react-native-skia: Big regression after upgrading to v2 on react native 0.79
Description
I have a library for rendering the table with Canvas on the web and with skia on mobile. It was working reasonably well with react native 0.76.9 + new arch
After upgrading to react native 0.79 + react 19 and react-native-skia v2. I’m facing significant issues. Flicker, memory leaks and skia elements being transparent on first render.
Here is the video of that.
https://github.com/user-attachments/assets/81b266e4-c659-410d-a84b-21fbcb179ba1
And this was before (on react 18.3 and react native 0.76.9)
https://github.com/user-attachments/assets/0e739a00-3572-457b-a9a9-16002a9d72ce
React Native Skia Version
2.0.0-next.2
React Native Version
0.79.0
Using New Architecture
- Enabled
Steps to Reproduce
This is a public repo where you can reproduce it. (the branch should be adopt/new-arch
It includes the source code of the table rendering logic as well
If you go to examples/expo folder and run pnpm ios. You’ll be able to see it
https://github.com/webbeetechnologies/datagrid/tree/adopt/new-arch
And on the main branch, we have the old version where it’s using react 18 and react native 0.76.9
https://github.com/webbeetechnologies/datagrid
Snack, Code Example, Screenshot, or Link to Repository
https://github.com/webbeetechnologies/datagrid/tree/adopt/new-arch
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 21 (7 by maintainers)
hehe funny I was already looking into it this morning. I also plan to address your comments above but first I want to fix something that might be indeed a regression.
@thetaungg Currently React Native Skia scene graph (the declarative components you are using) is really optimized to render once on the JS thread and then be animated on the main thread (using Reanimated for instance). This is why you’re experiencing issues. Currently you’re updating from the JS thread on every animation frame (causing the whole drawing tree to be re-rendered). And while this can be fast enough on iOS maybe, on low-end Android devices, it will never be fast enough (especially in debug mode and with Hermes). From there, I recommend two ways to go about it:
See if the code can be restructured in a way that follows this model: JS thread to build the initial scene, then animation values. Maybe the declarative model is not a good fit for the complex canvas you are trying to achieve (we have many use cases for which this is the case, for instance people building games), in which case you want to use the picture API to draw highly dynamic scenes using Reanimated: https://shopify.github.io/react-native-skia/docs/shapes/pictures/
I hope this helps and that it makes sense. I am closing this issue for now, but if you provide me with an example whose performance should really be investigated, I will take a look and reopen this. Regardless, let’s keep discussing to see if we can find a model that fits your use case.
I’m really upset, i hope react-native-signature-canvas help me out
Same. We’re thinking of moving to canvas with WebView for the time being.