Different Issues (Android and iOS) with useSkiaFrameProcessor
Description
Android Samsung S8 with android 9: Exception: ERROR Frame Processor Error: Exception in HostFunction: Failed to convert NativeBuffer to SkImage!, js engine: VisionCamera
Some other devices, for example Pixel 9 with android 15:
Black Screen:
iOS Memory Leak, memory increase until app crashes: https://youtube.com/shorts/kShery3nVW0
React Native Skia Version
1.11.7
React Native Version
0.76.7
Using New Architecture
- [x] Enabled
Steps to Reproduce
Start sample app linked below, just add useSkiaFrameProcessor to vision-camera. Relevant dependencies: "react-native-vision-camera": "4.6.3" "react-native-worklets-core": "1.5.0"
Snack, Code Example, Screenshot, or Link to Repository
https://github.com/maxximee/skiaIssues
const frameProcessor = useSkiaFrameProcessor((frame) => {
'worklet';
frame.render();
}, []);
return (
<Camera
style={StyleSheet.absoluteFill}
device={device}
isActive={true}
frameProcessor={frameProcessor}
/>
);
Note 1 : the sample repo only shows the crash and black screen on Android, it doesn't include the iOS yet. I'll add the ios build later, but I can reproduce the memory leak with my productive app. The iOS bug appeared in skia "1.11.x", it's working fine with "1.10.2",
Note 2 : Same result on android and ios with "newArchEnabled"
Having the same issue, memory leak on ios
I downgraded to "1.2.1" version, no crashes
Tested on Android, getting black screen
I'm experiencing the same iOS memory leak leading to a crash when using useSkiaFrameProcessor
react-native: 0.76.7
@shopify/react-native-skia: 1.12.3
@wcandillon Hi William, sorry to @ you directly. I was wondering if those issues are on the radar, to me it sounds like pretty major issues with the skiaFrameProcessor (the ios memory leak causing a crash and some android devices not working at all crash | black screen).
@maxximee we do plan do to maybe add an skia-frame-processor example and investigate this further but this will take a bit of time.
Just tried updating to the new SDK version; still the same thing: there's a leak somewhere... 🤔
Got a timelapse of the memory profile running on a physical device through Xcode, this with this minimal useSkiaFrameProcessor example:
https://github.com/user-attachments/assets/b67170c5-5772-49c1-84f7-e6ba5ef79461
Is there any update on this issue? There is still a breaking bug in useSkiaFrameProcessor on both iOS and most Android versions.
Still experiencing the leak with react-native-vision-camera :(
Just to add some details: The app works as expected on Android 13, but when running on Android 15, it breaks. If anyone has encountered similar issues with Android 15 or has suggestions for troubleshooting, I’d appreciate any guidance.
I'm experiencing the same iOS memory leak leading to a crash when using useSkiaFrameProcessor react-native: 0.77.2 @shopify/react-native-skia: 1.12.4
"@shopify/react-native-skia": "v2.0.0-next.4",
"react-native-worklets-core": "^1.6.2",
"react-native-vision-camera": "^4.7.1",
I'm experiencing the same issue using useSkiaFrameProcessor. It was working until mysteriously, it stopped working. Copy/pasting my comment from https://github.com/mrousavy/react-native-vision-camera/issues/3606
There's some very strange behaviour going on. I have a complex skia-processor that was working flawlessly. Then I changed some arbitrary code unrelated to the frame processing and it started crashing with the same behaviour as @abs007 describes.
The mind boggling issue for me is that even after I remove the code and revert back to code that was working without issue before, it still crashes. I've tried:
- npx expo prebuild --clean
- removing the app from the device (I'm running on a physical device using
npx expo ios --device)The app starts working again after I remove the
useSkiaProcessorhook. Even with a callback that simply renders the frame, it still crashes. Again, previously it was working flawlessly.Right now I can't get it back to a working state. It's like the development build itself gets stuck in a malloc loop.
Looks like with latest Skia update the ios memory leak issues might have been fix, I'll check soon. Android issues still there, useSkiaProcessor is not usable on Android (crashes or black screen on about 10% of devices). To reproduce, still same as in original issue description:
const frameProcessor = useSkiaFrameProcessor((frame) => {
'worklet';
frame.render();
}, []);
const frameProcessor = useSkiaFrameProcessor((frame) => {
'worklet';
frame.render();
}, []);
return (
<Camera
style={StyleSheet.absoluteFill}
device={device}
isActive={true}
frameProcessor={frameProcessor}
/>
);
Tested with : "@shopify/react-native-skia": "2.2.13", "react-native-vision-camera": "4.7.2",
Behavior on Android:
- Samsung s8: exception
ERROR Frame Processor Error: Exception in HostFunction: Failed to convert NativeBuffer to SkImage!, js engine: VisionCamera - Android 14, works for a while then exception:
E Failed to acquire image. java.lang.IllegalStateException: maxImages (6) has already been acquired, call #close before acquiring more. at android.media.ImageReader.acquireNextImage(ImageReader.java:664) at androidx.camera.core.AndroidImageReaderProxy.acquireNextImage(AndroidImageReaderProxy.java:86) at androidx.camera.core.SafeCloseImageReaderProxy.acquireNextImage(SafeCloseImageReaderProxy.java:86) at androidx.camera.core.ImageAnalysisBlockingAnalyzer.acquireImage(ImageAnalysisBlockingAnalyzer.java:39) at androidx.camera.core.ImageAnalysisAbstractAnalyzer.onImageAvailable(ImageAnalysisAbstractAnalyzer.java:126) at androidx.camera.core.SafeCloseImageReaderProxy.lambda$setOnImageAvailableListener$1$androidx-camera-core-SafeCloseImageReaderProxy(SafeCloseImageReaderProxy.java:211) at androidx.camera.core.SafeCloseImageReaderProxy$$ExternalSyntheticLambda0.onImageAvailable(D8$$SyntheticClass:0) at androidx.camera.core.AndroidImageReaderProxy.lambda$setOnImageAvailableListener$0$androidx-camera-core-AndroidImageReaderProxy(AndroidImageReaderProxy.java:167) at androidx.camera.core.AndroidImageReaderProxy$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651) at java.lang.Thread.run(Thread.java:1119) 2025-09-10 11:26:40.472 11333-11579 ImageAnalysisAnalyzer
- Android 15 and android 16: black screen.
any update about black screen on android?
any update about black screen on android?
Sadly android still not usable, I hope it will be fixed soon.
Any news for the android fix?
@wcandillon Hi William, Sorry to @ you directly, was wondering if there is a timeline when you would have time to look at the skiaFrameProcessor issue. I'm not sure it's related to the vision-camera or skia but it has been unusable since the start (trying since skia v1 all the way to latest version). Android crashes on about 10% of all devices and iOS has a memory leak leading to a crash on 100% of all devices. The only workaround for prod apps is to disable skia-frame-processor on android and set fps to 15 + image resolution to 2048x2048 on ios which gives pretty terrible results. Reproducing it is simple, I linked a git project above, basically empty project with just vison-camera and skia, add the skiaFrameProcessor and do nothing, just call frame.render()
@maxximee It appears that texture.value?.dispose() in SkiaCameraCanvas.tsx is not properly disposing of the image, which is causing the memory leak. After I commented out snapshotCopy in useSkiaFrameProcessor.js, the crash no longer occurred.