Closed Bug 1916306 Opened 1 year ago Closed 1 year ago

unexpected InvalidStateError exception with MediaSource.endOfStream() and short-duration last frame

Categories

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

defect

Tracking

()

RESOLVED FIXED
132 Branch
Tracking Status
firefox132 --- fixed

People

(Reporter: karlt, Assigned: karlt)

References

(Regressed 1 open bug)

Details

Attachments

(2 files)

https://pernos.co/debug/jm31IX8m_dYmE21IFNorXA/index.html records a case where endOfStream() throws because the result of GetHighestBufferedEndTime() is truncated to microseconds before being compared with HighestStartTime() for the exception. When the last frame is short enough, the highest start time can be greater than the truncated highest end time. In this case the last frame has zero duration for reasons described in bug 1916305, but the same can occur with non-zero-duration frames when the sample time denominator is larger than 10^6.

TimeUnit durations are subsequently truncated to microseconds by MediaSourceDecoder::SetMediaSourceDuration(), though the conversion to double seconds before multiplication by 10^6 and truncation may in edge cases lead to slightly different results than ToBase(), which multiplies before the double precision division. The SourceBuffer.buffered getter also uses ToBase().

The reasons for microsecond precision are given in commit messages as

it's
necessary to lower the precision of some values (using the method
ToMicrosecondResolution()) that end up visible by script to ensure that
there's no change in behaviour. When not doing that, the reported numbers have
higher precision -- we keep with the same precision for now
.

Similarly to the previous patch, it's necessary to reduce the resolution of
values visible from script to keep the exact same behaviour as before. We might
be able to remove this eventually but it might not be very useful to do so, the
benefits of using rational-based time are mostly for internal computations
.

The truncation to microseconds in endOfStream() may still serve a purpose, despite subsequent truncation, for the comparison with mDecoder->GetDuration(), the value of which may have been truncated when it was set.

Microsecond truncation of duration but not highest start time was sometimes
causing inappropriate InvalidStateError.

HighestStartTime() is more efficient than and equivalent when Ended to
GetHighestBufferedEndTime(), which constructs full TimeIntervals.

Use ToBase(USECS_PER_S) for rounding for consistency with the
SourceBuffer.buffered getter.

Pushed by ktomlinson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8fa884b2475d handle infinite TimeUnit values in ToBase() r=padenot
Pushed by ktomlinson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8a75f0122998 skip highest start time comparison on duration change from endOfStream r=padenot
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/47951 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 132 Branch
Upstream PR merged by moz-wptsync-bot
Upstream PR merged by moz-wptsync-bot
Regressions: 1917670
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: