Repository navigation
Conversation
|
These results are for the first version of this PR (a8ddb69), which disposed the output in the hook. The next comment has the results for the current head. Thread count on a Pixel 8 Pro, from
Harness runs on the same device: both new tests fail on the baseline APK and pass with the fix (hooks and frame suites, 19 passed, 3 skipped). The two camera-view failures (initial zoom, initial torch) fail on the baseline too. |
|
@chocky335 is attempting to deploy a commit to the Margelo Team on Vercel. A member of the Team first needs to authorize it. |
|
Device results for the lifetime change, Pixel 8 Pro (Android 17), debug build,
The hook stopped disposing the output because a cleanup cannot tell a hide from an unmount. When React shows a hidden tree again, it reconnects child effects before parent effects, with the props they committed before the hide. So Two guards keep a frame from reaching a dead worklet runtime. The Kotlin analyzer reads the callback for each frame, because CameraX runs the analyzer it captured when it posted the frame. The worklets provider queues a small task on the frame thread behind every callback removal, so the runtime stays reachable until that removal has run.
Red check: with the three Kotlin files and the two JS files from this PR's previous version, 8 of the new harness tests fail. At this head, all 34 pass (3 skipped on Android). |
27359bf to
890f5da
Compare
|
Independent confirmation on #4213: guuhgalvao ported this branch onto 5.1.1 and saw one |
What
On Android, each frame output keeps its
com.margelo.camera.framethread after the camera closes, so every mount leaks one thread.How
IdentifiableExecutornow lets that thread exit after 5 s while no frame callback is set, and shuts it down once nothing references the executor.useFrameOutputremoves its callbacks on unmount, hide and option changes, and never disposes the output, because React can hand the same output to effects again.Review focus: after 5 s without a frame callback, the Android frame output can run on a new thread (the
NativeThreaddocs allow this), and 5 s is a tuning choice.On iOS,
setOnFrameDroppedCallbacknow sets the callback on the output's queue, wheredidDropreads it. The #4212 test stays red on iOS untilHybridNativeThread.swiftrejects work afterdispose(). Callback removal foruseDepthOutputis a follow-up.Closes #4213
Related Pull Requests
useFrameOutputcleanups are included here, split so that a newonFramedoes not clear the analyzer