react-native-skia icon indicating copy to clipboard operation
react-native-skia copied to clipboard

Making first frame render synchronous

Open yard opened this issue 9 months ago • 5 comments

This PR aims to address the issue described in https://github.com/Shopify/react-native-skia/issues/2968.

Summary of changes

  1. <Canvas /> component populates SkiaSGRoot instance with the children elements so that it has content from the get-go instead of letting the first render to come through and appending children in an effect
  2. WindowContexts present() method has been extended with a boolean flush argument instructing the context to render the image immediately (i.e. perform a synchronous presentation)
  3. Corresponding implementations (iOS, Android) have been amended to take flush argument into account.

Disclaimer: I am by no means an expert in the inner workings of Skia's renderers and did the change using (my very own) common sense and testing locally; happy to adhere to changes to provide a better implementation, shall there be an oversight in this changeset.

yard avatar Mar 02 '25 18:03 yard

I have signed the CLA!

yard avatar Mar 02 '25 18:03 yard

looks very nice :)

wcandillon avatar Mar 02 '25 18:03 wcandillon

Could you provide me some small examples that would help me experience the issue described in #2968? This would allow me to review this more easily but overall this looks very good 👍

wcandillon avatar Mar 02 '25 18:03 wcandillon

Could you provide me some small examples that would help me experience the issue described in #2968? This would allow me to review this more easily but overall this looks very good 👍

Sure thing. The snack (https://snack.expo.dev/@anton9001/react-native-skia-error-app) in the original issue is a one-component example that exhibits the problem; I can as well create a separate branch in my fork to demonstrate that if that's easier? Lmk what's the easiest for you.

yard avatar Mar 02 '25 18:03 yard

let me know if #2991 fixes fixes #2968

wcandillon avatar Mar 03 '25 10:03 wcandillon

@yard I am now working on fixing time to first frame on iOS and Android. The way I do it is to first remove the reconciler out of the equation, have a very fast time to first frame and then add the reconciler back into the equation (I have some ideas of what we could do there).

Now I am looking back at this diff and it's going into a different direction than what I am currently doing. Could you tell me more about these specific fixes? I will test them again.

wcandillon avatar Nov 07 '25 10:11 wcandillon