Video Stream gets added each time you navigate to the Control tab #1780
What were you doing?
Everytime you navigate to the Control tab, it adds a new stream to the web page. This can be see in the web inspector and also in the bandwidth on the network interface - jumping about 2MB/s for each stream.
What did you expect to happen?
Only use the single stream.
What happened instead?
Branch & Commit or Version of OctoPrint
Printer model & used firmware incl. version
Browser and Version of Browser, Operating System running Browser
Safari 10.0.3, macOS Sierra 10.12.3
Link to octoprint.log
Link to contents of terminal tab or serial.log
Screenshot(s) showing the problem:
I have read the FAQ.
works normally in Chrome on windows. Navigating to the control page opens up the stream, navigating away from the control tab closes the stream after a few seconds. Navigating to it, away from it, to it, away from it in quick succession doesn't open up any new streams.
Thing is, OctoPrint tries to unload the mjpg stream when a) the control tab is not visible or b) the whole browser tab containing OctoPrint is not active for at least 5s. Reason for that is that it doesn't make sense to keep streaming if nobody is watching. Unloading is done by setting the img src to an empty string (and yes, that is the recommended way to do that). That works fine in all browsers - well, besides Safari apparently, because contrary to everything else on the market Safari simply keeps on loading the stream. On return to control tab/browser tab, OctoPrint will set the img src attribute back to the stream's URL. Apparently THAT is something that Safari in fact DOES react to and it loads a second (and then a third and a fourth and so on) stream.
So... it's a big fat browser bug and the only way around it that I see right now is explicitly switching the mjpg unload behaviour off for Safari until this bug is fixed in that browser.
referenced this issue
May 29, 2017
How about tricking safari to open a dead/non existent stream when the control tab is not on focus or when another tab is clicked and again loading the correct stream when the control tab is clicked?
This way it would not cause load when the tab is not active and would load when the tab is active
I don´t know if this will wrk but its just an idea.
@derfred33 Problem is that Safari simply continues streaming the stream, even if you set its URL to an existing other image :/ I just tested this on BrowserStack. So apparently the only option for now is to not touch things again once the stream is running in that particular browser. I suggest to use a browser that doesn't have this bug until Apple bothers to fix it (whenever that will happen, considering it's been present for more than ten years now). Chrome and Firefox both don't have any issues.
I have this issue on both osx and ios ipad but its not what I often see reported from years ago. They usually say that the stream stops after a few seconds, my stream does not stops. Only if I change the browser tab it stops, then I have to reload the octoprint tab.
Something like this:
Better yet would be to do this only if the user agent is Safari:
I´ll try to do this as soon as I have a spare pi, next week or so.