Bug 485884 - With an offscreen effect enabled, opening a window without frame sometimes causes a flickering black screen on Wayland
Summary: With an offscreen effect enabled, opening a window without frame sometimes ca...
Status: REOPENED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: 6.0.4
Platform: NixOS Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland-only
Depends on:
Blocks:
 
Reported: 2024-04-21 10:13 UTC by Marcin Woźniak
Modified: 2025-05-14 19:15 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.3.6
Sentry Crash Report:


Attachments
The output of "qdbus org.kde.KWin /KWin org.kde.KWin.supportInformation" (6.57 KB, text/plain)
2024-04-21 10:13 UTC, Marcin Woźniak
Details
A video of the issue occurring when opening Cryptomator (3.58 MB, video/mp4)
2024-04-21 10:16 UTC, Marcin Woźniak
Details
A video of the issue occurring when using GIMP (3.47 MB, video/mp4)
2024-04-21 10:19 UTC, Marcin Woźniak
Details
Same problem when exitting games (2.88 MB, video/mp4)
2024-06-29 13:44 UTC, Oleg
Details
Quake3e with WAYLAND_DEBUG (784.73 KB, text/x-log)
2025-05-05 19:46 UTC, Oleg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin Woźniak 2024-04-21 10:13:30 UTC
Created attachment 168736 [details]
The output of "qdbus org.kde.KWin /KWin org.kde.KWin.supportInformation"

SUMMARY
When window decorations are disabled, a window's expanded geometry can be 0 for a very short period of time after being opened. Frame geometry seems to always have a correct value.

When an offscreen effect is active, KWin attempts to allocate a 0 by 0 texture in OffscreenData::maybeRender, which fails, but KWin uses that texture anyways. This results in the entire screen turning black with the following messages being logged in the journal:
kwi 21 10:35:49 thinkpad kwin_wayland[1628]: kf.windowsystem: static bool KX11Extras::mapViewport() may only be used on X11
kwi 21 10:35:49 thinkpad kwin_wayland[1628]: kwin_scene_opengl: 0x2: GL_INVALID_VALUE in glTexStorage2D(width, height or depth < 1)
kwi 21 10:35:49 thinkpad kwin_wayland[1628]: kwin_scene_opengl: Invalid framebuffer status:  "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"
kwi 21 10:35:49 thinkpad kwin_wayland[1628]: kwin_scene_opengl: Can't enable invalid framebuffer object!

This issue only occurs on Wayland. I found two programs it can reliably reproduced with:
- Cryptomator (1.12.4)
- GIMP (2.10.36)

It doesn't seem to occur with Qt or other GTK applications.

STEPS TO REPRODUCE
1. Create a window rule that disables the titlebar and frame
2. Enable an offscreen effect, such as colorblindness correction
3. Open GIMP (sometimes this alone can cause the bug)
4. Repeatedly open and close a dialog by pressing CTRL+N and ESC. If the issue does not occur after a few attempts, restart GIMP and try again.

OBSERVED RESULT
The entire screen turns black and flickers until repainted.

EXPECTED RESULT
The screen shouldn't turn black.

SOFTWARE/OS VERSIONS
Linux: NixOS 24.05, Linux 6.8.7
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0

