altdesktop / playerctl

🎧 mpris media player command-line controller for vlc, mpv, RhythmBox, web browsers, cmus, mpd, spotify and others.
GNU Lesser General Public License v3.0
2.42k stars 79 forks source link

Command executes successfully but with 20 sec delay with firefox new MPRIS support. #187

Closed man9ourah closed 3 years ago

man9ourah commented 3 years ago

Hello!

I am trying to control firefox media through the newly added support for MPRIS .. see their spec document here but it might be out dated: https://drive.google.com/file/d/1TpQULFJTNRQ1QDCS7QKycf98677kB5DI/view

The new support is not on by default, you need to tweak a couple of options in about:config as mentioned in the document above.

Playerctl controls it successfully, and command are executed just fine. However it blocks for about 20 seconds afterwards then it timeouts.. With other players, i.e. vlc .. it does not do that. I am not sure which of the two (firefox or playerctl) is the one causing this. Another thing is: not all commands block.. status and metadata work perfectly without blocking.. play-pause next prev and commands that actually control the media are the ones with the problem.

If the problem is on firefox side (thats what I am expecting) .. is there a workaround? i.e. can I set the timeout value in cli? or even somewhere easily in the code?

Here are some commands output:

$ G_MESSAGES_DEBUG=playerctl playerctl -a next   
(process:4138): playerctl-DEBUG: 01:09:25.167: playerctl version 2.2.1
(playerctl:4138): playerctl-DEBUG: 01:09:25.182: Getting list of player names from D-Bus
(playerctl:4138): playerctl-DEBUG: 01:09:25.186: Getting list of player names from D-Bus
(playerctl:4138): playerctl-DEBUG: 01:09:25.186: found player: firefox.instance3284
(playerctl:4138): playerctl-DEBUG: 01:09:25.191: initializing player: firefox.instance3284
(playerctl:4138): playerctl-DEBUG: 01:09:25.192: executing command next
Could not execute command: Timeout was reached

the dbus monitor output:

$ dbus-monitor 
signal time=1598764417.904296 sender=org.freedesktop.DBus -> destination=:1.74 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.74"
signal time=1598764417.904320 sender=org.freedesktop.DBus -> destination=:1.74 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
   string ":1.74"
method call time=1598764419.401054 sender=:1.75 -> destination=org.freedesktop.DBus serial=1 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=Hello
method return time=1598764419.401077 sender=org.freedesktop.DBus -> destination=:1.75 serial=1 reply_serial=1
   string ":1.75"
signal time=1598764419.401090 sender=org.freedesktop.DBus -> destination=(null destination) serial=173 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
   string ":1.75"
   string ""
   string ":1.75"
signal time=1598764419.401115 sender=org.freedesktop.DBus -> destination=:1.75 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.75"
method call time=1598764419.401552 sender=:1.75 -> destination=org.freedesktop.DBus serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path='/org/freedesktop/DBus',arg0='org.freedesktop.DBus'"
method return time=1598764419.401576 sender=org.freedesktop.DBus -> destination=:1.75 serial=3 reply_serial=2
method call time=1598764419.401617 sender=:1.75 -> destination=org.freedesktop.DBus serial=3 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',path='/org/freedesktop/DBus'"
method return time=1598764419.401634 sender=org.freedesktop.DBus -> destination=:1.75 serial=4 reply_serial=3
method call time=1598764419.401671 sender=:1.75 -> destination=org.freedesktop.DBus serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',path='/org/freedesktop/DBus',arg0='org.freedesktop.DBus'"
method return time=1598764419.401687 sender=org.freedesktop.DBus -> destination=:1.75 serial=5 reply_serial=4
method call time=1598764419.401982 sender=:1.75 -> destination=org.freedesktop.DBus serial=5 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=StartServiceByName
   string "org.freedesktop.DBus"
   uint32 0
error time=1598764419.402020 sender=org.freedesktop.DBus -> destination=:1.75 error_name=org.freedesktop.DBus.Error.ServiceUnknown reply_serial=5
   string "The name org.freedesktop.DBus was not provided by any .service files"
method call time=1598764419.402275 sender=:1.75 -> destination=org.freedesktop.DBus serial=6 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.DBus"
method return time=1598764419.402295 sender=org.freedesktop.DBus -> destination=:1.75 serial=7 reply_serial=6
   string "org.freedesktop.DBus"
method call time=1598764419.402559 sender=:1.75 -> destination=org.freedesktop.DBus serial=7 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus.Properties; member=GetAll
   string "org.freedesktop.DBus"
method return time=1598764419.402574 sender=org.freedesktop.DBus -> destination=:1.75 serial=8 reply_serial=7
   array [
      dict entry(
         string "Features"
         variant             array [
               string "SystemdActivation"
            ]
      )
      dict entry(
         string "Interfaces"
         variant             array [
               string "org.freedesktop.DBus.Monitoring"
               string "org.freedesktop.DBus.Debug.Stats"
            ]
      )
   ]
method call time=1598764419.405466 sender=:1.75 -> destination=org.freedesktop.DBus serial=8 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=StartServiceByName
   string "org.freedesktop.DBus"
   uint32 0
