JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.88k stars 1.15k forks source link

G-SYNC causes stuttering and flickering #1648

Open lars-reimann opened 2 years ago

lars-reimann commented 2 years ago

Problem

When G-SYNC is active and an app that uses Compose MPP is focused, the refresh rate of the display is lowered considerably, so moving the mouse causes stuttering and flickering. While G-SYNC can simply be turned off during development, this also affects end users of an application. For example, this problem also occurs with the new Jetbrains Toolbox.

Video

https://user-images.githubusercontent.com/2501322/147570078-86f3a856-c717-42f3-b933-b0c1119ca829.mp4

Sorry for the terrible phone recording, but funnily the problem disappears when observed by OBS.

Versions

OS: Windows 11 Build 22000.376 Compose: id("org.jetbrains.compose") version "1.0.1" (building a desktop app) NVIDIA driver: 497.29

badmannersteam commented 2 years ago

Hi, any news about this? Compose development and usage of compose apps make my eyes hurt due to flickering :(

The worst thing is that flickering and stuttering occur even when G-SYNC is enabled only for fullscreen apps, not for windowed.

Maybe there is some way to fix it at least for development time, e.g. use another render api/etc? I know that i can disable g-sync completely for specific app in nvidia panel, but it causes the whole screen go black for seconds on every focus gain/loss, so this in not a solution either.

UPD: As a temporary workaround for saving eyes during development SOFTWARE_COMPAT, SOFTWARE or OPENGL renderer can be used instead of DIRECT3D, that causes the flickering. Renderer can be set via environment variable SKIKO_RENDER_API or system propety skiko.renderApi. So System.setProperty("skiko.renderApi", "OPENGL") in main() should be enough.

drakeet commented 2 years ago

This is indeed a common and serious problem with the JVM GUI and hopefully it will be resolved.

terryschmidt commented 1 year ago

This is horrendous what is going on with this I bought a gaming computer with the fastest CPU and GPU available on the market and this grinds my computer to a halt randomly and it took me months on end to stumble on to this

terryschmidt commented 1 year ago

Hi, any news about this? Compose development and usage of compose apps make my eyes hurt due to flickering :(

The worst thing is that flickering and stuttering occur even when G-SYNC is enabled only for fullscreen apps, not for windowed.

Maybe there is some way to fix it at least for development time, e.g. use another render api/etc? I know that i can disable g-sync completely for specific app in nvidia panel, but it causes the whole screen go black for seconds on every focus gain/loss, so this in not a solution either.

UPD: As a temporary workaround for saving eyes during development SOFTWARE_COMPAT, SOFTWARE or OPENGL renderer can be used instead of DIRECT3D, that causes the flickering. Renderer can be set via environment variable SKIKO_RENDER_API or system propety skiko.renderApi. So System.setProperty("skiko.renderApi", "OPENGL") in main() should be enough.

This is also correct in my experience. The bug happens even if you only tell GSYNC to activate for full screen apps and Jetbrains Toolbox is not a full screen app

malliaridis commented 3 months ago

I can confirm the issue with Compose 1.6.10-beta02 and Kotlin 1.9.22. However, the entire screen is flickering only when I hover over buttons. Disabling G-Sync also fixes the issue, but that is only a temporary solution for development.

The issue is present in the toolbox too, but not during the first window opening when it is manually started. Only if I minimize it to the tray and reopen it. Hope this information is useful for fixing it.

Additionally, marking the window as undecorated and transparent seems to fix the issue too.

okushnikov commented 1 month ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.