Making first frame render synchronous
This PR aims to address the issue described in https://github.com/Shopify/react-native-skia/issues/2968.
Summary of changes
<Canvas />component populatesSkiaSGRootinstance 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 effectWindowContextspresent()method has been extended with a booleanflushargument instructing the context to render the image immediately (i.e. perform a synchronous presentation)- Corresponding implementations (iOS, Android) have been amended to take
flushargument 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.
I have signed the CLA!
looks very nice :)
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 👍
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.
let me know if #2991 fixes fixes #2968
@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.