Closed Bug 1118589 Opened 9 years ago Closed 9 years ago

MSE: SourceBuffer::appendBuffer doesn't fill the buffer asynchronously

Categories

(Core :: Audio/Video, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla38
Tracking Status
firefox36 --- fixed
firefox37 --- fixed
firefox38 --- fixed

People

(Reporter: jya, Assigned: jya)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 3 obsolete files)

As per spec:
http://w3c.github.io/media-source/#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data:

"5. Asynchronously run the buffer append algorithm."

Currently the entire SourceBuffer::appendBuffer is done synchronously. This is causing an issue with bug 1118126.

For example, one problem of not running asynchronously could be:

var ms = new MediaSource();
var sb = new SourceBuffer();

ms.duration = 0; // this queue a secondary task that will change the duration
sb.appendBuffer(data); // this adds data to the source buffer.

Now the queue task that will set the duration is run and (with bug 1118126 fixed) will clear all data in the source buffer found after timestamp 0.

We now have a cleared source buffer.

Either setting the mediasource duration has to be done so that it's not processed asynchronously in a separate task; or make appendBuffer queue the task so it always occur after an earlier operation has completed.
Priority: -- → P2
Run appendBuffer's internal asynchronously rather than just the updateend event. I ponder if it would have been better to use NS_NewRunnableMethodWithArg with a nsTArary instead, as the change would have been smaller, but it would have doubled the memory usage (albeit temporarily)
Attachment #8545655 - Flags: review?(ajones)
Assignee: nobody → jyavenard
Status: NEW → ASSIGNED
Comment on attachment 8545655 [details] [diff] [review]
[MSE] Run appendBuffer internal's asynchronously

I think cajbir is more suited for the review.
Plus I can see some issues with the order of events.
Attachment #8545655 - Flags: review?(ajones)
Add check if sourcebuffer was aborted before task got the chance to run
Attachment #8545671 - Flags: review?(cajbir.bugzilla)
Attachment #8545655 - Attachment is obsolete: true
Depends on: 1119119
Comment on attachment 8545671 [details] [diff] [review]
[MSE] Run appendBuffer internal's asynchronously

Review of attachment 8545671 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/media/mediasource/SourceBuffer.cpp
@@ +39,5 @@
>  namespace mozilla {
>  
>  namespace dom {
>  
> +class AppendDataRunnable : public nsRunnable {

Add comment explaining what this class is for.

@@ +41,5 @@
>  namespace dom {
>  
> +class AppendDataRunnable : public nsRunnable {
> +public:
> +  explicit AppendDataRunnable(SourceBuffer* aSourceBuffer,

'explicit' isn't needed in multi argument constructors and is ignored by the compiler.

@@ +49,5 @@
> +  {
> +    mData.AppendElements(aData, aLength);
> +  }
> +
> +  NS_IMETHOD Run() MOZ_OVERRIDE MOZ_FINAL {

This does a lot of stuff internal to mSourceBuffer. How about move it all to a method of SourceBuffer and just call that method from Run(). Then you don't need to do all the mSourceBuffer-> stuff.
Attachment #8545671 - Flags: review?(cajbir.bugzilla) → review+
Carrying r+. Move code to SourceBuffer class, and re-base to support timestampOffset
Attachment #8545671 - Attachment is obsolete: true
Depends on: 1121342
Since bug 1119456, try has been failing test_eme_playback.patch on all non-debug build but windows

https://treeherder.mozilla.org/#/jobs?repo=try&revision=7fd45ecd1603
Depends on: 1125581
Attachment #8546299 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/a20b290d8c86
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Comment on attachment 8554417 [details] [diff] [review]
MSE: Run appendBuffer internal's asynchronously

Approval Request Comment
[Feature/regressing bug #]: MSE
[User impact if declined]: Less consistent testing, sites more likely to serve Flash video.
[Describe test coverage new/current, TreeHerder]: Landed on m-c.
[Risks and why]: This fixes a spec compliance issue and is MSE-specific. We don't know that it's critical for youtube, but I think the the churn is worthwhile to remove the branch variance.
[String/UUID change made/needed]: None.
Attachment #8554417 - Flags: approval-mozilla-beta?
Attachment #8554417 - Flags: approval-mozilla-aurora?
Attachment #8554417 - Flags: approval-mozilla-beta?
Attachment #8554417 - Flags: approval-mozilla-beta+
Attachment #8554417 - Flags: approval-mozilla-aurora?
Attachment #8554417 - Flags: approval-mozilla-aurora+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: