videojs / http-streaming

HLS, DASH, and future HTTP streaming protocols library for video.js
https://videojs-http-streaming.netlify.app/
Other
2.53k stars 425 forks source link

Background tab muted hangs after few minutes #1392

Closed misiek08 closed 1 week ago

misiek08 commented 1 year ago

Description

Setup basic live HLS+DASH player (I use it with DRM, but probably doesn't matter), start player muted and go to another tab. After 5+ minutes come back to this tab. Player will be downloading segments that passed and will report after while errors with each of the ABR playlists.

Looks very similar to https://github.com/videojs/http-streaming/issues/1196.

I think this is related to browsers killing chained timers in JS when tab is in background. Chrome is stopping such timers after 5 minutes by default. Probably global setInterval or requestAnimationFrame is a workaround.

I've tried plugin that is watching visibilitychange event and pausing player on leaving tab and then calling play()/currentTime(0) after coming back to tab again - seemed like it works, but it only prolonged the issue to 10+ minutes.

Sources

Doesn't matter, live HLS+DASH, with ABR should do.

Steps to reproduce

Explain in detail the exact steps necessary to reproduce the issue.

  1. Start muted player with HLS+DASH ABR playlists. EDIT: it happens very easily with DASH playlists with $Number$ template
  2. Leave the tab in background for 5+ minutes.
  3. Come back to player tab.

Results

Expected

Player still working correctly.

Error output

VIDEOJS: WARN: Problem encountered with playlist 0-placeholder-uri-0. Playlist no longer updating. Switching to playlist 3-placeholder-uri-3. [player.js:226:49](https://static.hawecdn.com/hp/player.js)
VIDEOJS: WARN: Problem encountered with playlist 3-placeholder-uri-3. Playlist no longer updating. Switching to playlist 2-placeholder-uri-2. [player.js:226:49](https://static.hawecdn.com/hp/player.js)
VIDEOJS: WARN: Problem encountered with playlist 2-placeholder-uri-2. Excessive audio segment downloading detected. Switching to playlist 1-placeholder-uri-1. [player.js:226:49](https://static.hawecdn.com/hp/player.js)
VIDEOJS: WARN: Removing other playlists from the exclusion list because the last rendition is about to be excluded. [player.js:226:49](https://static.hawecdn.com/hp/player.js)
VIDEOJS: WARN: Problem encountered with playlist 1-placeholder-uri-1. Playlist no longer updating. Switching to playlist 0-placeholder-uri-0. [player.js:226:49](https://static.hawecdn.com/hp/player.js)
VIDEOJS: WARN: Problem encountered with playlist 0-placeholder-uri-0. Excessive main segment downloading detected. Switching to playlist 3-placeholder-uri-3.

Additional Information

After returning to the tab player is downloading all old video segments (for a few seconds it tried to download audio, but after returning above errors it is just following video segments). I've tested currentTime(0) and now liveTracker.seekToLiveEdge() - they are not helping.

videojs version

what version of videojs does this occur with? video.js 8.0.4

Browsers

Platforms

what platforms are affected? please include operating system and version or device and version for each

Other Plugins

are any other videojs plugins being used on the page? If so, please list them with version below.

Other JavaScript

are you using any other javascript libraries or frameworks on the page? if so please list them below.

welcome[bot] commented 1 year ago

šŸ‘‹ Thanks for opening your first issue here! šŸ‘‹

If you're reporting a šŸž bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. To help make it easier for us to investigate your issue, please follow the contributing guidelines.

Essk commented 1 year ago

Thanks for the report! I wasn't able to reproduce but I think it would be interesting to know if the issue persists if the user overrides the "performance" setting of the browser.

Screenshot 2023-04-27 at 09 41 20
lqminh268 commented 3 months ago

Hello, have you found a solution yet? I'm facing a similar issue when playing an m3u8 link. When I switch to another tab, Video.js only requests the m3u8 file but doesn't request any TS files. It only makes the request when I return to the tab, but it shows a rather annoying loading screen. :(

misiek08 commented 1 week ago

The only solution we had is to detect muted player and just force src() to reset whole player. Currently migrated to shaka, because video.js is getting worse every day, especially VHS was too unstable :(