🐛 react-native-skia removed support for `onLayout` in v2.2.1
What's happening?
onLayout that's used in SkiaCameraCanvas.tsx was recently removed in @shopify/react-native-skia v2.2.1 release and is now replaced with onSize.
Workaround for now is to downgrade @shopify/react-native-skia to v2.2.0 or lower.
Reproduceable Code
const frameProcessor = useSkiaFrameProcessor(
frame => {
'worklet';
frame.render();
},
[],
);
VisionCamera Version
@shopify/react-native-skia @^2.2.1
Can you reproduce this issue in the VisionCamera Example app?
Yes, I can reproduce the same issue in the Example app here
Additional information
- [ ] I am using Expo
- [x] I have enabled Frame Processors (react-native-worklets-core)
- [x] I have read the Troubleshooting Guide
- [x] I agree to follow this project's Code of Conduct
- [x] I searched for similar issues in this repository and found none.
Guten Tag, Hans here 🍻.
Thank you for reporting zhis issue! It seems like you are facing a problem with onLayout being removed in a recent update of @shopify/react-native-skia, and I appreciate you providing useful information. However, I noticed zat you haven’t attached any relevant logs or detailed information about your camera device and environment.
For better assistance, could you please provide logs from Xcode or Android Studio, depending on your development environment? You can gather logs using adb logcat for Android or by viewing the logs in Xcode when running your app.
Also, to make sure this issue gets the attention it deserves, feel free to support zhe project by becoming a sponsor here, if possible.
Looking forward to your response!
Note: If you think I made a mistake, please ping
@mrousavyto take a look.
If you or someone else has the issue yet, since you are using the Skia v2 and onLayout was obsoleted, you need to apply some changes to */node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx. If you'd like to specify the canvas size on the UI thread and you are using RN reanimated, follow this guide:
https://shopify.github.io/react-native-skia/docs/canvas/overview/#ui-thread
Otherwise:
https://shopify.github.io/react-native-skia/docs/canvas/overview/#js-thread
Then, use the patch-package lib to patch it. Also, I attached the patch file for the size specifying on the UI thread (guide 1), so that you can alternatively copy it to the patches dir and use the lib for patching it.
Note: the patch file is compatible with react-native-vision-camera version 4.7.1
Hi @mrousavy , any updates on this?
Thanks @Mhp23 your patch does work. With skia 2.2.13 the error is now gone, using a useSkiaFrameProcessor does freeze the image on ios though. Can't find a solution yet.
Hi @maksymblank, you're welcome.
I also came across the issue that, if I’m not wrong, starts from version 2.2.11. I didn’t have enough time to explore the reason for the issue, so I recommend downgrading the lib to 2.2.10 until the issue is found and solved.
Hi @maksymblank, you're welcome. I also came across the issue that, if I’m not wrong, starts from version
2.2.11. I didn’t have enough time to explore the reason for the issue, so I recommend downgrading the lib to2.2.10until the issue is found and solved.
Exactly, the behaviour changes between 2.2.10 and 2.2.11. In 2.2.10 it works but the memory increases indefinetly until the app crashes, starting from 2.2.11 it just freezes after less than a second.
I've been using version 1.10 successfully until now, but I've migrated from expo 52 to 53 and new arch, so I can't revert back to version 1.x sadly. I'm a bit stuck and trying to fix the vision-camera but without any luck so far.
In IOS as soon as the camera screen is pushed into the navigation stack after two seconds it throws onLayout not being supported on New Arch.
Is downgrading the packages the only option left or going back to Old Arch? I have to undo all the migration i did for RN 0.81 and Expo 54.
Been stuck with this for 5 days. I cant figure out anything except patch-package and updating it to onSize, but i am not sure if i do that the results would be the same as before.
In IOS as soon as the camera screen is pushed into the navigation stack after two seconds it throws onLayout not being supported on New Arch.
Is downgrading the packages the only option left or going back to Old Arch? I have to undo all the migration i did for RN 0.81 and Expo 54.
Been stuck with this for 5 days. I cant figure out anything except patch-package and updating it to onSize, but i am not sure if i do that the results would be the same as before.
Even if you fix that error, you'll still face a freeze after a few seconds. There is also a memory leak that leads to crash after a few seconds on older versions. I managed to make it kind of work using one of 2.2.0 version and limiting the fps to 10 (above 12/15 fps it crashes). This leaves just enough time for the memory to be flushed before the app crashes. This means your app's memory will increase really high then be flushed just on time before a crash... Needless to say it's not great but with current state it's as good as I got it running
@Mhp23 By the way, I've noticed your patch has an incorrect size and zooms in the picture. But it's a good start, thanks for it anyways.
I've been using version 1.10 successfully until now, but I've migrated from expo 52 to 53 and new arch, so I can't revert back to version 1.x sadly. I'm a bit stuck and trying to fix the vision-camera but without any luck so far.
FYI 1.x can work in RN new arch -- I had it working in Expo 52
Would really appreciate having this fixed. I'm new to React Native and am just following the basic instructions to install React Native, Vision Camera, and Skia from the official docs. Unfortunately it's broken due to this error.
ERROR <Canvas onLayout={onLayout} /> is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size
Deps are here:
"expo": "~54.0.20"
"react": "19.1.0",
"react-native": "0.81.5",
"@shopify/react-native-skia": "2.2.12",
"react-native-reanimated": "~4.1.1",
It ends me up in this situation after running:
npx create-expo-app@latest
npx expo install react-native-vision-camera
npm i @shopify/react-native-skia
npm i react-native-reanimated
If anyone has a suggestion for how to bypass this, I'd appreciate it. Otherwise I guess I just need to wait until this issue is fixed to develop my camera effects app. I am doing Android fwiw.
I should mention that I did try and downgrade react-native-skia to 2.2.10 as some suggested, however it didn't fix the issue. I can't go back to 1.x without causing a whole bunch of dependency incompatibilities.
EDIT
Confirmed that @Mhp23 's patch did work against react-native-vision-camera 4.7.2 to support react-native-skia 2.2.12
EDIT2
It's not working when the phone is rotated
Mesmo problema aqui.
Tried to update the SkiaCameraCanvas.tsx with the new UI and JS methods set by @shopify/react-native-skia
Both lead to a frozen camera.
Tried to update the
SkiaCameraCanvas.tsxwith the new UI and JS methods set by @shopify/react-native-skiaBoth lead to a frozen camera.
Same here, it fixed the error in the log, but frozen camera. My only work-around was to use an old version of skia (2.2.4) and set fps to 15 + format to 2048. It leads to a low resolution preview with bad frame rate, but it's the only work-around I've found. I tried a lot to fiddle with the values (fps / resolution), but as soon as I increase either one the crashes start to show up on low-end devices like iphone 12
is not supported on the new architecture, to fix the issue, see: https://shopify.github.io/react-native-skia/docs/canvas/overview/#getting-the-canvas-size
@mrousavy getting the same issue any solution on this
Is there any update on this? I'm trying to apply a blur background filter and this prevents me doing it.
Is there any update on this @mrousavy ? useSkiaFrameProcessor cannot be used right now, due to this . @maxximee did you find any reliable workaround for this with new arch? Thanks
Is there any update on this @mrousavy ? useSkiaFrameProcessor cannot be used right now, due to this . @maxximee did you find any reliable workaround for this with new arch? Thanks
Not really, on android I disable frame processor (no available workaround), on ios I use an old version before the onLayout bug and limit format to 2048x2048 to avoid the memory leak exception. Looks like crap but it's the only way until this is fixed.
This is working for us with latest Skia (yes, latest), expo 53. You need to watch your GC much more carefully than 1.X
react-native-vision-camera+4.7.3.patch:
diff --git a/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx b/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx
index 56d4e0e..2c7da4b 100644
--- a/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx
+++ b/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx
@@ -1,4 +1,5 @@
import React, { useCallback, useState } from 'react'
+import { View } from 'react-native'
import type { LayoutChangeEvent, ViewProps } from 'react-native'
import type { CameraProps } from '../types/CameraProps'
import type { ISharedValue } from 'react-native-worklets-core'
@@ -47,10 +48,12 @@ function SkiaCameraCanvasImpl({ offscreenTextures, resizeMode = 'cover', childre
}, [])
return (
- <SkiaProxy.Canvas {...props} onLayout={onLayout} pointerEvents="none">
- {children}
- <SkiaProxy.Image x={0} y={0} width={width} height={height} fit={resizeMode} image={texture} />
- </SkiaProxy.Canvas>
+ <View {...props} onLayout={onLayout} style={[props.style, { flex: 1 }]}>
+ <SkiaProxy.Canvas style={{ width, height }} pointerEvents="none">
+ {children}
+ <SkiaProxy.Image x={0} y={0} width={width} height={height} fit={resizeMode} image={texture} />
+ </SkiaProxy.Canvas>
+ </View>
)
}
This is working for us with latest Skia (yes, latest), expo 53. You need to watch your GC much more carefully than 1.X
react-native-vision-camera+4.7.3.patch:
diff --git a/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx b/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx index 56d4e0e..2c7da4b 100644 --- a/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx +++ b/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx @@ -1,4 +1,5 @@ import React, { useCallback, useState } from 'react' +import { View } from 'react-native' import type { LayoutChangeEvent, ViewProps } from 'react-native' import type { CameraProps } from '../types/CameraProps' import type { ISharedValue } from 'react-native-worklets-core' @@ -47,10 +48,12 @@ function SkiaCameraCanvasImpl({ offscreenTextures, resizeMode = 'cover', childre }, []) return ( - <SkiaProxy.Canvas {...props} onLayout={onLayout} pointerEvents="none"> - {children} - <SkiaProxy.Image x={0} y={0} width={width} height={height} fit={resizeMode} image={texture} /> - </SkiaProxy.Canvas> + <View {...props} onLayout={onLayout} style={[props.style, { flex: 1 }]}> + <SkiaProxy.Canvas style={{ width, height }} pointerEvents="none"> + {children} + <SkiaProxy.Image x={0} y={0} width={width} height={height} fit={resizeMode} image={texture} /> + </SkiaProxy.Canvas> + </View> ) }
That removes the error, but doesn't fix the existential bugs sadly. iOS will still freeze / crash because of memory leak and android will still crash or show black screen on about 10% of all devices. It might work for you on your development device, but trust me once you deploy on PROD you will see high crash rates and regret.
PM me on discord. I’ll add you to TestFlight. It’s not crashing. I had to lower the camera resolution.
On Sun, Jan 25, 2026 at 8:47 PM maxximee @.***> wrote:
maxximee left a comment (mrousavy/react-native-vision-camera#3598) https://github.com/mrousavy/react-native-vision-camera/issues/3598#issuecomment-3797886385
This is working for us with latest Skia (yes, latest), expo 53. You need to watch your GC much more carefully than 1.X
react-native-vision-camera+4.7.3.patch:
diff --git a/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx b/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx index 56d4e0e..2c7da4b 100644 --- a/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx +++ b/node_modules/react-native-vision-camera/src/skia/SkiaCameraCanvas.tsx @@ -1,4 +1,5 @@ import React, { useCallback, useState } from 'react' +import { View } from 'react-native' import type { LayoutChangeEvent, ViewProps } from 'react-native' import type { CameraProps } from '../types/CameraProps' import type { ISharedValue } from 'react-native-worklets-core' @@ -47,10 +48,12 @@ function SkiaCameraCanvasImpl({ offscreenTextures, resizeMode = 'cover', childre }, [])
return (
- <SkiaProxy.Canvas {...props} onLayout={onLayout} pointerEvents="none">
{children}<SkiaProxy.Image x={0} y={0} width={width} height={height} fit={resizeMode} image={texture} />- </SkiaProxy.Canvas>
- <View {...props} onLayout={onLayout} style={[props.style, { flex: 1 }]}>
<SkiaProxy.Canvas style={{ width, height }} pointerEvents="none">{children}<SkiaProxy.Image x={0} y={0} width={width} height={height} fit={resizeMode} image={texture} /></SkiaProxy.Canvas>) }
That removes the error, but doesn't fix the existential bugs sadly. iOS will still freeze / crash because of memory leak and android will still crash or show black screen on about 10% of all devices. It might work for you on your development device, but trust me once you deploy on PROD you will see high crash rates and regret.
— Reply to this email directly, view it on GitHub https://github.com/mrousavy/react-native-vision-camera/issues/3598#issuecomment-3797886385, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATTERSZW7PEJMLSGPNTZ5AL4IWL6JAVCNFSM6AAAAACDJQRROCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTOOJXHA4DMMZYGU . You are receiving this because you commented.Message ID: @.***>