VOOZH about

URL: https://bugzilla.mozilla.org/show_bug.cgi?id=1648024

⇱ 1648024 - [Firefox] Needs permission to own MPRIS bus names, not just talk to them


Closed Bug 1648024 Opened 5 years ago Closed 5 years ago

[Firefox] Needs permission to own MPRIS bus names, not just talk to them

[Firefox] Needs permission to own MPRIS bus names, not just talk to them
Core
Widget: Gtk
77 Branch
Unspecified
Unspecified
defect
Points:
---
RESOLVED FIXED
RESOLVED
FIXED
82 Branch
Iteration:
---
a11y-review
Accessibility Severity
Performance Impact
Size Estimate
Webcompat Priority
Webcompat Score
Tracking Status
firefox82 --- fixed
Tracking Status
relnote-firefox
thunderbird_esr115
thunderbird_esr140
firefox-esr115
firefox-esr140
firefox-esr153
firefox82
firefox152
firefox153
firefox154
---
QA Whiteboard:
---
Has STR:
---
Change Request:
---
Bug Flags:
Signature:
None
This bug is publicly visible.

 
Reporter

Description

β€’
5 years ago

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:

  1. In about:config, set media.hardwaremediakeys.enabled = true
  2. 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

β€’
5 years ago
Reporter

Comment 1

β€’
5 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.

Priority: -- β†’ P3
Assignee: nobody β†’ pobega

Once this gets merged to central, it will naturally ride the 82 train.
I'll let the Sherriffs close the bug.

Comment 4

β€’
5 years ago
Pushed by mtabara@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7696ef3fe20d take ownership of correct mpris bus name for flatpak r=mtabara DONTBUILD

Comment 5

β€’
5 years ago
bugherder
Status: UNCONFIRMED β†’ RESOLVED
Closed: 5 years ago
status-firefox82: --- β†’ fixed
Resolution: --- β†’ FIXED
Target Milestone: --- β†’ 82 Branch

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.

No longer blocks: 1665211
Blocks: 1861627
No longer blocks: 1861627
You need to log in before you can comment on or make changes to this bug.