ADDITIONAL INFORMATION
I've attached videos of the issue occurring with GIMP and Cryptomator along with the output of "qdbus org.kde.KWin /KWin org.kde.KWin.supportInformation".
Comment 1 Marcin Woźniak 2024-04-21 10:16:07 UTC
Created attachment 168737 [details]
A video of the issue occurring when opening Cryptomator
Comment 2 Marcin Woźniak 2024-04-21 10:19:16 UTC
Created attachment 168738 [details]
A video of the issue occurring when using GIMP
Comment 3 Oleg 2024-06-24 20:47:34 UTC
I can confirm this issue. I experience this while exiting native Wayland OpenGL games.
Operating System: Arch Linux 
KDE Plasma Version: 6.1.0
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.1
Kernel Version: 6.9.6-2-cachyos (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-7700K CPU @ 4.20GHz
Memory: 15.6 ГиБ of RAM
Graphics Processor: AMD Radeon RX 6700 XT

июн 24 23:42:51 oleg-pc kwin_wayland[47517]: <Unknown File>:97: TypeError: Cannot read property 'translucencyWindowTypeAnimation' of undefined
июн 24 23:43:07 oleg-pc kwin_wayland[47517]: kwin_scene_opengl: 0x2: GL_INVALID_VALUE in glTexStorage2D(width, height or depth < 1)
июн 24 23:43:07 oleg-pc kwin_wayland[47517]: kwin_scene_opengl: Invalid framebuffer status:  "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"
июн 24 23:43:07 oleg-pc kwin_wayland[47517]: kwin_scene_opengl: 0x2: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
июн 24 23:43:07 oleg-pc kwin_wayland[47517]: kwin_scene_opengl: 0x2: GL_INVALID_VALUE in glTexStorage2D(width, height or depth < 1)
июн 24 23:43:07 oleg-pc kwin_wayland[47517]: kwin_scene_opengl: 0x2: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
июн 24 23:43:07 oleg-pc kwin_wayland[47517]: kwin_scene_opengl: Invalid framebuffer status:  "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"
июн 24 23:43:07 oleg-pc kwin_wayland[47517]: kwin_scene_opengl: 0x2: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
июн 24 23:43:07 oleg-pc kwin_wayland[47517]: kwin_scene_opengl: 0x2: GL_INVALID_FRAMEBUFFER_OPERATION in glClear(incomplete framebuffer)
июн 24 23:43:07 oleg-pc kwin_wayland[47517]: kwin_scene_opengl: 0x2: GL_INVALID_FRAMEBUFFER_OPERATION in glDrawArrays
июн 24 23:43:07 oleg-pc kwin_wayland[47517]: kwin_scene_opengl: 0x2: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
июн 24 23:43:07 oleg-pc kwin_wayland[47517]: kwin_scene_opengl: 0x2: GL_INVALID_FRAMEBUFFER_OPERATION in glDrawArrays
Comment 4 Oleg 2024-06-29 13:44:40 UTC
Created attachment 171178 [details]
Same problem when exitting games
Comment 5 Oleg 2024-11-28 16:55:08 UTC
Issue is still relevant

Operating System: Arch Linux 
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.12.1-2-cachyos (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-7700K CPU @ 4.20GHz
Memory: 15.6 ГиБ of RAM
Graphics Processor: AMD Radeon RX 6700 XT
Comment 6 Oleg 2025-02-12 19:45:21 UTC
Still happens

Operating System: Arch Linux 
KDE Plasma Version: 6.3.0
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.2
Kernel Version: 6.13.2-2-cachyos (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 9800X3D 8-Core Processor
Memory: 62.5 ГиБ of RAM
Graphics Processor: AMD Radeon RX 6700 XT
Manufacturer: ASUS
Comment 7 Oleg 2025-02-23 05:59:49 UTC
For me, this mostly happens with SDL applications using Wayland backend (games, scrcpy) when they shutdown.
Comment 8 Oleg 2025-03-03 17:24:49 UTC
As of kwin 6.3.2 and SDL 3.2.6 I can no longer experience this. Marcin, can you confirm?
Comment 9 Oleg 2025-03-08 17:14:52 UTC
Nevermind, it's still happening
Comment 10 v0 2025-04-14 10:05:17 UTC
i just got this as well
i had the built in Slide animation enabled which apparently doesn't check for .expandedGeometry().isValid()
Comment 11 v0 2025-04-14 10:11:28 UTC
sorry, it's the "Glide" effect
Comment 12 Bug Janitor Service 2025-05-05 17:28:11 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/7589
Comment 13 Oleg 2025-05-05 18:20:54 UTC
I can confirm MR 7589 fixes the issue!
Comment 14 Zamundaaa 2025-05-05 19:23:31 UTC
(In reply to Oleg from comment #3)
> I can confirm this issue. I experience this while exiting native Wayland
> OpenGL games.
Can you run the game with WAYLAND_DEBUG=1 please, and attach the output of that here?
While the MR fixes the effect (and is valid on its own), there shouldn't be any (Wayland) windows that have a visible size of zero. It would be good if we can figure out the underlying issue of that too.
Comment 15 Oleg 2025-05-05 19:46:29 UTC
Created attachment 180964 [details]
Quake3e with WAYLAND_DEBUG

(In reply to Zamundaaa from comment #14)
> Can you run the game with WAYLAND_DEBUG=1 please, and attach the output of
> that here?
> While the MR fixes the effect (and is valid on its own), there shouldn't be
> any (Wayland) windows that have a visible size of zero. It would be good if
> we can figure out the underlying issue of that too.

Yes, here
Comment 16 Zamundaaa 2025-05-06 10:28:20 UTC
Git commit 91c2389a78fdd56b69537092bc5ddac2e11ad03c by Xaver Hugl.
Committed on 06/05/2025 at 10:18.
Pushed by zamundaaa into branch 'master'.

effect/offscreeneffect: guard against allocating zero-size textures

This also fixes a potential crash during a GPU reset (when allocating the texture
fails)

M  +8    -0    src/effect/offscreeneffect.cpp

https://invent.kde.org/plasma/kwin/-/commit/91c2389a78fdd56b69537092bc5ddac2e11ad03c
Comment 17 Zamundaaa 2025-05-06 11:19:58 UTC
(In reply to Oleg from comment #15)
> Created attachment 180964 [details]
> Quake3e with WAYLAND_DEBUG
> 
> (In reply to Zamundaaa from comment #14)
> > Can you run the game with WAYLAND_DEBUG=1 please, and attach the output of
> > that here?
> > While the MR fixes the effect (and is valid on its own), there shouldn't be
> > any (Wayland) windows that have a visible size of zero. It would be good if
> > we can figure out the underlying issue of that too.
> 
> Yes, here
Thanks!
Comment 18 Zamundaaa 2025-05-06 11:30:34 UTC
Git commit 7da2894b2e431461c78d124a03480b189457d048 by Xaver Hugl.
Committed on 06/05/2025 at 11:12.
Pushed by zamundaaa into branch 'Plasma/6.3'.

effect/offscreeneffect: guard against allocating zero-size textures

This also fixes a potential crash during a GPU reset (when allocating the texture
fails)


(cherry picked from commit 91c2389a78fdd56b69537092bc5ddac2e11ad03c)

Co-authored-by: Xaver Hugl <xaver.hugl@gmail.com>

M  +8    -0    src/effect/offscreeneffect.cpp

https://invent.kde.org/plasma/kwin/-/commit/7da2894b2e431461c78d124a03480b189457d048
Comment 19 v0 2025-05-06 11:46:42 UTC
can someone check if chromium windows still have a size of 0x0 with the new code?
Comment 20 Zamundaaa 2025-05-06 12:05:20 UTC
That commit doesn't change the visible size of effect windows, it just removes the problematic consequences of it.
Comment 21 v0 2025-05-06 12:31:22 UTC
oh yeah i was wondering if the MR would address this too 
> there shouldn't be any (Wayland) windows that have a visible size of zero.
..but couldn't see it. 
i'll test this when i am back at my machine too.  plasma's default glide effect + closing any chromium browser used to result in crazy black flickering
Comment 22 Oleg 2025-05-14 19:15:25 UTC
Although it was fixed for most apps like SDL based I can still experience this on Plasma 6.3.5 with gamescope Wayland backend
<pre>
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_VALUE in glTexStorage2D(invalid width, height or depth)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: Invalid framebuffer status:  "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_VALUE in glTexStorage2D(invalid width, height or depth)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: Invalid framebuffer status:  "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
14.05.2025 22:11	kwin_wayland	kwin_scene_opengl: 0x4: GL_INVALID_OPERATION in glBindFramebuffer(non-gen name)
</pre>