🐛 [Android] Each FrameOutput leaks its native thread (dispose() doesn't shut down the executor; useFrameOutput never disposes)
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 70/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- mobile-dev
Research direction
Start from the reproduction PR #4212 and the harness-tests README in apps/simple-camera/__tests__ to get a failing test. Locate the Android FrameOutput implementation (search the android native sources for FrameOutput and its dispose()), and find where the frame-processing executor is created but never shut down; then trace the JS side useFrameOutput hook to see where disposal should be invoked on camera close. Done means the adb shell ps -T | grep -c camera.frame count returns to baseline after each open/close cycle and the harness test passes.
Written by the indexing model from the issue text.
Description
Prerequisites
- I have read and followed every applicable step in the Nitro Modules Troubleshooting guide.
- I have read the VisionCamera Troubleshooting guide.
- I have searched existing issues and found nothing matching.
- I am on the latest version of react-native-vision-camera, or have a specific reason I cannot upgrade.
Reproduction
https://github.com/margelo/react-native-vision-camera/pull/4212
Steps to reproduce
- install simple app on an Android device or emulator
- Open the camera screen (uses useFrameOutput with a trivial onFrame that disposes the frame)
- Toggle the camera off and on
- After each cycle run: adb shell ps -T -p $(adb shell pidof ) | grep -c camera.frame
What did you expect to happen?
Closing the camera frees its frame thread. The count stays at 1 while the camera is open and 0 when it's closed.
What actually happened?
The count goes up by one every time the camera opens and never goes down. In our production app, in a test session reached 42 threads, and memory kept growing with each camera open. There's no crash; the app gets slower until it freezes.
Affected platforms
Android (device)
Device(s) affected
Android, Samsung s23e, Samsung galaxy AO5 and A07, Motorola G35
VisionCamera version
5.1.1
React Native version
0.86.3
React Native architecture
New Architecture (Fabric / bridgeless)
Features being used
- Preview
- Photo capture
- Video capture
- Frame Processors (worklets)
- Skia Frame Processors
- Code/Barcode Scanner
- Location metadata
- Multi-cam
- Depth data
- HDR / custom dynamic range
- Custom format / FPS / resolution
Relevant logs / stack trace
# VisionCamera 5.1.1, Android 14 emulator (API 34, x86_64)
# logs captured after the app froze following repeated camera screen opens.
# No error or warning is logged by VisionCamera/CameraX; the leak is silent in logcat.
total threads: 235, "lo.camera.frame" threads: 42 (all S / futex_wait)
16143 S 27465 futex_wait com.pdvmundo
16618 S 56 futex_wait lo.camera.frame
16784 S 84 futex_wait lo.camera.frame
16956 S 123 futex_wait lo.camera.frame
17063 S 139 futex_wait lo.camera.frame
17153 S 111 futex_wait lo.camera.frame
17260 S 115 futex_wait lo.camera.frame
... (36 more, same state)
21752 S 88 futex_wait lo.camera.frame
21918 S 103 futex_wait lo.camera.frame
Additional context
No response
Submission
- The reproduction I linked is either (preferred) a PR against this repo that adds a failing harness test following the harness-tests README, or (fallback) a public repo that reproduces the bug on a fresh clone. I understand the issue will be closed without one.
- I pasted logs as text (not screenshots).
- I wrote this report in my own words. I did not paste AI-generated descriptions of the bug.
- Dominant language
- TypeScript
- Stars
- 9.6k
- Forks
- 1.4k
- Avg merge
- 16h 53m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from margelo/react-native-vision-camera
-
Android (vision-camera-location): HybridLocationManager never quits its HandlerThread on disposeOpen
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
margelo/react-native-vision-camera#4217 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
margelo/react-native-vision-camera#4216 ·
Maintainers usually reply within 3 days
-
🐛 bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
margelo/react-native-vision-camera#4211 ·
Maintainers usually reply within 3 days
-
🐛 bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
margelo/react-native-vision-camera#4096 · 3 comments ·
Maintainers usually reply within 3 days
-
🐛 bug
Difficulty 4/5 3-5 days Newbie friendliness 20/100
margelo/react-native-vision-camera#4219 ·
Maintainers usually reply within 3 days
All issues in margelo/react-native-vision-camera
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
stellar/stellar-dev-skill#151 ·
Maintainers usually reply within 1 day
-
area:arcade game ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
fderuiter/deruiter.dev#2281 · 1 comment ·
Maintainers usually reply within 1 day
-
scope: data grid type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
fix(frontend): correct VITE_IS_DEVELPOMENT typo in shared/app.ts and align dev environment flagsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
vicharanashala/ajrasakha#1439 ·
Maintainers usually reply within 1 day
-
Add: TV5Monde AsieOpenapproved check:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day