Skip to content

Fix cold-start ANR: resolve the native crash handler without reading the APK - #218

Merged
melekr merged 43 commits into
masterfrom
apk/native_startup_anr_fix
Aug 14, 2026
Merged

Fix cold-start ANR: resolve the native crash handler without reading the APK#218
melekr merged 43 commits into
masterfrom
apk/native_startup_anr_fix

Conversation

@melekr

@melekr melekr commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Problem

Native crash-handler path resolution synchronously opened the application's base APK and candidate split APKs with Java ZIP APIs.
Opening large APKs can parse their ZIP central directories on the calling thread and delay application startup.

Fixes

  • Add Native crash-handler test coverage #222
  • Resolve the native-library path selected by Android's linker.
  • Prefer an existing extracted native library.
  • Use installed split metadata only as fallback.
  • Do not open or parse the base APK or split APK ZIP contents.
  • Use the running process ABI when fallback construction requires one.
  • Compare split candidates globally and reject ambiguous matches.
  • Contain optional-native setup, disable, and dump failures.
  • Preserve managed reporting when native integration is unavailable.
  • Restart native uploads after disable followed by enable.
  • Sanitize native failure diagnostics.

API behavior

  • Existing void enableNativeIntegration(...) APIs remain compatible.
  • tryEnableNativeIntegration(...) reports whether native registration succeeded.
  • dumpWithoutCrash() is safe while native integration is unavailable or disabled.
  • Initialization remains synchronous and process-scoped.

Docs

https://docs.saucelabs.com/error-reporting/platform-integrations/android/native-crash-integration/

Compatibility

  • Minimum Android API remains 21.
  • Monolithic APK and Android App Bundle installations are supported.
  • x86_64, armeabi-v7a, and arm64-v8a remain supported, x86 native capture remains unsupported.
  • Flexible 16 KB page-size support is preserved.

ref: BT-7431
ref: BT-7447
ref: BT-7448
ref: BT-7449
ref: BT-7450
ref: BT-7458
ref: BT-7472

@melekr melekr self-assigned this Aug 10, 2026
@melekr melekr changed the title fix(native): resolve crash-handler library without parsing the APK [wip] fix(native): resolve crash-handler library without parsing the APK Aug 10, 2026
@melekr
melekr marked this pull request as ready for review August 10, 2026 22:31
@melekr
melekr marked this pull request as draft August 10, 2026 23:15
melekr added 22 commits August 11, 2026 10:19
library load and handler dispatch are contained separately (RuntimeException and LinkageError each) with distinguishable messages.
@melekr melekr changed the title [wip] fix(native): resolve crash-handler library without parsing the APK Resolve crash-handler library without parsing the APK Aug 12, 2026
@melekr melekr changed the title Resolve crash-handler library without parsing the APK Fix cold-start ANR: resolve the native crash handler without reading the APK Aug 12, 2026
@melekr
melekr marked this pull request as ready for review August 14, 2026 17:43
@melekr
melekr requested a review from KishanPRao August 14, 2026 19:51
@melekr
melekr merged commit 2249998 into master Aug 14, 2026
21 of 22 checks passed
@melekr
melekr deleted the apk/native_startup_anr_fix branch August 14, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant