pimusicbox/mopidy-musicbox-webclient

The webclient reset the mopidy volume to old value

dublok opened this issue · 2 comments

I am not sure that this is the correct place for this error message, maybe it belongs to mopidy.

When I sent set_volume via HTTP RPC to mopidy (in a rapid sequence) then someone resets the volume to the old value.

INFO     mixer set_volume 29  << OK: set by test via mixer.set_volume()
INFO     mixer set_volume 26  << OK: set by test via mixer.set_volume()
INFO     mixer set_volume 23  << OK: set by test via mixer.set_volume()
INFO     mixer set_volume 20  << OK: set by test via mixer.set_volume()
INFO     mixer set_volume 29  << Error: reset via playback.set_volume()

The issue is gone, if I close the webbrowser (which shows musicbox-webclient).
The issue started recently (mopidy 2.0 or musicbox-webclient update)

Setup:

  • Rasperry Pi 2
  • mopidy 2.0 as service (or started from commandline)
  • midori webbrowser with musicbox-weblient
  • play any music
  • Enabled extensions: mpd, alsamixer, http, dleyna, stream, m3u, local-images, softwaremixer, file, musicbox_webclient, local, local-sqlite

To reproduce use the attached script to send volume-down to mopidy.
volume_setter.py.zip

Detailed log:
unexpected_set_volume_2.txt.zip

https://github.com/pimusicbox/mopidy-musicbox-webclient/blame/develop/mopidy_musicbox_webclient/static/js/gui.js#L269

Always calling setVolume(data["volume"]); fixes the issue (for me). I can't observe any feedback loop between mopidy and webclient, but ... I think there was a good reason to introduce the volumeChanging flag.

As far as I know the web client only processes volume changes every 500ms.

So if it receives multiple requests during this period the others will be ignored, which is probably why it reverts to the first volume setting that it receives via HTTP RPC.

I think this was done to prevent the client from sending large numbers of volume change requests to Mopidy as the user moves the volume slider around.

It seems like a reasonable optimization, though I am not sure that it is still necessary.