MJPEG streaming in Safari - possible improvements

Note: This post is just informational for a possible future improvement to Safari webcam handling.

Currently the method for disabling the webcam stream is to set the src attribute of the associated image to "". This doesn't work in Safari, so the code has a browser test and doesn't bother to reset the source if the browser is Safari:

// safari bug doesn't release the mjpeg stream, so we just set it up the once
if (OctoPrint.coreui.browser.safari && currentSrc != undefined) {
     return;
}

I have a simple html file that tests this behavior and noticed that in the latest Safari Tech Preview (13.2, WebKit 15610.1.2.1), this seems to be fixed.

When this makes it into the wild, it might be possible to update the test to include a minimum version and use the normal behavior for newer versions of Safari.

2 Likes