error time=1598764419.405490 sender=org.freedesktop.DBus -> destination=:1.75 error_name=org.freedesktop.DBus.Error.ServiceUnknown reply_serial=8
   string "The name org.freedesktop.DBus was not provided by any .service files"
method call time=1598764419.405680 sender=:1.75 -> destination=org.freedesktop.DBus serial=9 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.DBus"
method return time=1598764419.405698 sender=org.freedesktop.DBus -> destination=:1.75 serial=10 reply_serial=9
   string "org.freedesktop.DBus"
method call time=1598764419.405858 sender=:1.75 -> destination=org.freedesktop.DBus serial=10 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus.Properties; member=GetAll
   string "org.freedesktop.DBus"
method return time=1598764419.405875 sender=org.freedesktop.DBus -> destination=:1.75 serial=11 reply_serial=10
   array [
      dict entry(
         string "Features"
         variant             array [
               string "SystemdActivation"
            ]
      )
      dict entry(
         string "Interfaces"
         variant             array [
               string "org.freedesktop.DBus.Monitoring"
               string "org.freedesktop.DBus.Debug.Stats"
            ]
      )
   ]
method call time=1598764419.406097 sender=:1.75 -> destination=org.freedesktop.DBus serial=11 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=ListNames
method return time=1598764419.406111 sender=org.freedesktop.DBus -> destination=:1.75 serial=12 reply_serial=11
   array [
      string "org.freedesktop.DBus"
      string ":1.7"
      string "org.freedesktop.PowerManagement"
      string "org.freedesktop.Notifications"
      string ":1.8"
      string "org.freedesktop.network-manager-applet"
      string ":1.9"
      string "org.freedesktop.systemd1"
      string "org.xfce.Xfconf"
      string "org.mpris.MediaPlayer2.firefox.instance3284"
      string "org.awesomewm.awful"
      string "org.gtk.vfs.mountpoint_2854"
      string "org.gtk.vfs.Daemon"
      string "org.pulseaudio.Server"
      string ":1.63"
      string "org.a11y.Bus"
      string "org.gtk.vfs.UDisks2VolumeMonitor"
      string ":1.64"
      string ":1.21"
      string ":1.68"
      string ":1.24"
      string ":1.46"
      string ":1.69"
      string ":1.25"
      string ":1.47"
      string ":1.48"
      string "org.xfce.PowerManager"
      string ":1.49"
      string "ca.desrt.dconf"
      string "org.bluez.obex"
      string "org.gtk.vfs.GPhoto2VolumeMonitor"
      string "org.freedesktop.ReserveDevice1.Audio0"
      string "org.gtk.vfs.mountpoint_2863"
      string "org.gtk.vfs.AfcVolumeMonitor"
      string "org.PulseAudio1"
      string "org.gtk.vfs.GoaVolumeMonitor"
      string "org.blueman.Applet"
      string ":1.50"
      string "org.gtk.vfs.Metadata"
      string ":1.52"
      string ":1.75"
      string ":1.10"
      string "org.gtk.vfs.mountpoint_dnssd"
      string ":1.11"
      string ":1.56"
      string ":1.12"
      string ":1.57"
      string ":1.0"
      string ":1.13"
      string ":1.14"
      string ":1.15"
      string ":1.16"
      string "org.gtk.vfs.MTPVolumeMonitor"
      string ":1.17"
      string ":1.39"
      string ":1.5"
      string ":1.6"
   ]
method call time=1598764419.407953 sender=:1.75 -> destination=org.freedesktop.DBus serial=12 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.mpris.MediaPlayer2.firefox.instance3284',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path='/org/mpris/MediaPlayer2',arg0='org.mpris.MediaPlayer2.Player'"
method return time=1598764419.407976 sender=org.freedesktop.DBus -> destination=:1.75 serial=13 reply_serial=12
method call time=1598764419.408047 sender=:1.75 -> destination=org.freedesktop.DBus serial=13 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.mpris.MediaPlayer2.firefox.instance3284',interface='org.mpris.MediaPlayer2.Player',path='/org/mpris/MediaPlayer2'"
method return time=1598764419.408066 sender=org.freedesktop.DBus -> destination=:1.75 serial=14 reply_serial=13
method call time=1598764419.408096 sender=:1.75 -> destination=org.freedesktop.DBus serial=14 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',path='/org/freedesktop/DBus',arg0='org.mpris.MediaPlayer2.firefox.instance3284'"
method return time=1598764419.408111 sender=org.freedesktop.DBus -> destination=:1.75 serial=15 reply_serial=14
method call time=1598764419.408287 sender=:1.75 -> destination=org.freedesktop.DBus serial=15 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=StartServiceByName
   string "org.mpris.MediaPlayer2.firefox.instance3284"
   uint32 0
error time=1598764419.408304 sender=org.freedesktop.DBus -> destination=:1.75 error_name=org.freedesktop.DBus.Error.ServiceUnknown reply_serial=15
   string "The name org.mpris.MediaPlayer2.firefox.instance3284 was not provided by any .service files"
