Bug 344319 - Suspend desktop effects for fullscreen windows does not work in Plasma5 (Intel Haswell)
Summary: Suspend desktop effects for fullscreen windows does not work in Plasma5 (Inte...
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: glx (show other bugs)
Version: 5.2.0.1
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 355081 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-02-18 14:17 UTC by attila.jakosa
Modified: 2016-05-30 20:54 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
kwin rule for kodi to block compositing (237 bytes, text/plain)
2015-02-18 16:57 UTC, Thomas Lübking
Details

Note You need to log in before you can comment on or make changes to this bug.
Description attila.jakosa 2015-02-18 14:17:32 UTC
Suspend desktop effects for fullscreen windows does not work in Plasma5 for Intel Haswell Iris Pro graphics.

This was working in Plasma4. I can manually suspend compositor with ALT+SHIFT+F12 and can re-enable it any time with no problem, but it does not do it automatically. If I tick to enable this option, the next time I go into the settings, it is already turned off by itself.

Environment: 
Hardware: Macbook pro Retina.
OS: Kubuntu Vivid Daily image
Renderer: GLX
Opengl: 2.1
Tried application: Kodi Media Center (formerly XBMC)

Please let me know if you need any more debug info.

Reproducible: Always

Steps to Reproduce:
1. Enable Suspend Desktop effects for fullscreen windows
2. Run Kodi (or any other fullscreen application)
3. Check if it is running in full screen
4. Go back to settings and check that the setting has not persist.

Actual Results:  
Desktop effects are not suspended even having Kodi running full screen.
Comment 1 Martin Flöser 2015-02-18 14:39:56 UTC
suspend desktop effects for fullscreen windows is not supported on Intel hardware, neither was it on KDE4.
Comment 2 attila.jakosa 2015-02-18 15:33:30 UTC
Hi Martin !

Thanks for the info. 
Just a question: what happens when I press ALT +SHIFT +F12, run the program and press it again. Can this be automated ?

Isn't kwin suspending the desktop effects with this key combination ?

I see a more fluid gui (like if I am running Kodi in standalone without any window manager) when I press this key combo. Power consumption is nearly the same, only ca. 10-13% less this time.

BTW, I love plasma5 and I am amazed how energy efficient the whole environment.
Comment 3 Martin Flöser 2015-02-18 15:39:40 UTC
> Just a question: what happens when I press ALT +SHIFT +F12, run the program and press it again. Can this be automated ?

sure. Applications can set an X11 property (_KDE_NET_WM_BLOCK_COMPOSITING) to do this (e.g. you could ask kodi devs to add support for it). And we offer window specific rules for it.

> Isn't kwin suspending the desktop effects with this key combination ?

It's different. The shortcut and the blocking "disable" compositing completely by e.g. tearing down the OpenGL context. While the "unredirect fullscreen" does not disable, but just skips it from compositing.
Comment 4 Thomas Lübking 2015-02-18 16:57:36 UTC
Created attachment 91157 [details]
kwin rule for kodi to block compositing
Comment 5 attila.jakosa 2015-02-18 17:08:08 UTC
Thanks Thomas :-)
You guys rock !
Comment 6 attila.jakosa 2015-02-18 20:11:27 UTC
Tried the rule and works really well. Just one more question: isn't it possible to disable compositing for only in the full screen state of the specific window ? So at minimized or just windowed state compositing would come back ?

Thanks for all the patience and help :-)
Comment 7 Thomas Lübking 2015-02-18 20:13:16 UTC
in principal - I don't recall whether I added xbmc to the default list, but that's now kodi anyway ;-)
Comment 8 attila.jakosa 2015-02-18 20:27:05 UTC
(In reply to Thomas Lübking from comment #7)
> in principal - I don't recall whether I added xbmc to the default list, but
> that's now kodi anyway ;-)

Sorry, but I don't understand. Can I apply any rule for only the maximized state of the window ?
Comment 9 Thomas Lübking 2015-02-18 20:53:22 UTC
Me is very ssupid, sorry - forgot to link PoC ;-)

