[Firefox] Needs permission to own MPRIS bus names, not just talk to them
Categories
(Core :: Widget: Gtk, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox82 | --- | fixed |
People
(Reporter: will, Assigned: pobega)
References
(Blocks 2 open bugs)
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15 Epiphany/605.1.15
Steps to reproduce:
- In about:config, set media.hardwaremediakeys.enabled = true
- Browsed to YouTube and started playing a video
Actual results:
No media playback indicator appeared in the GNOME Shell notification menu.
This is because the Firefox flatpak only has permission to talk to the name org.mpris.MediaPlayer2.org.mozilla.firefox. This is not correct:
- As described in the MPRIS specification[1] and implemented in Firefox[2], Firefox needs to own a name in the MPRIS namespace, not talk to one.
- That's not the name Firefox uses. It defines DBUS_MRPIS_SERVICE_NAME (sic, should be MPRIS) as "org.mpris.MediaPlayer2.firefox" [3] and then (following guidance in the MPRIS specification for apps which can have multiple running instances) appends ".instance$PID" to that name[4]
[1] https://specifications.freedesktop.org/mpris-spec/latest/#Bus-Name-Policy
[2] https://github.com/mozilla/gecko-dev/blob/34eac0d840a849f88ae09b17e2c599114a74b859/widget/gtk/MPRISServiceHandler.cpp#L423-L427
[3]
[4] https://github.com/mozilla/gecko-dev/blob/34eac0d840a849f88ae09b17e2c599114a74b859/widget/gtk/MPRISServiceHandler.cpp#L421
Expected results:
Based on reading https://docs.google.com/document/d/1c4FivJpvAjjw9Uw-jn7X1UjGOoWkANXOulNyqDWs83w/ I expected that the playing media would be shown by GNOME Shell, thanks to Firefox implementing the MPRIS specification.
If I launch Firefox with:
$ flatpak run --own-name=org.mpris.MediaPlayer2.firefox.'*' org.mozilla.firefox
Then indeed I can see the playing media in the GNOME notifications menu, and control it with the media keys on my keyboard.
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Comment 1•4 years ago
|
||
Oh – in a Flatpak context a PID is not a suitable key to unique-ify between different instances of Firefox. If you start a second Firefox with a different profile, it will be in a separate PID namespace, so both are likely to believe themselves to be PID 3. A better choice (which is also suitable in the non-Flatpak case) is to use something derived from the D-Bus connection's unique name.
These are defined in https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus. The specification is a little wooly on the details but in practice they have the form ":I.J" for two integers I and J; adjusting for characters which are legal in D-Bus names, perhaps org.mpris.MediaPlayer2.firefox.instance_I_J would be a good option.
Updated•4 years ago
|
Assignee | ||
Comment 2•4 years ago
|
||
Updated•4 years ago
|
Comment 3•4 years ago
|
||
Once this gets merged to central, it will naturally ride the 82 train.
I'll let the Sherriffs close the bug.
Comment 5•4 years ago
|
||
bugherder |
Comment 6•4 years ago
|
||
The concern with PIDs being non-unique still holds, though.
In it's current form, the PIDs would clash resulting the second instance to be unable to own the bus, hence not registering MPRIS.
Description
•