Open sergeymorkovkin opened 4 months ago
Likely, I need to implement frame pacing.
@sergeymorkovkin I hadn't the time to process the message above. I just wanted to write a quick note that I did build a prototype that implements frame pacing using that exact SDK. Back then we thought this would be the key to a fast first time to frame and sync the frames with native views. I didn't yield any benefits for us. I thought I would mention it.
Thank you for providing us with a standalone example. Would you mind providing us (even privately) with bunnies.png? That would allow us to test the example.
If you believe that indeed useRSXformBuffer is invoked more than once per frame. This is a bug. Did you try these examples in Release mode? On Android, Hermes in Debug mode is exceptionally slow.
Hi @wcandillon,
Responding to both of your messages:
I'm now trying to implement Frame Pacing with a WebGL-based bunnymark, and this might give us some more information on the context.
I understand that you've implemented Frame Pacing for RNSkia, and it didn't work well. This is definitely another valuable observation. Not sure how to explain this yet.
An image for bunnies.png is in my issue initial message - find it at the very bottom. I tried downloading it, and it's unchanged in format/size - should work well.
I don't say useRSXformBuffer is invoked more than once per frame. I say that JsiRSXform.set
is repeated in a loop, inside useRSXformBuffer. Every call to JsiRSXform.set
has JSI costs. On a small counts it can be neglected, but on the hundreds of bunnies we have hundreds of calls, which might need to be batched.
Important. As I've already mentioned, I could not confirm that JsiRSXform.set
calls is the only bottleneck. Evidently, it's not.
We might compare react-native-skia architecture to the expo-gl - might get additional information from there.
Let's, maybe get on a call and I'll share my observations in-detail? Which messenger works for you best?
Description
I've implemented a bunnymark demo on top of React native Skia, and I use Atlas for sprite rendering.
It all works perfect on my iPhone 12 mini, and renders 10000 bunnies every frame without any frame drops. Slight frame drops start at 15000, and only become significant after 20-25k bunnies.
However, when running on OPPO A16 (a lower-end Android smartphone), the maximum number of bunnies that can run without frame drops is 300. After thorough debugging I discovered performance throttling happens due to multiple
JsiRSXform.set
calls happening in the same frame. This is basically howuseRSXformBuffer
hook works.So, I'm thinking: shouldn't we batch our transforms buffer updates into one JSI call per frame per Atlas?
I've also tried creating 10000 bunnies, but only animate first 500. I wanted to confirm whether
JsiRSXform.set
calls throttling is the only reason. Unfortunately, this is also slow and animates at around 5 FPS. Presumably, due to the following code inJsiSkCanvas.h
:Version
1.2.3
Steps to reproduce
Run example code provided on a lower-end Android smartphone, under $100-150.
Snack, code example, screenshot, or link to a repository
Here is the code: