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
v1 goes into a loop on detaching and re-attaching media #3732
Comments
This works fine with version <1.0 |
Appears to be a regression in v1 of hls.js. An upstream issue created at video-dev/hls.js#3732 But I also found similar issue (video-dev/hls.js#2473) that seems to suggest that it's best to just re-initialize the Hls instance instead of re-attaching the media so I'll just go with that for now. Fixes #688
* fix(CAMERA_STREAM): stream fails to resume after being suspended Appears to be a regression in v1 of hls.js. An upstream issue created at video-dev/hls.js#3732 But I also found similar issue (video-dev/hls.js#2473) that seems to suggest that it's best to just re-initialize the Hls instance instead of re-attaching the media so I'll just go with that for now. Fixes #688 * revert debugging code * debug code
I recommend calling
|
OK I see what's happening here. |
… recursive calls when handlers call loadSource) Resolves #3732
Hi @rchl, Thanks for the bug report. #3754 should fix this issue. Can you confirm by trying this build with your test case? Thanks! https://deploy-preview-3754--hls-js-dev.netlify.app/dist/hls.js |
The fix works for the issue with getting into the loading loop. A sandbox using the fixed version is at https://codesandbox.io/s/hls-v1-bug-try-fix-9wr6b?file=/index.html But I wonder if it's correct that re-attaching triggers double Below is a log on re-attaching the media. You can see that Log
|
We can avoid attaching a third time, but there is a reason for that. When you reattach after having already loaded a stream, you don't need to call loadSource again. Detaching destroys the MediaSource, but hls.js rememebers the url it loaded, so that when reattaching it can load it again (set Your example reloads on attaching and then must restart on attached becuase It's best to create a new instance when loading different streams, for a single stream, just do not call |
Thanks for the explanation. I did decide to just change my code to destroy the instance instead of detaching (see resoai/TileBoard#692). |
If you're loading one source, then changing to a new one, are you SUPPOSED to detach/reattach as common flow? I don't understand why you're supposed to detach if you're re-using 1 hls.js instance, and 1 video element. Can you not just wait for the video to end playing (OR call stopload) and then call loadSource with a new URL? This method seems to work fine for me in 1.0.0 EXCEPT for the fact that loadSource is calling MEDIA_ATTACHED, which makes no sense to me because the MEDIA isn't being detached (or manually reattached) from the video element. For more details on my specific usage.. I am listening to MEDIA_ATTACHED to generate all the URLs that will be played in order, and it calls loadSource on the first one. On video event 'ended' I call loadSource again for the next URL, but it is triggering MEDIA_ATTACHED (so I have an IF statement to prevent my code running more than once.) I would assume MEDIA_ATTACHED should only logically be triggered when hls.attachMedia(video); is called.. but I am not detaching/reattaching. I only attach once after initializing hls.js. |
If codecs change then new SourceBuffers are required. That's why you would need to detach reattach. I'm looking at not automatically performing the detach/attach if the buffer controller has not been used yet. I edited my last comment now as I work through the problem. I can see how you might want to wait for attached to be successful before loading your stream, the real issue comes when you want to reattach for some reason because you don't need to call loadSource in that case. Also if you want to load something new you should be able to just call loadSource, but you could not in previous viersions without the detach and attach, so we do it for you, but that's where the recursive problem can surface if you do this on attached. |
…e URL has changed, and source buffer types are set Resolves #3732
HI @rchl / cc @MasterEvilAce, I've reworked #3754 so that https://deploy-preview-3754--hls-js-dev.netlify.app/demo/ If you could, please give it go and let me know if everything looks OK. Thanks! (the preview URL is the same so you can see the fix in the same sandbox app shared earlier https://codesandbox.io/s/hls-v1-bug-try-fix-9wr6b?file=/index.html) |
Looks good. Seeing only one Thanks! |
What version of Hls.js are you using?
v1.0.0
What browser and OS (including versions) are you using?
Chrome 89 on macOS 11.2.3
Test stream:
https://codesandbox.io/s/hls-v1-bug-1n63v?file=/index.html
Configuration:
defaults
Checklist
Steps to reproduce
hls.loadSource()
called from theMEDIA_ATTACHED
event andvideo.play()
called from theMANIFEST_PARSED
event.Expected behavior
The stream starts playing again.
Actual behavior
The video goes into some loop, playing and pausing constantly. The event logs shows that the
MEDIA_ATTACHED
event is called twice after step 3.Console output
The text was updated successfully, but these errors were encountered: