Bug 349910

Summary: KWIN doesn't respect _NET_WM_BYPASS_COMPOSITOR application window property
Product: [Frameworks and Libraries] frameworks-kwindowsystem Reporter: dhiru1602 <cvr.dheeraj>
Component: generalAssignee: Martin Flöser <mgraesslin>
Status: RESOLVED FIXED    
Severity: wishlist CC: anakin.cs, commander.alchemy, darkbasic, jeremy9856, kdelibs-bugs, kde_bugzilla_2, thomas.luebking
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
URL: https://git.reviewboard.kde.org/r/126561/
Latest Commit: Version Fixed In: 5.20
Sentry Crash Report:

Description dhiru1602 2015-07-04 19:18:49 UTC
KWIN doesn't seem to disable window composition when the application window sets _NET_WM_BYPASS_COMPOSITOR flag. The freedesktop WM specification http://standards.freedesktop.org/wm-spec/latest/ar01s05.html#idm139870829920368 states that _NET_WM_BYPASS_COMPOSITOR could be set by the client to request uncomposited window. 

There was a patch submitted by "Alexander Mezin" https://git.reviewboard.kde.org/r/110088/ which added support for the before-said window property, however it hasn't been merged yet. 

There are a lot of issues when running games especially Dota 2 which explicitly sets _NET_WM_BYPASS_COMPOSITOR=1, but kwin doesn't seem to respect the setting. This causes drastic drops in framerate and when I switch to another window from the game, kwin often crashes or the nvidia gpu driver starts to misbehave.

More details here: https://github.com/ValveSoftware/Dota-2-Reborn/issues/204

Reproducible: Always

Steps to Reproduce:
1. Enable Desktop Effects in KWIN
2. Start an SDL application or a game which sets _NET_WM_BYPASS_COMPOSITOR
3. Application would run with composition, thereby affecting performance.

Actual Results:  
KWIN handles the composition for the application even when the application window property is set.

Expected Results:  
KWIN should respect _NET_WM_BYPASS_COMPOSITOR and disable composition for that particular window just
Comment 1 Thomas Lübking 2015-07-04 20:52:45 UTC
@dhiru
Simply suspend the compositor for the time being (SHIFT+Alt+F12) - also, because of the legacy nvidia blob, I'd bet the actual problem is in the sync fences.

Please try to run
   KWIN_EXPLICIT_SYNC=0 kwin_x11 --replace &

and test [lol, i thought: that's supposed to be a 2013 title? looks like WC3 - well, seem's it's actually a WC3 mod ;-)] *without* suspending compositing.

---

Dev note:
from the description in this and the linked bug report, suspending the compositor when this flag is set (ie. invoke it for composition blocking) should make most sense - also because
a) driver bugs reg. unredirection (should we ignore the hint for intel IGPs or risk to raise that bug again?)
b) "when I switch to another window" - we'd have to ignore the hint for non-fullscreen windows (I like this sentence: "The compositing manager MAY bypass compositing for both fullscreen and non-fullscreen windows if bypassing is requested, but MUST NOT bypass if it would cause differences from the composited appearance." - let's please never get any explicit and where would you know whether some effect or even the client alters depending on the presence of a compositor - should we ignore the hint if color correction is enabled?? *sigh*)

The setter/getter should imo best go into kwindowsystem / netwininfo (like for the composition blocker hint)?
Comment 2 Thomas Lübking 2015-07-05 06:11:14 UTC
*** Bug 349917 has been marked as a duplicate of this bug. ***
Comment 3 jeremy9856 2015-12-11 13:48:12 UTC
I tested this on Manjaro with Kwin 5.4.3 with MPV-git and I confirm that doesn't work even with "KWIN_EXPLICIT_SYNC=0 kwin_x11 --replace &".

https://github.com/mpv-player/mpv/commit/ad3f75cc94adac9781fda93cc2a7c0c23ac0a606
http://cgit.freedesktop.org/xdg/xdg-specs/tree/wm-spec/wm-spec.xml#n1579
Comment 4 jeremy9856 2016-02-04 11:43:02 UTC
Can the review request be merged now ?

https://git.reviewboard.kde.org/r/126561/
Comment 5 Thomas Lübking 2016-02-16 13:09:07 UTC
Git commit 2a5b7943a020f2154049d28a33216149b6220d53 by Thomas Lübking.
Committed on 16/02/2016 at 13:03.
Pushed by luebking into branch 'master'.

support _NET_WM_BYPASS_COMPOSITOR
FIXED-IN: 5.20

M  +1    -1    src/netwm_def.h
M  +1    -0    src/platforms/xcb/atoms_p.h
M  +26   -4    src/platforms/xcb/netwm.cpp

http://commits.kde.org/kwindowsystem/2a5b7943a020f2154049d28a33216149b6220d53
Comment 6 jeremy9856 2016-02-16 15:55:50 UTC
Thank you !
Comment 7 dhiru1602 2016-02-22 06:51:44 UTC
Thanks Thomas!
Comment 8 AnAkkk 2016-02-22 13:02:45 UTC
Does that mean that is it no longer needed to disable compositing with Valve games?
Comment 9 Thomas Lübking 2016-02-22 16:07:17 UTC
It means that it will automatically be suspended when the game sets this property.
Whether that happens: I've no idea ;-)
(But you check the window with "xprop" for it)
Comment 10 AnAkkk 2016-02-22 17:11:45 UTC
That seem to be set with CS GO indeed. Does it still disable compositing for the window, even if you have an intel card?
Comment 11 Thomas Lübking 2016-02-22 17:17:30 UTC
Yes, this has nothing to do with unredirection - it's virtually like auto-pressing SHIFT+Alt+F12 when the window appears/closes.
Comment 12 dhiru1602 2016-10-19 18:14:16 UTC
(In reply to Thomas Lübking from comment #9)
> It means that it will automatically be suspended when the game sets this
> property.
> Whether that happens: I've no idea ;-)
> (But you check the window with "xprop" for it)

I have had a chance to test this with few games this week. I can confirm that upon starting the game, the compositing is disabled and upon exiting the game, the composition is enabled again. This works as intended and the framerate in the games that I have tested is good. 

However, it would be good if the composition can be enabled back again if the window is minimized. Currently it only gets enabled if the application is completely closed. This makes switching between applications difficult when the game is running in the background.