Skip to content

fix: improve SkiaCameraCanvas layout handling#3668

Closed
therealpurplemana wants to merge 1 commit intomrousavy:mainfrom
therealpurplemana:fix/skia-canvas-layout
Closed

fix: improve SkiaCameraCanvas layout handling#3668
therealpurplemana wants to merge 1 commit intomrousavy:mainfrom
therealpurplemana:fix/skia-canvas-layout

Conversation

@therealpurplemana
Copy link
Copy Markdown

What

Wraps the Skia Canvas with a View component to provide better layout control and flexibility. The View handles layout events and styles, while the Canvas receives explicit width/height dimensions.

This fix is a backwards compatible patch for the post Skia 2.20 removal of canvas.onLayout.

Changes

  • Added View import from react-native to wrap the Skia Canvas component
  • Moved onLayout and style props to the outer View wrapper
  • Applied explicit width and height styles to the SkiaProxy.Canvas based on layout measurements
  • Merged user-provided styles with { flex: 1 } to maintain backwards compatibility
  • Canvas now receives dimensions from parent View instead of handling layout directly

Tested on

  • Expo 53 + React 19 + Skia 2.3.10 (with no memory leak on iOS!)

Related issues


🤖 Generated with Claude Code

Wraps the Skia Canvas with a View component to provide better layout control and flexibility. The View handles layout events and styles, while the Canvas receives explicit width/height dimensions.

This fix is a backwards compatible patch for the post Skia 2.20 removal of canvas.onLayout.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Nov 13, 2025

@therealpurplemana is attempting to deploy a commit to the mrousavy's Team Team on Vercel.

A member of the Team first needs to authorize it.

@gpadova
Copy link
Copy Markdown

gpadova commented Nov 18, 2025

Super important PR. Right now, it is not possible so the "useSkiaFrameProcessor" with Skia ˆ2.0.0 in the new arch.

@CanRau
Copy link
Copy Markdown

CanRau commented Nov 19, 2025

Yes please 🥹 just got started with vision-camera etc and hit this right away when trying my first frame processor 😅

Maybe it might even be interesting to be able to pass a custom SkiaCameraCanvas into Camera? 🤔

@makamekm
Copy link
Copy Markdown

Could you please approve it? This is very needed. Thanks @therealpurplemana!

@therealpurplemana
Copy link
Copy Markdown
Author

I would encourage more testing with it please before we merge. Can folks please pull the branch and test it locally and share results?

@evertdespiegeleer
Copy link
Copy Markdown

evertdespiegeleer commented Dec 12, 2025

I pulled in your branch and tried it. Seems to work at first sight, the explicit error is also gone!

After 14-ish frames, the video feed freezes. I'm doing nothing at all in the frame processor, just rendering the frame itself. The app's running out of memory, it seems like a memory leak. I suppose that's the issue being talked about here.

  const frameProcessor = useSkiaFrameProcessor((frame) => {
    'worklet';
    frame.render();
  }, [])

@maxximee
Copy link
Copy Markdown

  • onLayout

Yes still memory issue. You can get it working at 15 fps with low format (2048), but it will look horrible

@1997roylee
Copy link
Copy Markdown

onLayout is not support new arc!!!

@therealpurplemana therealpurplemana closed this by deleting the head repository Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 react-native-skia removed support for onLayout in v2.2.1

7 participants