Skip to content

test: frame output thread keeps accepting work after dispose() - #4212

Open
dmandrade wants to merge 1 commit into
margelo:mainfrom
dmandrade:test/frame-output-thread-after-dispose
Open

dmandrade wants to merge 1 commit into
margelo:mainfrom
dmandrade:test/frame-output-thread-after-dispose

Conversation

@dmandrade

Copy link
Copy Markdown

What

On Android, every CameraFrameOutput owns a single-thread executor (IdentifiableExecutor), and HybridFrameOutput.dispose() / HybridDepthFrameOutput.dispose() only call clearAnalyzer(). Nothing calls shutdown() on it, so each disposed output leaves a live com.margelo.camera.frame thread behind. Combined with useFrameOutput never disposing its output, the count grows by one per camera mount: 1 to 8 over 8 open/close cycles in our app, and 42 before the app froze in a long session.

Test

Adds one Harness test that creates a frame output, runs a task on its thread, disposes the output, and asserts the thread rejects new work. It is red on main because the executor keeps running.

No camera session is needed: the executor thread starts on the first task.

Notes

  • On iOS the thread is a DispatchQueue, which doesn't leak an OS thread but would also keep accepting work, so this may be red on iOS too. Whether "a disposed output's thread rejects work" should hold on both platforms is your call.
  • The fix we run locally (patch-package) shuts the executor down in both dispose() methods and ignores late CameraX callbacks. For this test to pass, runOnThread would also have to throw after shutdown. Happy to push that here if this direction looks right.
  • Related: fix: Clear native output callbacks in output hooks on unmount聽#4192 (clears hook callbacks on unmount; doesn't stop the thread), fix(android): Destroy the session lifecycle owner on reconfigure聽#4186 (Android session lifecycle owner leak).

On Android each CameraFrameOutput owns a single-thread executor that
dispose() never shuts down, so every disposed output leaves a live
thread behind. Assert that the output's thread rejects new work once
the output is disposed.
@vercel

vercel Bot commented Oct 6, 2026

Copy link
Copy Markdown

@dmandrade 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