Skip to content

Playback stuck when failed to locate next period due to floating point error #882

Closed
@albertcsm

Description

@albertcsm

Hi, I am playing a multi-period DASH, and encounter playback stuck.

Shaka tried to locate the period by (last period start time + last segment end time in period), but the number ended up slightly less than the start time of the next period due to floating point error. Consequently, Shaka incorrectly looked up the the segment from the last period, and never advance to the next one.

There were console logs showing that Shaka tried to buffer segment at time 5.955944499999999s, but failed and keep retrying.

(audio:8) timeNeeded=5.955944499999999
18:53:03.026 streaming_engine.js:900 (audio:8) update_: playheadTime=5.50202 bufferedAhead=0.4939239999999998
18:53:03.027 streaming_engine.js:1030 (audio:8) next position known: position=2
18:53:03.027 streaming_engine.js:1130 (audio:8) segment does not exist: currentPeriod.startTime=1.001 position=2
18:53:03.027 streaming_engine.js:1879 (audio:8) updating in 1 seconds
18:53:03.042 streaming_engine.js:888 (video:6) timeNeeded=5.955944499999999
18:53:03.043 streaming_engine.js:900 (video:6) update_: playheadTime=5.50202 bufferedAhead=0.45392900000000047
18:53:03.043 streaming_engine.js:1030 (video:6) next position known: position=2
18:53:03.044 streaming_engine.js:1130 (video:6) segment does not exist: currentPeriod.startTime=1.001 position=2
18:53:03.044 streaming_engine.js:1879 (video:6) updating in 1 seconds
18:53:04.028 streaming_engine.js:888 (audio:8) timeNeeded=5.955944499999999
18:53:04.029 streaming_engine.js:900 (audio:8) update_: playheadTime=5.50202 bufferedAhead=0.4939239999999998
18:53:04.029 streaming_engine.js:1030 (audio:8) next position known: position=2
18:53:04.029 streaming_engine.js:1130 (audio:8) segment does not exist: currentPeriod.startTime=1.001 position=2
18:53:04.030 streaming_engine.js:1879 (audio:8) updating in 1 seconds
18:53:04.045 streaming_engine.js:888 (video:6) timeNeeded=5.955944499999999
18:53:04.045 streaming_engine.js:900 (video:6) update_: playheadTime=5.50202 bufferedAhead=0.45392900000000047
18:53:04.046 streaming_engine.js:1030 (video:6) next position known: position=2
18:53:04.046 streaming_engine.js:1130 (video:6) segment does not exist: currentPeriod.startTime=1.001 position=2
18:53:04.047 streaming_engine.js:1879 (video:6) updating in 1 seconds

The manifest looks like follows:

<?xml version="1.0" encoding="UTF-8"?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:scte35="urn:scte:scte35:2014:xml+bin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" mediaPresentationDuration="PT50.0546222S" minBufferTime="PT8.0S" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd">
   <Period start="PT0S" id="1">
      ...
   </Period>
   <Period start="PT1.001S" id="2">
      <AdaptationSet mimeType="audio/mp4" startWithSAP="1" lang="eng" segmentAlignment="true">
         <SegmentTemplate timescale="10000000" presentationTimeOffset="1984022521601042" media="$RepresentationID$/Segment-$Time$.m4a" initialization="$RepresentationID$/init.m4i">
            <SegmentTimeline>
               <S t="1984022532077598" d="39680000" />
            </SegmentTimeline>
         </SegmentTemplate>
         <Representation audioSamplingRate="48000" codecs="mp4a.40.29" id="stream_1" bandwidth="48000" />
      </AdaptationSet>
      ...
   </Period>
   <Period start="PT5.9559445S" id="3">
      <AdaptationSet mimeType="audio/mp4" startWithSAP="1" lang="eng" segmentAlignment="true">
         <SegmentTemplate timescale="10000000" presentationTimeOffset="1984022571150487" media="$RepresentationID$/Segment-$Time$.m4a" initialization="$RepresentationID$/init.m4i">
            <SegmentTimeline>
               <S t="1984022571757598" d="49920000" />
            </SegmentTimeline>
         </SegmentTemplate>
         <Representation audioSamplingRate="48000" codecs="mp4a.40.29" id="stream_1" bandwidth="48000" />
      </AdaptationSet>
      ...
   </Period>
</MPD>

I verified that the error is caused by floating point error by computing 1.001 + 4.9549445 in console, which gives 5.955944499999999.
(1.001 is start time of period "2" and 4.9549445 is the end time of the last segment in period "2" after fitting to the period boundary between period "2" and "3").

I have opened similar issue before (#694) but seems the fix is incomplete.

Thanks in advance.

Metadata

Metadata

Assignees

Labels

status: archivedArchived and locked; will not be updatedtype: bugSomething isn't working correctly

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions