Bug 361091

Summary: Translucency lost when starting video using mpv bypassing the compositor
Product: [Plasma] kwin Reporter: Bernd Steinhauser <linux>
Component: effects-variousAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED INTENTIONAL    
Severity: normal CC: akhilesh, bob.mt.wya, imy51, marcodv, mtmkls, tempestempire
Priority: NOR    
Version: 5.6.0   
Target Milestone: ---   
Platform: Exherbo   
OS: Linux   
Latest Commit: Version Fixed In:

Description Bernd Steinhauser 2016-03-28 13:12:53 UTC
Tried with OpenGL 2.0 and 3.1, XRender, EGL, GLX, all the same.
Transparancy comes back when mpv exits or when the compositor is restarted or the backand is changed.

It seems like it only happens when x11-bypass-compositor is enabled, which is explained as:
"If set to yes (default), then ask the compositor to unredirect the mpv window. This uses the _NET_WM_BYPASS_COMPOSITOR hint."
Thus, I've not seen it with other players like vlc, firefox html5 video or ffplay, which don't seem to make use of that hint.
It could also be a bug in mpv.

Reproducible: Always

Steps to Reproduce:
1. Enable the Translucency effect, ensure it works 
2. Start a movie using mpv. Video output does not matter (tested xv, x11, vdpau and opengl)
3. Check if Translucency works
4. Quit mpv
5. Check if Translucency works
Comment 1 Thomas Lübking 2016-03-28 14:15:53 UTC
_NET_WM_BYPASS_COMPOSITOR isn't specified for unredirection (leaving aside that the specification is horrible in every aspect...)

This happens because of https://git.reviewboard.kde.org/r/126561/

The behavior is intended (whether or not and when or not media players should set that hint is a matter of its own)
Also compare bug #349910

You can still use window rules to override the hint (force composite blocking to false) if mpv doesn't provide a setting for this.
Comment 2 rphl 2016-03-28 22:50:34 UTC
_NET_WM_BYPASS_COMPOSITOR hint that got support in plasma 5.6 by kwin breaks a lot of user apps like this https://github.com/mpv-player/mpv/issues/2997 Plus if I try to turn on\off effects while app is still running window decorations break and I have graphical artifacts around window which persist until kwin is restarted.

Also there is currently no control over this feature as it tottaly ignores "Suspend compositor for full screen windows" option in compositor's settings.
Comment 3 Thomas Lübking 2016-03-28 23:38:35 UTC
The control is "kcmshell5 kwinrules", add a rule to not block compositing for the window.

You can add a general rule (matching all windows), but if a window signals "The compositor is a problem for me", we'll turn it off (which is btw. the only way to half-wise comply with the silly specification of this hint except for completely ignoring it)

> totaly ignores "Suspend compositor for full screen windows"
Leaving aside that the property aims for exactly that (overriding a general behavior here), KWin doesn't operate by unredirection here since it hardly frees any resources (ie. you could just as much kick the property entirely) and unredirection is fragile (thus still completely disabled on intel chips)

