Bug 349910 - KWIN doesn't respect _NET_WM_BYPASS_COMPOSITOR application window property
Summary: KWIN doesn't respect _NET_WM_BYPASS_COMPOSITOR application window property
Alias: None
Product: frameworks-kwindowsystem
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Martin Flöser
URL: https://git.reviewboard.kde.org/r/126...
: 349917 (view as bug list)
Depends on:
Reported: 2015-07-04 19:18 UTC by dhiru1602
Modified: 2016-10-19 18:14 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.20


Note You need to log in before you can comment on or make changes to this bug.
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
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 &".

Comment 4 jeremy9856 2016-02-04 11:43:02 UTC
Can the review request be merged now ?

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'.

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

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.