Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebVTT subtitles broken when calling loadSource(..) inside MEDIA_ATTACHED-Event #3053

Closed
5 tasks done
netTrekfd opened this issue Sep 24, 2020 · 7 comments
Closed
5 tasks done
Labels
Milestone

Comments

@netTrekfd
Copy link
Contributor

netTrekfd commented Sep 24, 2020

What version of Hls.js are you using?

The bug initially appeared in 0.14.8 and is reproducable in every release since then.

What browser and OS are you using?

Chrome and Firefox (latest) on macOS 10.15.5 and windows 10, but does not seam to be OS or browser related.

Test stream:

https://zdfhls20-i.akamaihd.net/hls/live/744753/none/high/master.m3u8

Checklist

Steps to reproduce

  1. Go to https://clients.nettrek.de/hlsjs/demo/?src=https%3A%2F%2Fzdfhls20-i.akamaihd.net%2Fhls%2Flive%2F744753%2Fnone%2Fhigh%2Fmaster.m3u8&demoConfig=eyJlbmFibGVTdHJlYW1pbmciOnRydWUsImF1dG9SZWNvdmVyRXJyb3IiOnRydWUsImR1bXBmTVA0IjpmYWxzZSwibGV2ZWxDYXBwaW5nIjotMSwibGltaXRNZXRyaWNzIjotMX0= built from the current master and updated the main.js as follows:
hls.attachMedia(video);    
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
  hls.loadSource(url);
}
  1. Select a captions track using the video controls
  2. Click play
  3. Observe vtt segments are not loaded in the network panel / timeline

Expected behavior

According to the API it should be ok to call hls.loadSource(...) inside the Hls.Events.MEDIA_ATTACHED event.
Subtitles should be showing up.

Actual behavior

Subtitles are not showing up, regardless which subtitle track is being selected.

Console output

The console output does not show up any errors.

@robwalch robwalch added the Bug label Sep 25, 2020
@robwalch
Copy link
Collaborator

robwalch commented Sep 25, 2020

Hi @netTrekfd,

Do you ever call hls.startLoad()? Doing this following loadSource should fix the issue until a patch is made (or just load the manifest while the media is attaching - isn't that more performant?)

I don't know if your setup depends on config.autoStartLoad behavior and when that kicks in prior to and after the changes on #2909, or if you were calling it prior to loadSource.

@netTrekfd
Copy link
Contributor Author

Hi @robwalch,
thanks for your quick reply!

Indeed our own setup is relying on config.autoStartLoad. The hls.startLoad(pos) is being called inside the Hls.Events.MANIFEST_PARSED event. Calling hls.startLoad(-1) following or before calling loadSource does not fix this issue.
We also tested different scenarios with config.autoStartLoad enabled or disabled, all without affect. The only way to workaround (or probably a good idea in general) is to call attachMedia and loadSource right inside the same callstack (the order does not matter).

@robwalch
Copy link
Collaborator

Thanks @netTrekfd,

Could you make the "Steps to reproduce" a little clearer? Example:

  1. Go to https://clients.nettrek.de/hlsjs/demo/?src=https%3A%2F%2Fzdfhls20-i.akamaihd.net%2Fhls%2Flive%2F744753%2Fnone%2Fhigh%2Fmaster.m3u8&demoConfig=eyJlbmFibGVTdHJlYW1pbmciOnRydWUsImF1dG9SZWNvdmVyRXJyb3IiOnRydWUsImR1bXBmTVA0IjpmYWxzZSwibGV2ZWxDYXBwaW5nIjotMSwibGltaXRNZXRyaWNzIjotMX0=
    built from the current master and updated the main.js as follows:
hls.attachMedia(video);    
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
  hls.loadSource(url);
}
  1. Select a captions track using the video controls
  2. Click play
  3. Observe vtt segments are not loaded in the network panel / timeline

I didn't realize you included a test page. Thank you. I can reproduce the issue.

@robwalch
Copy link
Collaborator

robwalch commented Sep 25, 2020

Looks like this issue is in subtitle-stream-controller. It only starts its tick interval in onSubtitleTrackLoaded and has no override for startLoad to restart the interval. So basically you can't call stopLoad and startLoad without breaking this controller. Sorry my change exposed that. Have a look at startLoad in audio-stream-controller. The elements of what we need to add to subtitle-stream-controller can be found there.

@robwalch robwalch added this to the 0.14.14 milestone Sep 25, 2020
@netTrekfd
Copy link
Contributor Author

netTrekfd commented Sep 26, 2020

Thanks @robwalch for your feedback, i updated the issue accordingly. I will have a look at the subtitle-stream-controller and prepare a fix.

netTrekfd added a commit to netTrekfd/hls.js that referenced this issue Sep 26, 2020
netTrekfd added a commit to netTrekfd/hls.js that referenced this issue Sep 26, 2020
… otherwise it is done inside the onSubtitleTrackSwitch and/or onSubtitleTrackLoaded event.
video-dev#3053
@netTrekfd
Copy link
Contributor Author

netTrekfd commented Sep 28, 2020

Hi @robwalch,

i just added a PR for this issue.

During my tests i found another issue related to the loading behaviour which was a little bit tricky to reproduce. Actually it only occurred in about 5% of all tests and depends on network speed/latency (it was easier to reproduce via LTE) and general system performance. The problem is, that the last loaded fragment was saved correctly ( this.fragPrevious ) to keep up the right order of loading the webvtt files, but was not resetted in case of media seeking. If the initial load starts the subtitle controller to load it's webvtt-file before seeking to the live position, the error occurs. As the fragPrevious reference was not deleted, the subtitle controller continued to load webvtt-files from the very beginning of the dvr window instead of the one related to the current position. I fixed this by also calling stopLoad() and startLoad() inside the seeking and seekend event and was not able to reproduce it afterwards.

I luckily was able to record it: https://clients.nettrek.de/hlsjs/issue3053.mp4
Bildschirmfoto 2020-09-28 um 10 10 55

This is fixed with this commit: netTrekfd@2736608
Do you think it's better to add a separate issue for this?

Thanks!

@robwalch
Copy link
Collaborator

Hi @netTrekfd,

Great catch! I left you some feedback in the fix PR #3063 (comment)

netTrekfd added a commit to netTrekfd/hls.js that referenced this issue Sep 29, 2020
netTrekfd added a commit to netTrekfd/hls.js that referenced this issue Sep 29, 2020
… otherwise it is done inside the onSubtitleTrackSwitch and/or onSubtitleTrackLoaded event.
video-dev#3053
@robwalch robwalch closed this as completed Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants