Iris
Iris copied to clipboard
Re-establishing WS after extended background inactivity
Describe the bug When shutting down the computer over night (while leaving the tabs open in the browser (I'm kinda a tab messy and keep everything open)) and opening the browser the next day and accessing Iris I get a red error message in the bottom left that says "Mopidy: Call to an invalid object. Check you are calling a valid Mopidy object."
It is fixed by reloading without the cache (Ctrl + F5 on Firefox).
To Reproduce Steps to reproduce the behavior:
- Shut your computer down without closing the Iris tab.
- Start the browser the next day so that it restores the tabs
- Try to do anything in Iris. It shows that messages pretty much every time you try to do anything.
Expected behavior I'd expect it to not show that warning and continue working
Screenshots
Environment details:
- OS: Windows 10
- Browser: Firefox and Chrome
- Iris version: 3.45.1
Additional context Nothing major, just annoying.
This is an error that results when the Mopidy websocket object is missing, damaged or non-responsive. This can happen for a multitude of reasons - most of which are beyond the scope of Iris.
When you leave a tab in the background, many browsers limit their processes (usually to limit battery usage). Or your computer puts the network adapter into sleep mode. Or your computer has gone in to low power mode.
Iris will attempt to reconnect to both websocket endpoints when a disconnection occurs. However what I think you're describing is where the websocket hasn't been disconnected, just throttled. My theory is that this throttled connection now has a long queue of pending messages which bogs down the connection somewhere, causing the issue.
Iris will re-fetch the latest player state and queue on bringing the tab back to the foreground, but beyond that I don't know of a fix to this issue.
This happens for me when my computer was off and the tab has been restored.
Exactly - the browser is manipulating a long-running TCP (websocket) connection by restoring it. It needs to connect.
My advice is to pin your Iris tab and refresh it when necessary.
I mean wouldn't it be possible to try to detect that and reopen the socket?
@BrainStone you are most welcome to have a go at developing that and submitting a pull request.
I would if I had a clue about WebSockets.
@BrainStone do you still have that issue? I often put my PC into hibernation mode over night with Iris open and I've never seen this notification :)