This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26436 - [MSE] SourceBuffer Monitoring algorithm can cause stall after endOfStream()
Summary: [MSE] SourceBuffer Monitoring algorithm can cause stall after endOfStream()
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: Media Source Extensions (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: CR
Assignee: Aaron Colwell
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-25 18:13 UTC by Jer Noble
Modified: 2014-08-12 17:24 UTC (History)
4 users (show)

See Also:


Attachments

Description Jer Noble 2014-07-25 18:13:19 UTC
After MediaSource.endOfStream() is called, the duration of the media is extended to the highest reported buffered range of each SourceBuffer in MediaSource.sourceBuffers:

"2.4.7 End of stream algorithm"
"3. If error is not set"
"3.1. Run the duration change algorithm with new duration set to the highest end time reported by the buffered attribute across all SourceBuffer objects in sourceBuffers."

Also, the buffered ranges returned by HTMLMediaElement.buffered are modified to include these "virtual" buffered ranges:

"9. HTMLMediaElement Extensions"
"5. For each SourceBuffer object in activeSourceBuffers run the following steps:"
"5.2. If readyState is "ended", then set the end time on the last range in source ranges to highest end time."

But the checks in "SourceBuffer Monitoring" use only the original, unmodified buffered ranges:

"2.4.4 SourceBuffer Monitoring"
"If buffered for at least one object in activeSourceBuffers contains a TimeRange that ends at the current playback position and does not have a range covering the time immediately after the current position:"
"1. Set the HTMLMediaElement.readyState attribute to HAVE_CURRENT_DATA."

This causes playback to stall, and will typically occur at the end of a stream, after endOfStream() is called, when 2 or more SourceBuffers of fractionally different buffered lengths are active. It is exceedingly unlikely that streams of different types (audio, video) will have exactly the same duration, due to the relative sample durations of each media type.
Comment 1 Aaron Colwell 2014-08-12 17:24:35 UTC
Change committed.
https://dvcs.w3.org/hg/html-media/rev/856c321c7a6b

I changed the steps in the SourceBuffer Monitoring to trigger transitions based on HTMLMediaElement.buffered instead of the individual SourceBuffer.buffered attributes. This should address the issue since HTMLMediaElement.buffered takes into account the extending of the ranges.

I also updated the HTMLMediaElement.readyState transition steps at the bottom of the "coded frame processing" algorithm to use HTMLMediaElement.buffered as well to make the behavior consistent with the SourceBuffer monitoring algorithm.