Skip to content

fix(scanner): prevent ANR from uncaught ImageProxy.close() exception#844

Merged
bmc08gt merged 1 commit into
code/cashfrom
fix/scanner-imageproxy-anr
Jun 4, 2026
Merged

fix(scanner): prevent ANR from uncaught ImageProxy.close() exception#844
bmc08gt merged 1 commit into
code/cashfrom
fix/scanner-imageproxy-anr

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

ImageProxy.close() in the finally block of MultiCodeAnalyzer.analyze() can throw IllegalArgumentException when CameraX pipeline is already torn down. With no CoroutineExceptionHandler on the scope, the exception propagated to ThreadGroup.uncaughtException and killed the app.

  • Wrap image.close() with runCatching to absorb the benign failure
  • Add CoroutineExceptionHandler to route any future uncaught exceptions to the caller onError handler instead of the process kill path

Fixes: Bugsnag 69eada8ad5699cd63c22712a

ImageProxy.close() in the finally block of MultiCodeAnalyzer.analyze()
can throw IllegalArgumentException when CameraX pipeline is already torn
down. With no CoroutineExceptionHandler on the scope, the exception
propagated to ThreadGroup.uncaughtException and killed the app.

- Wrap image.close() with runCatching to absorb the benign failure
- Add CoroutineExceptionHandler to route any future uncaught exceptions
  to the caller onError handler instead of the process kill path

Fixes: Bugsnag 69eada8ad5699cd63c22712a

Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
@bmc08gt bmc08gt self-assigned this Jun 4, 2026
@github-actions github-actions Bot added type: fix Bug fix area: ui Compose UI, theme, components, resources area: scanner QR/Kikcode scanning, camera labels Jun 4, 2026
@bmc08gt bmc08gt merged commit 19c44a3 into code/cash Jun 4, 2026
3 checks passed
@bmc08gt bmc08gt deleted the fix/scanner-imageproxy-anr branch June 4, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: scanner QR/Kikcode scanning, camera area: ui Compose UI, theme, components, resources type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant