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

Delete DASH tracks on reset on a ended state #1394

Closed
patcheco1001 opened this issue May 12, 2016 · 8 comments
Closed

Delete DASH tracks on reset on a ended state #1394

patcheco1001 opened this issue May 12, 2016 · 8 comments
Milestone

Comments

@patcheco1001
Copy link

The problem #488 / #151 isn't completely resolved, on branchs 1.6.0 and development.
In "abort" function of SourceBufferExtensions/SourceBufferController, you said:
if (mediaSource.readyState === "open") { buffer.abort(); }
But if the ready state = "ended" you also need to delete the text tracks:
if(["open", "ended"].indexOf(mediaSource.readyState) !== -1)

@davemevans
Copy link
Contributor

The code you link has nothing to do with deleting TextTracks. SourceBuffer.abort is simply used to abort the current SourceBuffer.append.

Your suggestion is not something we would want to do because calling SourceBuffer.abort when readyState is not open will cause an InvalidStateError to be thrown [1].

Can you provide a further information on the problem you are seeing?

[1] https://w3c.github.io/media-source/#widl-SourceBuffer-abort-void

@patcheco1001
Copy link
Author

patcheco1001 commented May 17, 2016

This is the call stack after we're calling player.reset() (if ready state === "open") :

  1. SourceBufferExtensions.abort()
  2. TextSourceBuffer.abort()
  3. TextTrackExtensions.deleteAllTextTracks()

I have two contents with subtitles.
On the first, the subtitles start at 2 seconds and on the second, the subtitles start at 5 seconds.
In the "ended" event of the first video I'm doing : player.reset();
I'm launching the second video and I'm seeing the subtitle of the first video at 2s, and then that of the second video to 5s. After that I'm only seeing the subtitles of the second video.

When I called buffer.abort() while the ready state = ended, I haven't had a problem.

@davemevans
Copy link
Contributor

davemevans commented May 17, 2016

Can you confirm you have tested this with either http://dashif.org/reference/players/javascript/v2.1.1/samples/dash-if-reference-player/index.html or the latest development branch?

This appears to be working for me in the latest dev branch in Chrome on Windows 7. What UA, OS are you using?

@patcheco1001
Copy link
Author

I confirm. For both.
Here are the manifests :
1st video : http://videos-pmd.francetv.fr/innovation/media4D/m4d-rugby-avc-ondemand/manifest.mpd
2nd video : http://videos-pmd.francetv.fr/innovation/media4D/m4d-JT-20h-2-ondemand/manifest.mpd

  1. Load the first video
  2. Please note that the first text track is "M. Larbot: la sortie des Bleus en ambiance."
  3. Wait the "ended" event.
  4. Load the second video

You can see the first text track of the first video.

@davemevans
Copy link
Contributor

I still can't reproduce your problem, but I can understand why it might be happening.

This is probably another example of TextSourceBuffer violating the API of SourceBuffer while attempting to polyfill - see #685 (comment) for the other example.

As mentioned above, the purpose of the abort method is simply to abort the current append. Here it is being overloaded as a reset method.

As also mentioned above, MSE specifies an exception must be thrown if abort is called when readyState isn't open, so we can't just call abort in that case.

I suspect the hack fix will be similar to the previous example, where we detect if the SourceBuffer is a polyfill and alter the behaviour accordingly. Something like:

    function abort(mediaSource, buffer) {
        const alwaysReset = Object.prototype.toString.call(buffer).slice(8, -1) === 'Object';
        try {
            if (mediaSource.readyState === 'open' || alwaysReset) {
                buffer.abort();
            }
        } catch (ex) {
        }
    }

This raises the question again about whether TextSourceBuffer is an appropriate polyfill for SourceBuffer.

@patcheco1001
Copy link
Author

It's strange that you can't reproduce the problem. I use W10 64bit with Chrome 50 and Firefox 43.0.1.
I have the problem on both browsers.
The "ended" event must be triggered on the first video.
Our code line fix the problem.

@davemevans
Copy link
Contributor

Our code line fix the problem.

Yes, because the try {} catch block masks the InvalidStateError which is thrown by the non-Text SourceBuffers. But it's a hack around the real problem, just as my suggestion was.

@dsilhavy
Copy link
Collaborator

dsilhavy commented Apr 7, 2020

Fixed in #3170

@dsilhavy dsilhavy closed this as completed Apr 7, 2020
@dsilhavy dsilhavy added this to the 3.1.0 milestone Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants