Disable XNNPACK and NNAPI for the wake word / VAD interpreters (fixes #105) - #109
Merged
Merged
Conversation
…rXbox#105) Any TFLite inference on live audio crashed the app on the 32-bit Wall Displays (X2/PEGASUS on Android 8.1 and Gen1/STARGATE on Android 7): SIGSEGV at libtensorflowlite_jni.so+0x1f9b68, XNNPACK's qs8_gemm_minmax 4x8 aarch32 NEON kernel, called with a garbage input pointer (0x14). TFLite enables the XNNPACK delegate by default, so the NNAPI-only change did not reach that code path. With XNNPACK off the segfault is gone, but on the X2 (API 27) the NNAPI runtime then leaks a memory mapping per execution (/proc/<pid>/maps grows ~7000 entries per 20 s) until it hits vm.max_map_count and pthread_create fails: "thread constructor failed: Try again" in android::nn::StepExecutor::startComputeOnCpu. The wake word and VAD models are 52 KB / 34 KB; the built-in int8 CPU kernels handle them with ~40 % of one core on a quad A7, so neither delegate is needed. Verified on both 32-bit devices (wake word detected and answered end to end, stable for hours) and on the arm64 XL. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Fixes #105.
Two separate problems on the 32-bit Wall Displays, both in
WakeWordDetector.buildInterpreter:qs8_gemm_minmax 4x8 aarch32 NEONkernel segfaults (fault addr 0x14,libtensorflowlite_jni.so+0x1f9b68) as soon as the wake-word or VAD model runs on live audio. Reproduced bit-identically on the X2 (PEGASUS, Android 8.1) and the Gen1 (STARGATE, Android 7, which has no NNAPI at all), so 3d13d7f alone doesn't reach it./proc/<pid>/maps+~7000 entries per 20 s) until it hitsvm.max_map_countand dies withthread constructor failed: Try againafter ~3 minutes.The models are 52 KB / 34 KB and the plain int8 CPU kernels run them at ~40 % of one core on the quad-A7 STARGATE, so both delegates are simply disabled. Verified with a patched 3.26230.0834 on the STARGATE and the X2 (wake word detected and answered end to end, stable for hours) and on the arm64 XL. Measurements, disassembly and logs: #105 (comment).
Side effect: this also makes
maincompile again – 3d13d7f referencesBuild.VERSION.SDK_INTwithout importingandroid.os.Build(error: package Build does not existincompileDebugJavaWithJavac); that block is gone with this change.:app:assembleDebugpasses with this branch.🤖 Generated with Claude Code