http://kde-look.org/content/show.php/GameMode?content=156659
Comment 10 attila.jakosa 2015-02-18 22:06:13 UTC
Thanks, tried to install with this command
plasmapkg -t kwinscript5 -i ./156659-gamemode.kwinscript 

It created the files here:
.kde/share/apps/kwin/scripts/gamemode/contents/code/main.js

But it does not appear among the kwin scripts on the settings panel. So I cannot enable it.
Any idea ?
Comment 11 Thomas Lübking 2015-02-18 23:18:55 UTC
(In reply to attila.jakosa from comment #10)
> Thanks, tried to install with this command
> plasmapkg -t kwinscript5 -i ./156659-gamemode.kwinscript 

that should likely be "plasmapkg2" for KDE5 - the correct target location would then be
~/.local/share/kwin/scripts

plasmapkg2 -t kwinscript -i ./156659-gamemode.kwinscript
Comment 12 attila.jakosa 2015-02-22 06:53:01 UTC
Thomas, thanks for all the help and sorry to bother you with this again, but still no luck with the gamemode script. Now it is enabled, but still no luck. With vlc it works, but not with kodi. I tried all possible strings "kodi", "Kodi", "kodi.bin" etc. 
I even tried the things described in this thread: http://kde-look.org/content/show.php/GameMode?content=156659

I checked if kodi is supporting the _NET_WM_STATE_FULLSCREEN property and it does here:
https://github.com/xbmc/xbmc/blob/master/xbmc/windowing/X11/WinSystemX11.cpp#L1124

I tried to insert a line to set the _KDE_NET_WM_BLOCK_COMPOSITING property like this:

    if (fullscreen && hasWM)
    {
      printf("FULLSREEN HIT\n");
      Atom fs = XInternAtom(m_dpy, "_NET_WM_STATE_FULLSCREEN", True);
      XChangeProperty(m_dpy, m_mainWindow, XInternAtom(m_dpy, "_NET_WM_STATE", True), XA_ATOM, 32, PropModeReplace, (unsigned char *) &fs, 1);
      
      int   one = 1;
      XChangeProperty (
      m_dpy, m_mainWindow,
      XInternAtom ( m_dpy, "_KDE_NET_WM_BLOCK_COMPOSITING", True ),
      XA_INTEGER,  32,  PropModeReplace,
      (unsigned char*) &one,  1);
    }

The codepath gets hit every time I switch to fullscreen (I see it with the printf line), but still compositing is on.

Any ideas ?
Comment 13 Thomas Lübking 2015-02-22 11:19:44 UTC
(In reply to attila.jakosa from comment #12)
> sorry to bother you with this again
No problem.

> luck. With vlc it works, but not with kodi. I tried all possible strings
> "kodi", "Kodi", "kodi.bin" etc. 

d'ohhh.
kodi does not set a window fullscreen, but re-adds a new one for every change (while 1; do head -> table; done)

I updated the script, it should catch kodi OotB

>       XChangeProperty (
>       m_dpy, m_mainWindow,
>       XInternAtom ( m_dpy, "_KDE_NET_WM_BLOCK_COMPOSITING", True ),
>       XA_INTEGER,  32,  PropModeReplace,

Wrong type, try XA_CARDINAL
Comment 14 attila.jakosa 2015-03-10 19:47:32 UTC
Just to let you guys know, now block compositing is already supported in Kodi. I didn't mention that I am a Kodi developer :-)

Here is the commit:
https://github.com/xbmc/xbmc/commit/15a1c3dfed16789909b5f28b47dc61ee2b3d80b5

Thank you for the help Thomas and Martin !
Now all works really great.
Comment 15 Thomas Lübking 2015-03-10 21:18:50 UTC
(In reply to attila.jakosa from comment #14)
> Just to let you guys know, now block compositing is already supported in Kodi.
=D
Very cool!

> I didn't mention that I am a Kodi developer :-)
Hehe - hopefully not the one responsible for the window re-creation (or I dropped a pallet of bricks ;-)
Comment 16 attila.jakosa 2015-03-10 21:29:21 UTC
Yes I am responsible for the translation system and language update. So windowing is too complicated for me, so thanks for the help once again !
Comment 17 AnAkkk 2015-08-05 13:12:56 UTC
(In reply to Martin Gräßlin from comment #1)
> suspend desktop effects for fullscreen windows is not supported on Intel
> hardware, neither was it on KDE4.

It was not supported due to an intel bug which has been fixed a few years ago apparently. Would it be possible to allow the unredirect fullscreen on intel hardware again?
Comment 18 Thomas Lübking 2015-08-05 13:14:25 UTC
(In reply to AnAkkk from comment #17)

> It was not supported due to an intel bug which has been fixed a few years
> ago apparently.

Link to commit?
Comment 19 AnAkkk 2015-08-05 13:16:57 UTC
(In reply to Thomas Lübking from comment #18)
> (In reply to AnAkkk from comment #17)
> 
> > It was not supported due to an intel bug which has been fixed a few years
> > ago apparently.
> 
> Link to commit?

http://cgit.freedesktop.org/xorg/xserver/commit/?id=0ce25fd7904c792924c3e0ee6fc21a5f1bec1a68

according to
https://bugs.freedesktop.org/show_bug.cgi?id=30509
Comment 20 Thomas Lübking 2015-08-05 14:46:19 UTC
Thanks.

On the very surface, I'm a bit sceptical whether a driver bug fixed in late 2010 would still have caused use reports in mid 2013 - from gentoo users!
Also the patch applies to dri2, while bug reports hit us from intel users (nearly?) exclusively.

Briefly looking at the backtraces of bug #252817, they seem to have changed during 2011 though, so the driver patch might have simply caught *one* error in this condition, leading us simply to the next driver bug (or it's been because of the UXA -> SNA switch) :-(

Right now, there's also some fuzz about https://bugs.freedesktop.org/show_bug.cgi?id=86281 - which seems broadwell only, but in the same area.

We might want to add

THIS_MAY_CRASH_IN_THE_DRIVER_FORCE_UNREDIRECTION_ALLOWED=1 kwin_x11 --replace &

to allow people testing it w/o having to recompile kwin, but please understand that we're not very eager to get 2-3 reports a day on this again (and for the little benefit it adds)
Comment 21 AnAkkk 2015-08-05 15:52:09 UTC
Well, I guess we can't know whether it's fixed or not without trying. It would be nice to have an easy way to do so.
Comment 22 Martin Flöser 2015-08-10 08:30:06 UTC
unredirecting compositing is honestly a rather stupid thing and also the implementation in KWin is rather stupid. I have some ideas on how to do it better in Wayland and have a blog post about this already in mind probably to be written and published later this week.

Given the thought I spent on this overall topic over the last two weeks I tend to say we will remove the feature all together.
Comment 23 Thomas Lübking 2015-11-09 21:35:47 UTC
*** Bug 355081 has been marked as a duplicate of this bug. ***
Comment 24 Martin Flöser 2015-11-10 07:38:03 UTC
*** Bug 355081 has been marked as a duplicate of this bug. ***
Comment 25 Ferry 2016-05-30 20:54:21 UTC
To my best recollection, this did work in kde4 on intel.

And despite #22, there is a use case where it is important: I'm using a NUC DE3815 with Atom E3815 as HTPC. Even though it is 1.5GHz single core, it will play back video in 1080p when the player is bare bones, so MPV works fine, but VLC tries much tricks in the CPU. But only when using vaapi for decode and opengl for rendering. And of course by eliminating other unnecessary load  as MPV even when offloading to the GPU loads the CPU over 60%.

With desktop effects disabled VLC will play 720p.

So , why use this weak NUC for this task? It consumes ~5W, so it can stay always on at little cost.

It doesn't make sense to need to implement a rule for each app that runs in full screen to disable compositing. Or can there be one rule that this for all full screen apps?