Skip to content

fix(android): report the reason behind a camera interruption - #4226

Open
radko93 wants to merge 2 commits into
margelo:mainfrom
radko93:feat/android-interruption-reason
Open

radko93 wants to merge 2 commits into
margelo:mainfrom
radko93:feat/android-interruption-reason

Conversation

@radko93

@radko93 radko93 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Problem

On Android, onInterruptionStarted always reports 'unknown'. HybridCameraSession.onInterruptionStarted() hardcodes InterruptionReason.UNKNOWN, and the CameraX StateError that caused the interruption is dropped in ActiveCameraSessionSingle.

We see devices (moto g stylus 5G 2024, motorola edge 2024) that get interrupted mid-recording in nearly every camera session, and without the reason we cannot tell why.

Change

  1. fix(android): report the CameraX error behind an interruption passes the StateError through ActiveCameraSession.Listener and maps ERROR_CAMERA_IN_USE to the existing 'video-device-in-use-by-another-client'. No public API change.
  2. feat(android): add max-cameras-in-use and other-recoverable-error interruption reasons covers the other two RECOVERABLE CameraState errors with two new InterruptionReason values. iOS never emits them. Generated with bun camera specs.

CameraX has exactly three RECOVERABLE errors, so with both commits the mapping is complete. The second commit is the API-visible part; happy to rename the values or drop it if you prefer a different mapping.

Verification

  • bun run lint-kotlin, biome, bun camera typecheck and the example app tsc are clean.
  • ./gradlew assembleDebug of the example app builds.
  • No harness test: an interruption needs another app to take the camera, which the harness cannot do. To check by hand, start a session on Android, then open the camera in another app (for example in split screen), and expect 'video-device-in-use-by-another-client'.

Generated with Claude Code

radko93 and others added 2 commits October 19, 2026 15:08
`onInterruptionStarted` always reported `'unknown'` on Android because
`HybridCameraSession` hardcoded `InterruptionReason.UNKNOWN` and the
`StateError` that triggered the interruption was dropped. Pass it through,
and map `ERROR_CAMERA_IN_USE` (another app or the system took the camera)
to `'video-device-in-use-by-another-client'`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… interruption reasons

CameraX reports three recoverable `CameraState` errors, which VisionCamera
turns into interruptions. `ERROR_CAMERA_IN_USE` already maps to
`'video-device-in-use-by-another-client'`; the other two had no matching
`InterruptionReason`:

- `ERROR_MAX_CAMERAS_IN_USE` -> `'max-cameras-in-use'`
- `ERROR_OTHER_RECOVERABLE_ERROR` -> `'other-recoverable-error'` (device
  error or disconnect that CameraX retries)

iOS never emits these values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 19, 2026

Copy link
Copy Markdown

@radko93 is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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