> window decorations break and I have graphical artifacts
Unrelated issue; what suspends the compositor doesn't matter.
Please file a bug and attach the output of "qdbus org.kde.KWin /KWin supportInformation" there.
Comment 4 Bob Wya 2016-03-29 16:25:50 UTC
(In reply to rphl from comment #2)
> _NET_WM_BYPASS_COMPOSITOR hint that got support in plasma 5.6 by kwin breaks
> a lot of user apps like this https://github.com/mpv-player/mpv/issues/2997
> Plus if I try to turn on\off effects while app is still running window
> decorations break and I have graphical artifacts around window which persist
> until kwin is restarted.

@rphl,

I'm also seeing this issue.. Launching a (native) Steam game and returning to the desktop leaves all the Window decorations broken... A large black border replaces the shadow region. All applications are affected.

@Thomas,

I've rebuild all my (Gentoo) Plasma packages with debug info enabled... So I guess I will (now) be able to supply more useful info...

Do you want:
  qdbus org.kde.KWin /KWin supportInformation
from before / after window breakage - or both?

I can confirm that it was only my move from Plasma 5.5.5 to 5.6.0 that caused this breakage... All other packages were held at a fixed version.

Restarting Plasmashell or turning compositing off & on doesn't clear the issue.
Comment 5 Thomas Lübking 2016-03-29 16:31:46 UTC
(In reply to Bob Wya from comment #4)

>   qdbus org.kde.KWin /KWin supportInformation
> from before / after window breakage - or both?

Anytime. It also doesn't require debug options - I mostly want to see whether it's the breeze deco or some aurorae theme and which GPU/driver combo you use.
 
> Restarting Plasmashell or turning compositing off & on doesn't clear the
> issue.
The plasmashell process is unrelated, would be kwin_x11.
Does resizing a window "fix" the deco content?

And please open a new bug about this - this one here is *very* prone to be closed as "invalid" anytime soon (the hint is supposed to have such or similar effect)
Comment 6 Bob Wya 2016-03-29 17:17:08 UTC
(In reply to Thomas Lübking from comment #5)
> And please open a new bug about this - this one here is *very* prone to be
> closed as "invalid" anytime soon (the hint is supposed to have such or
> similar effect)

Okey dokey...
https://bugs.kde.org/show_bug.cgi?id=361154
Comment 7 Bernd Steinhauser 2016-03-29 19:08:23 UTC
(In reply to Thomas Lübking from comment #1)
> _NET_WM_BYPASS_COMPOSITOR isn't specified for unredirection (leaving aside
> that the specification is horrible in every aspect...)
> 
> This happens because of https://git.reviewboard.kde.org/r/126561/
> 
> The behavior is intended (whether or not and when or not media players
> should set that hint is a matter of its own)
> Also compare bug #349910
Thanks for the explanation. To  me that sounds very weird, but understandable. I'm not sure that bypassing the compositor here is a good idea, despite the explanation by wm4 regarding mpv.
 
> You can still use window rules to override the hint (force composite
> blocking to false) if mpv doesn't provide a setting for this.
mpv does have a setting as described above. It defaults to bypassing the compositor since a few months.
Comment 8 Thomas Lübking 2016-03-29 21:07:22 UTC
The problem with the hint is:
"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."

This can never be guaranteed - an unredirected window shapes away the compositor scene and as result will nearby inevitably impact the result (even for fullscreen windows, some effect - like be::clock ;-) - might simply paint onto the final scene) - that impact not generally detectable.
So basically the hint is to be ignored... m(

Also, if there was considerable benefit in pure unredirection *and* you could guarantee that this does not impact the outcome, hell just unredirect the window - why look at a property hint itfp?


So we put the focus on:
"window would benefit from running uncomposited [...] or that the window might be hurt from being uncomposited" which is the reasonable part and also intended by _KDE_NET_WM_BLOCK_COMPOSITING

The point is that a heavy GL game errr.... CAD studio!, windowed or fullscreen, will largely benefit from being the only (ok, that one's lost...) active GL context around, notably if you're short on texture RAM.
Comment 9 Thomas Lübking 2016-03-30 17:14:04 UTC
*** Bug 361188 has been marked as a duplicate of this bug. ***
Comment 10 Bernd Steinhauser 2016-03-30 17:32:11 UTC
Maybe that will be a bit out of reach of this bug, but would the situation be better on wayland, especially when talking about video (i.e. mpv)?
Comment 11 Thomas Lübking 2016-03-30 17:37:56 UTC
There's nothing such as "unredirection" on wayland nor is it designed to be non-compositing.
Whether that's better or worse depends on the problems you face ;-)
Comment 12 Martin Flöser 2016-04-01 13:34:17 UTC
(In reply to Bernd Steinhauser from comment #10)
> Maybe that will be a bit out of reach of this bug, but would the situation
> be better on wayland, especially when talking about video (i.e. mpv)?

on Wayland the situation can be better as we can bypass the rendering by presenting the windows buffer directly on the DRM device. That's not implemented, yet. Means once Phoronix starts to do it's benchmarks the results will be worse :-P

Concerning the bug in question: KWin does what it's asked for. Thus it's not a bug and there is a window rule to workaround the behavior.
Comment 13 tempestempire 2016-04-01 21:18:06 UTC
(In reply to Bernd Steinhauser from comment #7)
> (In reply to Thomas Lübking from comment #1)
> > _NET_WM_BYPASS_COMPOSITOR isn't specified for unredirection (leaving aside
> > that the specification is horrible in every aspect...)
> > 
> > This happens because of https://git.reviewboard.kde.org/r/126561/
> > 
> > The behavior is intended (whether or not and when or not media players
> > should set that hint is a matter of its own)
> > Also compare bug #349910
> Thanks for the explanation. To  me that sounds very weird, but
> understandable. I'm not sure that bypassing the compositor here is a good
> idea, despite the explanation by wm4 regarding mpv.
>  
> > You can still use window rules to override the hint (force composite
> > blocking to false) if mpv doesn't provide a setting for this.
> mpv does have a setting as described above. It defaults to bypassing the
> compositor since a few months.

Just wanted to add that the setting to add to mpv.conf to prevent this behavior is:
x11-bypass-compositor=no
Comment 14 Martin Flöser 2016-04-04 06:07:30 UTC
*** Bug 361335 has been marked as a duplicate of this bug. ***
Comment 15 Thomas Lübking 2016-06-12 14:09:30 UTC
*** Bug 364240 has been marked as a duplicate of this bug. ***
Comment 16 miklos 2016-10-15 13:51:02 UTC
How can I reopen this?

Using a hint supplied by the application is clearly wrong, because application developers can't be bothered to set window properties correctly. It's especially weird that KWin developers insist on using obscure window hints here, and at the same time they lament in their blog about applications incorrectly setting their window type: https://blog.martin-graesslin.com/blog/2016/07/multi-screen-woes-in-plasma-5-7/

Some examples to illustrate the problem: Portal and GMod don't set set the block compositor hint, but Scummvm does. It should be the opposite. ETQW doesn't allow alt-tab, so I don't know if it disables the compositor (I guess it doesn't). Moreover, when a game is running, but it's minimized, then it doesn't draw anything, so it shouldn't affect the compositor, but as long as that window exists, the compositor is turned off.

I don't understand why the good old "if fullscreen window: turn off compositor" logic had to be replaced with this mess.