Closed
Bug 1401147
Opened 7 years ago
Closed 7 years ago
video shouldn't be playing when the media source doesn't have any source buffer
Categories
(Core :: Audio/Video: Playback, enhancement)
Tracking
()
RESOLVED
FIXED
mozilla58
Tracking | Status | |
---|---|---|
firefox58 | --- | fixed |
People
(Reporter: alwu, Assigned: alwu)
References
(Depends on 1 open bug, )
Details
Attachments
(3 files, 1 obsolete file)
This test page does the following things,
STR.
1. add the source buffer
2. append data
3. receiving updateend (append success)
4. remove the present source buffer
5. play video
Expect.
6. video can't start playing
Actual.
6. video can still be playing
We need to implement this todo[1] and make thing works.
[1] http://searchfox.org/mozilla-central/source/dom/media/mediasource/MediaSource.cpp#338
Assignee | ||
Comment 1•7 years ago
|
||
Comment hidden (mozreview-request) |
Assignee | ||
Updated•7 years ago
|
Assignee: alwu → jyavenard
Assignee | ||
Comment 3•7 years ago
|
||
After applying your patch, I still see some problems.
These behaviors seem wrong.
1. The video still shows the first frame
2. The duration of media source still have a value (60.63)
In addition, could you please add a test?
Thanks!
Flags: needinfo?(jyavenard)
Comment 4•7 years ago
|
||
(In reply to Alastor Wu [:alwu][please needinfo me][GMT+8] from comment #3)
> After applying your patch, I still see some problems.
> These behaviors seem wrong.
>
> 1. The video still shows the first frame
There's no reason it shouldn't. After all, readyState can have reached HAVE_CURRENT_FRAME.
No where does it state in the spec that the canvas is to be cleared.
Compare this to removing network access while playing.
Playback will stop, but whatever is currently being displayed is still stopped.
> 2. The duration of media source still have a value (60.63)
same as above.
It's fundamentally the same as pulling the network cable, or manually emptying the sourcebuffer with remove. duration shouldn't change.
https://w3c.github.io/media-source/#dom-mediasource-removesourcebuffer
There's nothing about changing the duration, or moving the readyState to HAVE_NOTHING (which would be required if you reset the duration (part of the metadata).
>
> In addition, could you please add a test?
> Thanks!
Flags: needinfo?(jyavenard)
Assignee | ||
Comment 5•7 years ago
|
||
(In reply to Jean-Yves Avenard [:jya] from comment #4)
> > 2. The duration of media source still have a value (60.63)
> same as above.
> It's fundamentally the same as pulling the network cable, or manually
> emptying the sourcebuffer with remove. duration shouldn't change.
>
> https://w3c.github.io/media-source/#dom-mediasource-removesourcebuffer
>
> There's nothing about changing the duration, or moving the readyState to
> HAVE_NOTHING (which would be required if you reset the duration (part of the
> metadata).
>
Make sense.
> (In reply to Alastor Wu [:alwu][please needinfo me][GMT+8] from comment #3)
> There's no reason it shouldn't. After all, readyState can have reached
> HAVE_CURRENT_FRAME.
> No where does it state in the spec that the canvas is to be cleared.
> Compare this to removing network access while playing.
> Playback will stop, but whatever is currently being displayed is still
> stopped.
Step11 said that "Destroy all resources for sourceBuffer" [1].
If we destroyed all its resources, should the video frame also be removed?
If the video frame was destroyed, why we could show it for user?
If this behavior is not well-defined on the spec, should we file a bug?
[1] https://w3c.github.io/media-source/#dom-mediasource-removesourcebuffer
---
In addition, I wanted to run my tests on Chrome to see the behavior, but all of them [1] can't run successfully.
Is my usage way incorrect? or that is Chrome's problem?
Thanks!
[1] https://alastor0325.github.io/htmltests/ (mse_XXX.html)
Flags: needinfo?(jyavenard)
Assignee | ||
Comment 6•7 years ago
|
||
mozreview-review |
Comment on attachment 8909752 [details]
Bug 1401147 - Empty track buffer content upon detach.
https://reviewboard.mozilla.org/r/181252/#review187010
r+ with adding test.
Attachment #8909752 -
Flags: review?(alwu) → review+
Comment 7•7 years ago
|
||
(In reply to Alastor Wu [:alwu][please needinfo me][GMT+8] from comment #5)
> Step11 said that "Destroy all resources for sourceBuffer" [1].
> If we destroyed all its resources, should the video frame also be removed?
> If the video frame was destroyed, why we could show it for user?
>
the video frame or canvas isn't part of the sourcebuffer. the sourcebuffer contains undemuxed / undecoded frames. It really for all purpose is to be considered like a network resource.
> If this behavior is not well-defined on the spec, should we file a bug?
>
> [1] https://w3c.github.io/media-source/#dom-mediasource-removesourcebuffer
In the spirit of the spec, there's nothing related to what you suggest.
If you were detaching the MediaSource itself then yes:
https://w3c.github.io/media-source/#mediasource-detach
But here we're just removing a source buffer.
This isn't a final situation, you can perfectly add a new sourcebuffer if desired. In which case you want playback to resume.
For all intent and purpose, removing the source buffer to me is akin to calling SourceBuffer::remove(0, +oo) on it. You've emptied the source buffer, but you haven't destroyed the media source.
Feel free to open a new bug on the MSE spec however if you feel it should be clarified.
the more clarification the better :)
> ---
>
> In addition, I wanted to run my tests on Chrome to see the behavior, but all
> of them [1] can't run successfully.
> Is my usage way incorrect? or that is Chrome's problem?
the error returned is:
Uncaught DOMException: Failed to execute 'removeSourceBuffer' on 'MediaSource': The SourceBuffer provided is not contained in this MediaSource.
at removeBuffer (https://alastor0325.github.io/htmltests/mse_remove_sourcebuffer.html:39:23)
at SourceBuffer.sourceBuffer.addEventListener.once (https://alastor0325.github.io/htmltests/mse_remove_sourcebuffer.html:41:9)
the code seems correct to me, chrome error isn't.
when you don't call removeBuffer() does it works (that is show a video frame)?
Feel free to take this bug and write a test for it...
Flags: needinfo?(jyavenard)
Comment 8•7 years ago
|
||
Seeing that all browsers appear to behave differently when this situation above, maybe it is worth better defining what needs to be done.
Assignee | ||
Comment 9•7 years ago
|
||
(In reply to Jean-Yves Avenard [:jya] from comment #7)
> the video frame or canvas isn't part of the sourcebuffer. the sourcebuffer
> contains undemuxed / undecoded frames. It really for all purpose is to be
> considered like a network resource.
Hmm, seem that the decoded frame is not in the field of this API, it's more related with MediaElement itself.
>
> In the spirit of the spec, there's nothing related to what you suggest.
>
> If you were detaching the MediaSource itself then yes:
> https://w3c.github.io/media-source/#mediasource-detach
>
> But here we're just removing a source buffer.
> This isn't a final situation, you can perfectly add a new sourcebuffer if
> desired. In which case you want playback to resume.
>
> For all intent and purpose, removing the source buffer to me is akin to
> calling SourceBuffer::remove(0, +oo) on it. You've emptied the source
> buffer, but you haven't destroyed the media source.
>
> Feel free to open a new bug on the MSE spec however if you feel it should be
> clarified.
> the more clarification the better :)
OK, I'll file a spec bug later.
> the error returned is:
> Uncaught DOMException: Failed to execute 'removeSourceBuffer' on
> 'MediaSource': The SourceBuffer provided is not contained in this
> MediaSource.
> at removeBuffer
> (https://alastor0325.github.io/htmltests/mse_remove_sourcebuffer.html:39:23)
> at SourceBuffer.sourceBuffer.addEventListener.once
> (https://alastor0325.github.io/htmltests/mse_remove_sourcebuffer.html:41:9)
>
> the code seems correct to me, chrome error isn't.
>
> when you don't call removeBuffer() does it works (that is show a video
> frame)?
Yes, I have other tests, I think they're more common usage way. (mse_higher_explicit_duration.html/mse_no_end_of_stream.html)
However, none of them could be run on Chrome. So I'm confused whether my implementation is wrong or other browsers are wrong...
And it makes me surprise, I think the usage of MSE should be more compatible.
> Feel free to take this bug and write a test for it...
Sure, I'll write a test and ask for a review.
Assignee | ||
Updated•7 years ago
|
Assignee: jyavenard → alwu
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 12•7 years ago
|
||
Comment 13•7 years ago
|
||
mozreview-review |
Comment on attachment 8910668 [details]
Bug 1401147 - part2 : add test.
https://reviewboard.mozilla.org/r/182104/#review187464
::: dom/media/mediasource/test/test_PlayWithoutValidSourceBuffer.html:39
(Diff revision 1)
> + el.play();
> + setTimeout(function() {
> + // The ready state of media element is HAVE_FUTURE_DATA, it means we have
> + // a few frames. Therefore, the current time might not be zero but it would
> + // be very close to it.
> + ok(Math.abs(el.currentTime - 0.0) < 0.001,
It's either 0 or it's not.
In either case your comment isn't correct.
if it has a few frames buffered (as they have already been decoded before the source buffer got removed) testing that it's within 0.001 s is likely going to cause intermittent.
el.currentTime - 0.0 makes no sense either.
Assignee | ||
Comment 14•7 years ago
|
||
(In reply to Jean-Yves Avenard [:jya] from comment #13)
> It's either 0 or it's not.
>
> In either case your comment isn't correct.
>
> if it has a few frames buffered (as they have already been decoded before
> the source buffer got removed) testing that it's within 0.001 s is likely
> going to cause intermittent.
Do you mean we should not test with current time?
What I saw is the current time would like around ~0.000040.
Any other good ways can we check whether the video is playing?
Thanks!
Flags: needinfo?(jyavenard)
Assignee | ||
Comment 15•7 years ago
|
||
Hmm, is it a good idea if I increase the threshold of checking current time? or we need to use another way?
eg. if el.currentTime < 0.1, then the test pass
Assignee | ||
Comment 16•7 years ago
|
||
I've seen the different current time on my try result, and it indeed causes the fail.
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 19•7 years ago
|
||
Flags: needinfo?(jyavenard)
Comment 20•7 years ago
|
||
mozreview-review |
Comment on attachment 8910668 [details]
Bug 1401147 - part2 : add test.
https://reviewboard.mozilla.org/r/182104/#review187656
::: dom/media/mediasource/test/test_PlayWithoutValidSourceBuffer.html:37
(Diff revision 2)
> + "buffered range should be 0 when we don't have any source buffer");
> +
> + info("- play video without the valid source buffer -");
> + el.play();
> + await once(el, "waiting");
> + ok(true, "video should not have enough data to playback continuously.");
this test doesnt add much value, even if you had added data you will hace got a waiting event once currentTime reaches the end as endOfStream() wasnt called.
that buffered attribute is empty should be enough IMHO.
alternatively, you could check that seeking to 0 never completes.
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 23•7 years ago
|
||
(In reply to Jean-Yves Avenard [:jya] from comment #20)
> that buffered attribute is empty should be enough IMHO.
No, without patch1, video can be playing and its buffered is also empty.
I would add seeking check to ensure the correct behavior (seek would fail cause of lacking enough data).
Assignee | ||
Updated•7 years ago
|
Attachment #8909752 -
Attachment is obsolete: true
Assignee | ||
Updated•7 years ago
|
Attachment #8910667 -
Flags: review?(jyavenard)
Assignee | ||
Updated•7 years ago
|
Attachment #8910668 -
Flags: review?(jyavenard)
Assignee | ||
Comment 24•7 years ago
|
||
Comment 25•7 years ago
|
||
(In reply to Alastor Wu [:alwu][please needinfo me][GMT+8] from comment #23)
> (In reply to Jean-Yves Avenard [:jya] from comment #20)
> > that buffered attribute is empty should be enough IMHO.
>
> No, without patch1, video can be playing and its buffered is also empty.
> I would add seeking check to ensure the correct behavior (seek would fail
> cause of lacking enough data).
You're not testing that the video isn't playing. You're testing that the waiting event will be fired.
And even without removing the source buffer, the waiting event *will* be fired.
You aren't calling EndOfStream, as such ended won't ever be fired. But waiting surely will.
Assignee | ||
Comment 26•7 years ago
|
||
(In reply to Jean-Yves Avenard [:jya] from comment #25)
> You're not testing that the video isn't playing. You're testing that the
> waiting event will be fired.
> And even without removing the source buffer, the waiting event *will* be
> fired.
>
> You aren't calling EndOfStream, as such ended won't ever be fired. But
> waiting surely will.
Have you seen my latest patch? I've changed the test to check whether seeking can be completed as a criteria, instead of checking "waiting" event.
Comment 27•7 years ago
|
||
I was just answering your message (which was an answer to mine), where I was specifically talking about the waiting event.
Assignee | ||
Comment 28•7 years ago
|
||
(In reply to Jean-Yves Avenard [:jya] from comment #27)
> I was just answering your message (which was an answer to mine), where I was
> specifically talking about the waiting event.
Yes, I just mean, only testing buffered is not enough (not talking about 'waiting', I've known it's not a good criteria from your explanation), so I'm adding your suggestion to seek 0 to ensure the video won't have enough data to playback.
Thanks for those detail reply.
Comment 29•7 years ago
|
||
mozreview-review |
Comment on attachment 8910667 [details]
Bug 1401147 - part1 : empty track buffer content upon detach.
https://reviewboard.mozilla.org/r/182102/#review187842
this is a commit of mine which you r+.
If you had kept the commit-id, authorship and review status would be kept
Attachment #8910667 -
Flags: review?(jyavenard) → review+
Comment 30•7 years ago
|
||
mozreview-review |
Comment on attachment 8910668 [details]
Bug 1401147 - part2 : add test.
https://reviewboard.mozilla.org/r/182104/#review187844
::: dom/media/mediasource/test/test_SeekWithoutValidSourceBuffer.html:26
(Diff revision 3)
> + ok(true, "start seeking");
> +
> + let timer = setTimeout(function() {
> + ok(true, "seeking would never be completed because of lacking enough data.");
> + resolve();
> + }, 1000);
should never have timeout or things assuming an operation will complete in a particular amount of time.
This will always end up intermitently failing depending on how busy the machine running the test is.
so let it timeout
Attachment #8910668 -
Flags: review?(jyavenard)
Assignee | ||
Comment 31•7 years ago
|
||
(In reply to Jean-Yves Avenard [:jya] from comment #30)
> should never have timeout or things assuming an operation will complete in a
> particular amount of time.
>
> This will always end up intermitently failing depending on how busy the
> machine running the test is.
>
> so let it timeout
Sad, I can't find any ways could make this test stable without using timeout...
So I would remove the playback related checking and only leave buffered status check.
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 34•7 years ago
|
||
mozreview-review |
Comment on attachment 8910668 [details]
Bug 1401147 - part2 : add test.
https://reviewboard.mozilla.org/r/182104/#review187924
::: dom/media/mediasource/test/test_RemoveSourceBuffer.html:36
(Diff revision 4)
> + is(el.buffered.length, 0,
> + "buffered range should be 0 since we don't have any source buffer.");
> +
> + info("- call endOfStream -");
> + ms.endOfStream();
> + is(ms.duration, 0, "duraton should be 0 since we don't have any source buffer.");
may as well also test that activeSourceBuffer is empty and that source buffer list is also empty.
Attachment #8910668 -
Flags: review?(jyavenard) → review+
Comment hidden (mozreview-request) |
Assignee | ||
Comment 36•7 years ago
|
||
Comment 37•7 years ago
|
||
Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/aabb5872e828
part1 : empty track buffer content upon detach. r=jya
https://hg.mozilla.org/integration/autoland/rev/d7435cf7c4e7
part2 : add test. r=jya
Comment 38•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/aabb5872e828
https://hg.mozilla.org/mozilla-central/rev/d7435cf7c4e7
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox58:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
You need to log in
before you can comment on or make changes to this bug.
Description
•