method call time=1598764419.408490 sender=:1.75 -> destination=org.freedesktop.DBus serial=16 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.mpris.MediaPlayer2.firefox.instance3284"
method return time=1598764419.408503 sender=org.freedesktop.DBus -> destination=:1.75 serial=17 reply_serial=16
   string ":1.68"
method call time=1598764419.408641 sender=:1.75 -> destination=:1.68 serial=17 path=/org/mpris/MediaPlayer2; interface=org.freedesktop.DBus.Properties; member=GetAll
   string "org.mpris.MediaPlayer2.Player"
method return time=1598764419.409340 sender=:1.68 -> destination=:1.75 serial=30 reply_serial=17
   array [
      dict entry(
         string "PlaybackStatus"
         variant             string "Playing"
      )
      dict entry(
         string "Rate"
         variant             double 1
      )
      dict entry(
         string "Metadata"
         variant             array [
               dict entry(
                  string "mpris:trackid"
                  variant                      object path "/org/mpris/MediaPlayer2/firefox"
               )
               dict entry(
                  string "xesam:title"
                  variant                      string "Ed Sheeran - Thinking Out Loud [Official Video]"
               )
               dict entry(
                  string "xesam:album"
                  variant                      string ""
               )
               dict entry(
                  string "xesam:artist"
                  variant                      array [
                        string "Ed Sheeran"
                     ]
               )
            ]
      )
      dict entry(
         string "Volume"
         variant             double 1
      )
      dict entry(
         string "Position"
         variant             int64 0
      )
      dict entry(
         string "MinimumRate"
         variant             double 1
      )
      dict entry(
         string "MaximumRate"
         variant             double 1
      )
      dict entry(
         string "CanGoNext"
         variant             boolean true
      )
      dict entry(
         string "CanGoPrevious"
         variant             boolean true
      )
      dict entry(
         string "CanPlay"
         variant             boolean true
      )
      dict entry(
         string "CanPause"
         variant             boolean true
      )
      dict entry(
         string "CanSeek"
         variant             boolean false
      )
      dict entry(
         string "CanControl"
         variant             boolean true
      )
   ]
method call time=1598764419.409794 sender=:1.75 -> destination=:1.68 serial=18 path=/org/mpris/MediaPlayer2; interface=org.mpris.MediaPlayer2.Player; member=Next
method call time=1598764444.432831 sender=:1.75 -> destination=org.freedesktop.DBus serial=19 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',path='/org/freedesktop/DBus',arg0='org.mpris.MediaPlayer2.firefox.instance3284'"
method return time=1598764444.432887 sender=org.freedesktop.DBus -> destination=:1.75 serial=18 reply_serial=19
method call time=1598764444.433327 sender=:1.75 -> destination=org.freedesktop.DBus serial=20 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.mpris.MediaPlayer2.firefox.instance3284',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path='/org/mpris/MediaPlayer2',arg0='org.mpris.MediaPlayer2.Player'"
method return time=1598764444.433389 sender=org.freedesktop.DBus -> destination=:1.75 serial=19 reply_serial=20
method call time=1598764444.433471 sender=:1.75 -> destination=org.freedesktop.DBus serial=21 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.mpris.MediaPlayer2.firefox.instance3284',interface='org.mpris.MediaPlayer2.Player',path='/org/mpris/MediaPlayer2'"
method return time=1598764444.433503 sender=org.freedesktop.DBus -> destination=:1.75 serial=20 reply_serial=21
signal time=1598764444.434269 sender=org.freedesktop.DBus -> destination=:1.75 serial=5 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
   string ":1.75"
signal time=1598764444.434324 sender=org.freedesktop.DBus -> destination=(null destination) serial=174 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
   string ":1.75"
   string ":1.75"
   string ""
^C

Thanks!

man9ourah commented 3 years ago

Oh .. nvm .. I just saw #179 .. I am on firefox 79 btw ..

closing this..

acrisci commented 3 years ago

The relevant line from the dbus-monitor log is this:

method call time=1598764419.409794 sender=:1.75 -> destination=:1.68 serial=18 path=/org/mpris/MediaPlayer2; interface=org.mpris.MediaPlayer2.Player; member=Next

A message with reply_serial=18 is missing. This is a violation of the dbus specification

When an application handles a method call message, it is required to return a reply. The reply is identified by a REPLY_SERIAL header field indicating the serial number of the METHOD_CALL being replied to. The reply can have one of two types; either METHOD_RETURN or ERROR.

You can reproduce the issue with dbus-send.

I recommend using plasma-browser-integration as a workaround.

man9ourah commented 3 years ago

I really appreciate your response!!

From playerctl side, is the timeout configurable or easily accessible in the code where I could tweak it until firefox resolve this?

the suggested workaround have lots of dependencies for my environment.

acrisci commented 3 years ago

93 is open. I would accept a --timeout parameter into the cli.

You can also do timeout 0.5 playerctl next or playerctl next &.

acrisci commented 3 years ago

I've submitted a patch to firefox at https://bugzilla.mozilla.org/show_bug.cgi?id=1648874

If you want this issue to be resolved, please support that issue.