flyskywhy / react-native-gcanvas

react native canvas based on gpu opengl glsl GCanvas -- A lightweight cross-platform graphics rendering engine. (超轻量的跨平台图形引擎)
Apache License 2.0
208 stars 21 forks source link

Any plans or possibilities to use JSI? #57

Open olosegres opened 1 year ago

olosegres commented 1 year ago

Hello, thanks for your work, appreciate it :)

Your tool opens the opportunity to use many libraries and algorithms from web development.

But animation rendering requires JS calculation and some things cannot work normally due to the calculation lags of each frame. JSI can solve this problem.

Have you think about the opportunity to use it with JSI?

I seems like existing API of react-native-gcanvas api will fit good to the approach that used in react-native-reanimated2 or react-native-skia.

flyskywhy commented 1 year ago

Recently (at least a year) I have no time to rewrite everything to JSI, if you desire JSI performance, maybe you can try expo-gl@^11.0.0.

react-native-skia just 2d, but react-native-gcanva support 2d and 3d, so react-native-skia is not considered.

And which api is fit good between react-native-gcanvas and react-native-reanimated2, for example?

olosegres commented 1 year ago

I meant js woklets, or a woklet hook, it seems the react-native-gcanvas js API can be left the same as it is now.

I don't know about the difficulty of translating to JSI, is it very labor intensive?

p.s. I can't use those libraries, because I have a lot of business logic tied to the canvas API

flyskywhy commented 1 year ago

Do you mean lot of business logic tied to the canvas API can be run in worklet e.g. https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/worklets/ ? Have you tested it or verified it?

With some blog about JSI I've read, translating to JSI need re-write every code so it is very labor intensive.

olosegres commented 1 year ago

Do you mean lot of business logic tied to the canvas API can be run in worklet e.g

I hope that one day it will be possible :) No, I didn't try it. I think It should require some patches on native side, but I'm not so deep into the wilds of react-native.