Resolve the loaded native crash handler and contain startup failures - #297
Merged
Conversation
* fix(android): report the ABI of the running process as device.abi * feat(android): select the extracted-library directory by process ABI * test(android): pin the native interop signatures in in-editor CI * fix(android): query the linker first and contain metadata and ANR failures * ci: build Android players on Unity 2022.3 and 6000.3 * ci: provide the synthetic build project with a registered scene
* fix(android): make native library fallback resolution fail-safe - Treat filesystem, parent-directory, and system-library-path discovery as optional enrichment so failures cannot block linker or installed-package resolution. - Require an exact process-ABI directory match when the ABI is known and reject ambiguous candidates deterministically. * fix(android): roll back incomplete native initialization - Track native backend activation before JNI cleanup and disable the backend when attribute setup or cleanup fails after initialization. - Attempt every local-reference deletion, preserve the original setup failure, and contain rollback diagnostics. * fix(android): contain ANR JNI lifecycle failures - Contain watchdog attach, detach, dump, and attribute failures without escaping the worker thread. - Retry transient attachment failures and always restore error.type to Crash after a hang-report attempt. * fix(android): make native shutdown failure-safe - Clear native and watcher state before cleanup, then run every shutdown stage independently. - Keep native-disable, watcher-stop, watcher-dispose, and diagnostic failures nonfatal. * ci(android): validate IL2CPP app bundle packaging - Compile the SDK from Assets in every Android build lane while importing only the Editor, Runtime, and Android package content. - Add a Unity 6 ARM64 IL2CPP App Bundle build, verify the required native libraries are packaged, and identify the platform and Unity version in job names.
* fix(native): handle dynamic attribute update failures * fix(android): continue after linker path lookup failures * feat(android): update NativeClient NativeAttributeLifecycle * fix(android): roll back partial native initialization - mark native bridge completion before JNI cleanup - roll back partial native state when initialization returns false - contain rollback and diagnostic failures - cover pre-bridge rejection and false-result rollback * test(android): exercise OOM attribute continuation in editor - add an instance-scoped native attribute writer for deterministic tests - compile the Android client test path in ordinary Editor lanes without JNI - verify OnOOM attempts the timestamp after the first native write fails - assert sanitized failure diagnostics * ci(android): verify Java crash handler in app bundles - inspect every base DEX entry in the generated App Bundle - require the BacktraceCrashHandler class descriptor - report missing DEX files and missing handler packaging clearly
- Remove empty EditMode lanes that have no corresponding test assembly. - Validate NUnit results and require the critical Android lifecycle tests. - Cover missing, malformed, empty, failed, and incomplete test results.
melekr
marked this pull request as ready for review
August 21, 2026 19:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improve Android native crash-handler startup for Unity applications where Backtrace native library is loaded directly from an APK or an Android App Bundle ABI split.
The SDK now resolves the native library selected by Android's linker, while retaining extracted-library, installed split, and base-APK fallbacks.
This PR also incorporates the runtime attribute-containment changes from #300 and strengthens native initialization, JNI cleanup, ANR handling, shutdown, child-process environment construction, and crash-handler failure handling.
Docs
saucelabs/sauce-docs#3640
Problem
The previous Unity implementation constructed the crash-handler library path from the base APK,
nativeLibraryDir, and a device-preferred ABI.That can produce an incorrect path when:
nativeLibraryDiror Unity activity metadata is unavailableThe native bridge also had several lifecycle and interop risks:
voidexports were declared as returningboolfalseafter partially initializing native stateWhat changed
Native-library resolution
libbacktrace-native.sopath through Android's native linker.ApplicationInfometadata.Running-process ABI
device.abireport attribute.Native initialization and JNI
false;Dynamic native attributes
SetAttributes(...)entries after one native write fails.ANR and shutdown lifecycle
error.type=Crashafter every ANR dump attempt.Crash-handler child process
Child-process environment
CLASSPATHBACKTRACE_UNITY_CRASH_HANDLERLD_LIBRARY_PATHANDROID_DATACI and packaging
libil2cpp.so;libbacktrace-native.so;BacktraceCrashHandlerclass in a base-module DEX file.Compatibility
C.I