-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First frame renders transparent canvas #2968
Comments
Thank you for this. I'm definitely interesting to have an example where I can reproduce the issue and also see the suggested fix. Thank you for looking into this. |
Hey @wcandillon, here is a simple snack demonstrating the issue. A canvas with lime background is rendering a blue circle (which covers the whole canvas) after 1s delay. If you run it on device, you can notice a lime flash which should not be there (as there are just two states: canvas not shown completely and canvas is shown with a blue circle) – or just record the screen and inspect the video frame by frame. I will prepare a PR today or tomorrow. P.S. Love your videos on RN skia, great job! |
Thank you for the clear reproduction. I was able to fix the issue with this change: #2991 Can you confirm it on your side? |
I am afraid I have tried that and it doesn't seem to be enough. I have pushed an example app to my fork into As far as I understand the issue, it is caused by 2 elements: populating the root with the delay and the native part not rasterizing the canvas on time. The first part can be addressed by either my patch (populating the root right after the construction) or by yours (using P.S. It's quite easy to miss, so I normally record the video and then scrub through around the switch to see if there's a lime frame. |
Ok it looks like even my changes are not enough: I have changed the example to continiously show and hide the canvas, and I do see lime flashes crippling through. I will post an update here once I figure out what is missing. |
I am doing a bit more testing now and indeed, switch to
useLayoutEffect does improve the first time to frame but it still
looks it could be faster.
…On Mon, Mar 3, 2025 at 6:15 PM Anton Zhuravsky ***@***.***> wrote:
Ok it looks like even my changes are not enough: I have changed the example to continiously show and hide the canvas, and I do see lime flashes crippling through. I will post an update here once I figure out what is missing.
—
Reply to this email directly, view it on GitHub or unsubscribe.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
🎉 This issue has been resolved in version 1.11.10 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Shall we re-open this? |
yes correct |
Description
Our app uses a Skia's canvas as a background for the home screen, and the first render always comes through transparent, although there are elements to be rendered.
We have debugged the issue and believe there are 2 places that cause this behaviour:
Canvas
component supplyingchildren
collection inuseEffect
and missingwaitUntilCompleted
call tocommandBuffer
inMetalWindowContext
class.We have attempted to fix it on our end by adding
root.render(children)
to the memoized creation ofSkiaSGRoot
insideCanvas
component and added abool
flag topresent()
method to enforce command buffer completion when immediate draw is requested (e.g. fromdrawRect
of the view).We are happy to open a PR with these fixes, but figured it's a good idea to create a bug first and get a confirmation that it is a real issue and our solution is worth submitting.
React Native Skia Version
1.11.1
React Native Version
0.76.6
Using New Architecture
Steps to Reproduce
Snack, Code Example, Screenshot, or Link to Repository
Please have a look at two recordings from iOS Simulator (iPhone 16 Pro, iOS 18.1) where a screen with Canvas as a background opens (following a white flash). In both cases, the Canvas's style set to
[StyleSheet.absoluteFill, {backgroundColor: "lime"}]
and the first video shows a green flash, which is not present in the second video.Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-02-18.at.17.11.45.mp4
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-02-18.at.17.11.59.mp4
The text was updated successfully, but these errors were encountered: