Skip to content

stopped session stays unbound after another session is cleared (Android repro) - #4231

Open
dakshshah96 wants to merge 1 commit into
margelo:mainfrom
dakshshah96:repro/session-unbind-all
Open

dakshshah96 wants to merge 1 commit into
margelo:mainfrom
dakshshah96:repro/session-unbind-all

Conversation

@dakshshah96

@dakshshah96 dakshshah96 commented Oct 22, 2026 •

Copy link
Copy Markdown

What the test does

  1. Session A (back camera, photo output) is configured, started, then stopped.
  2. Session B (same camera) is configured, started, stopped, and cleared with configure([]). This is what a second <Camera> mounting and unmounting does via useCameraSession's cleanup.
  3. Session A is started again and must fire onStarted and capture a photo.

Expected: A restarts and captures. On Android it shouldn't, because A's use-cases were unbound by B.

Cause

HybridCameraSession.configure() and dispose() (Android) call cameraProvider.unbindAll(). ProcessCameraProvider is process-wide, so tearing down one session unbinds every other session too. A's start() then only moves its CustomLifecycle to RESUMED with nothing bound. In our app this shows up as a black preview and a dead torch on a tab screen's <Camera> (kept mounted with isActive={false}) after another screen's <Camera> unmounts.

Fix we're running locally

Each session remembers the SessionConfig it bound (or the use-cases, for multi-cam) and unbinds only those with cameraProvider.unbind(...), in both configure() and dispose(). That fixed it on our device (Redmi Note 11T 5G, Android 11; VisionCamera 5.2.3, RN 0.88.0, New Architecture): 25/25 previews live across 12 round trips. Happy to open that as a PR if it's the direction you want.

I haven't been able to run the harness suite locally, so I'm relying on CI to confirm the failure.

On Android, HybridCameraSession.configure() and dispose() call
ProcessCameraProvider.unbindAll(). The provider is process-wide, so
clearing one session also unbinds every other session's use-cases, and
a stopped session that is started again never reopens the camera.

This test stops session A, sets up and clears session B on the same
camera, then restarts A and captures a photo from it.

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

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@dakshshah96 dakshshah96 changed the title test: stopped session stays unbound after another session is cleared (Android repro) stopped session stays unbound after another session is cleared (Android repro) Oct 22, 2026

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