-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Window flashes with default background color when shown initially #1794
Window flashes with default background color when shown initially #1794
Comments
Running into the same issue, on macOS you can indeed fix it using the It appears that the window is shown before the Compose UI code, which seems unexpected to me. Maybe the window should be hidden until the first frame? |
Fixes JetBrains/compose-multiplatform#1794 If the first frame is too long to draw (> 500ms), users should make their apps asynchronous and draw UI gradully in multiple frames without blocking the UI thread for too long in single frame
In 1.1.0 we draw the first frame offscreen. If the application has too long start after this change, we can measure the first frame, and move the heavy logic to background or to the next frames. We can measure the first frame with this snippet:
|
Fixes JetBrains/compose-multiplatform#1794 Fixes JetBrains/compose-multiplatform#1652 If the first frame is too long to draw (> 500ms), users should make their apps asynchronous and draw UI gradually in multiple frames without blocking the UI thread for too long in single frame. Change-Id: I3f01c963478bf23ee75e4adeb45a172b25591073 Test: ./gradlew jvmTest desktopTest -Pandroidx.compose.multiplatformEnabled=true
Fixes JetBrains/compose-multiplatform#1794 If the first frame is too long to draw (> 500ms), users should make their apps asynchronous and draw UI gradully in multiple frames without blocking the UI thread for too long in single frame # Conflicts: # compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/window/TestUtils.kt # compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/window/dialog/DialogTest.kt # compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/window/window/WindowTest.kt
Looks like we have a regression here. This happens maybe 25% of the times the app is launched:
Screen.Recording.2023-02-07.at.9.30.20.mp4Compose 1.3.0 |
The problem seems to be in Skiko, not Compose. |
Actually, maybe not. The reproducer I was trying to get in Skiko was doing it wrong. |
Ok, the culprit here is I'm guessing that it happens because it requires an extra layout pass to determine the composition size, so the window is drawn before the composition is drawn at its final size. |
To avoid flickering, we draw the first frame before isVisible = true. When we don't specify the size, we call Maybe we do it after we draw the first frame. In this case, the fix will be to move calling |
I figured out why it's happening... |
Note that the problem still exists when opening a |
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks. |
On Mac OS X (haven't checked other platforms), the simplest application showing a window filled with some color will flash the default background color for a split second. This is unnoticeable with a light theme, but is very annoying with a dark theme.
window.flash.mp4
This happens because
JFrame
sets its background inframeInit
toUIManager.getColor("control")
.Even setting
inside the
singleWindowApplication
content doesn't help because it seems the window has drawn itself by the time it's called.What does help is calling
before the call to
singleWindowApplication
.The text was updated successfully, but these errors were encountered: