react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

feat: Use `setExternalMemoryPressure` to notify JS VM about `Frame`'s actual size (on GPU)

Open mrousavy opened this issue 1 year ago • 1 comments

What

Uses setExternalMemoryPressure to notify the JS VM about the Frame's actual size (the byte buffer on the GPU, which is bytesPerRow * height).

If the JS VM (e.g. Hermes) knows the true size of the Frame in memory, it will delete old stale FrameHostObjects sooner instead of just keeping them floating around in memory because it thinks it's just a few bytes in size. (right now around 400 of those pile up until GC hits, with this PR only 3 pile up at a time)

This doesn't really matter for us since we need to eagerly delete the Frame after the Frame Processor is done, because the Camera pipeline stalls otherwise.

So we still need to keep the manual ref counting stuff. Make sure to use it properly!

Changes

Tested on

Related issues

mrousavy avatar Jul 24 '24 12:07 mrousavy

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-vision-camera ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2024 0:40am

vercel[bot] avatar Jul 24 '24 12:07 vercel[bot]