javascript – How to avoid background tab throttling for an HTML5 radio app?
I am running an internet radio station that uses an html5 audio element and a websocket.
According to MDN browsers should not throttle tabs that play audio or use websockets; however when the radio app runs in a background tab, connection drops in less than 30 minutes (the delay depends on the device’s RAM and load) with the following error:
GET https://coderadio-relay-blr.freecodecamp.org/radio/8010/radio.mp3 net::ERR_CONNECTION_CLOSED 200
Note1: The app optimizes for tab visibility and reduces its memory usage when it is in a background tab.
Note2: A similar behavior is experienced when a simple html5 audio and vanilla JS is used.
Note3: Here is the source code.
Note4: The experience is similar across browsers.
Read more here: Source link