Bug 384837

Summary: No media controls or info in thumbnail if using Firejail
Product: [Plasma] plasmashell Reporter: Rafael C. <rccavalcanti>
Component: Task Manager and Icons-Only Task ManagerAssignee: Eike Hein <hein>
Status: RESOLVED FIXED    
Severity: minor CC: kalomel, kde, kde, nate, plasma-bugs
Priority: NOR    
Version: 5.10.5   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Screenshot

Description Rafael C. 2017-09-19 04:39:44 UTC
Created attachment 107900 [details]
Screenshot

Starting a media player using Firejail will cause the media controls and the media information not to show in the application thumbnail.

Tested: VLC, Spotify.

The media control plasmoid, however, works fine.
Comment 1 Kai Uwe Broulik 2017-09-19 08:51:57 UTC
I suspect the PID of the service that owns the mpris service becomes different from the PID that owns the window.

Can you check xprop | grep PID and click the window when running in firejail and compare that to qdbus org.freedesktop.DBus / org.freedesktop.DBus.GetConnectionUnixProcessID org.mpris.MediaPlayer2.vlc
Comment 2 Rafael C. 2017-09-19 08:57:57 UTC
(In reply to Kai Uwe Broulik from comment #1)
> I suspect the PID of the service that owns the mpris service becomes
> different from the PID that owns the window.
> 
> Can you check xprop | grep PID and click the window when running in firejail
> and compare that to qdbus org.freedesktop.DBus /
> org.freedesktop.DBus.GetConnectionUnixProcessID org.mpris.MediaPlayer2.vlc


You're definitely right!


With Firejail:
$ xprop | grep PID
_NET_WM_PID(CARDINAL) = 9
$ qdbus org.freedesktop.DBus / org.freedesktop.DBus.GetConnectionUnixProcessID org.mpris.MediaPlayer2.vlc
8057


Without Firejail:
$ xprop | grep PID
_NET_WM_PID(CARDINAL) = 8089
$ qdbus org.freedesktop.DBus / org.freedesktop.DBus.GetConnectionUnixProcessID org.mpris.MediaPlayer2.vlc
8089
Comment 3 Kai Uwe Broulik 2017-09-19 09:02:05 UTC
The question is... what can we do about it? :/

Is Firejail perhaps the parent process of VLC? Then we could maybe traverse the parent tree but I'm not really fond of making this mapping logic even more complex and brittle than it already is.
Comment 4 Rafael C. 2017-09-19 09:04:33 UTC
(In reply to Kai Uwe Broulik from comment #3)
> The question is... what can we do about it? :/
> 
> Is Firejail perhaps the parent process of VLC? Then we could maybe traverse
> the parent tree but I'm not really fond of making this mapping logic even
> more complex and brittle than it already is.

Indeed. I just checked pstree and we have:

plasmashell───firejail───firejail───vlc───5*[{vlc}]
Comment 5 Rafael C. 2017-10-28 22:12:20 UTC
Reported to Firejail: https://github.com/netblue30/firejail/issues/1619
Comment 6 kalomel 2018-05-27 11:56:52 UTC
There is a related discussion in the Mate community, where it has been proposed to use LOCAL_CLIENT_PID instead of _NET_WM_PID: https://github.com/mate-desktop/marco/issues/301

Posting just for reference, can't judge if that makes any sense.
Comment 7 David Edmundson 2018-05-27 22:56:22 UTC
Thanks

That's not a terrible idea, but blindly switching will break just as many places as it fixes.
Like smplayer which have mplayer and the GUI as separate processes, but deliberately have a NET_WM_PID which is "faked"
Comment 8 David Edmundson 2019-07-26 09:55:00 UTC
Git commit b485043e5633b9a07e3cc6804a66ddbe2c134583 by David Edmundson.
Committed on 26/07/2019 at 09:48.
Pushed by davidedmundson into branch 'master'.

[platforms/xcb] Use XRES extension to get real window PID

Summary:
It's increasingly common for apps to be in their own PID namespace. If
this is the case, they report a buggy NET_WM_PID on their windows as
obviously they don't know their own PID.

This patch uses the XResources extension to query the real PID instead
of asking the window.

This allows the task manager to know the real PID when doing lookups for
matching services or showing pulseaudio badges.

Querying the NET_WM_PID with the NETWM wrappers remains unchanged, so we
still have access to all information should a system need it.

Test Plan:
The relevant unit test KWindowInfo::testPid() still passes whilst using
this new extension.

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D22755

M  +1    -1    CMakeLists.txt
M  +1    -0    src/platforms/xcb/CMakeLists.txt
M  +36   -0    src/platforms/xcb/kwindowinfo.cpp
M  +1    -0    src/platforms/xcb/kwindowinfo_p_x11.h

https://commits.kde.org/kwindowsystem/b485043e5633b9a07e3cc6804a66ddbe2c134583