Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player got stuck when playing multi-period live DASH #694

Closed
albertcsm opened this issue Feb 14, 2017 · 8 comments
Closed

Player got stuck when playing multi-period live DASH #694

albertcsm opened this issue Feb 14, 2017 · 8 comments
Assignees
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@albertcsm
Copy link
Contributor

albertcsm commented Feb 14, 2017

I have a multiple-period DASH stream produced by a proprietary encoder.
When playing it in Shaka, I found that the player got stuck occasionally at period boundaries. The loading circle keep spinning and the browser keep retrieving the manifest regularly, but there is no attempt to download the segment files.
image

After briefly digging in the Shaka code, I found the issue is likely caused by error in floating point manipulation. Shaka uses the start time of last-period and the presentation time of last segment to find the next period and segment to play. However, when it compare the time values, minor error introduced in floating point manipulation would cause it to miss the correct period/segment. Then Shaka will keep waiting for segment in the last period which is already over.

Here is the screenshot for Chrome's debug console. The "findPeriodContainingTime_" function should return period 12, but it didn't due to the small error in the time value passed to the function.
image

Here is the sample manifest, the player has problem loading period "13":
multi-period-stuck-floating-error.mpd.txt

The same issue happens on at least the following functions:

My MPD has a timescale of 1000, but I guess the same problem would occurs with any timescale > 1, since floating point errors happen even when there is only a few significant digits, e.g. 0.1 + 0.7 = 0.7999999999999999 < 0.8

I did a quick workaround to compensate for 1ns when comparing time values, and the stuck no longer happen. So I guess Shaka should compensate for floating point errors when it lookup the period/segment with computed time values.

Shaka: master checkout from github (40a92b6)
Chrome: 56.0.2924.28 beta (64-bit)

@albertcsm
Copy link
Contributor Author

albertcsm commented Feb 14, 2017

Reproduced with v2.0.5 and latest commit today (3cd2506)

@TheModMaker
Copy link
Contributor

Would it be possible to get a live (playable) version of the manifest so we can test that our fix actually works? You can send it privately if you want (my email is in CONTRIBUTORS and on my profile).

@albertcsm
Copy link
Contributor Author

Sorry, I am not be able to host the MPD right now.
Maybe I can help verify the fix or I can publish the stream to some external WebDAV server.

@TheModMaker
Copy link
Contributor

It would be really helpful if you could give us something to test ourselves. But in the meantime, can you try the following patch:

diff --git a/lib/dash/mpd_utils.js b/lib/dash/mpd_utils.js
index 7ee7dee..993ef05 100644
--- a/lib/dash/mpd_utils.js
+++ b/lib/dash/mpd_utils.js
@@ -320,12 +320,8 @@ shaka.dash.MpdUtils.fitSegmentReferences = function(
             firstReference.startByte, firstReference.endByte);
   }
 
-  if (dynamic)
+  if (periodDuration == null || periodDuration == Infinity)
     return;
-  goog.asserts.assert(periodDuration != null,
-                      'Period duration must be known for static content!');
-  goog.asserts.assert(periodDuration != Infinity,
-                      'Period duration must be finite for static content!');
 
   var lastReference = references[references.length - 1];

@TheModMaker TheModMaker self-assigned this Mar 3, 2017
@TheModMaker TheModMaker added the type: bug Something isn't working correctly label Mar 3, 2017
@joeyparrish joeyparrish changed the title Player got stuck due to floating point error when playing multi-period DASH Player got stuck when playing multi-period live DASH Mar 9, 2017
shaka-bot pushed a commit that referenced this issue Mar 9, 2017
We usually fit segment references to the Period for VOD content.  This
ensures that a gap in the manifest at the end of the Period doesn't
cause problems.  We don't do this for live because we may get more
segments.  However, for multi-Period live, we should still fit the
references for all Periods except the last one.

This also removes the error about duplicate Representation IDs for
VOD content since the problem only occurs for live.

Issue #694
b/35849085

Change-Id: Ib195dc51982ca58b8d5613b37817216980b8d366
@TheModMaker
Copy link
Contributor

I just pushed a change that might help your problem. I think the problem is that the last segment of the Period before it isn't being adjusted to the end of the next Period. This introduces a gap that makes us try to fetch the wrong Period.

@albertcsm Please try again from master.

@TheModMaker TheModMaker added the status: waiting on response Waiting on a response from the reporter(s) of the issue label Mar 13, 2017
@joeyparrish joeyparrish added this to the v2.1.0 milestone Mar 31, 2017
@joeyparrish
Copy link
Member

We believe this bug has been fixed. Please let us know when you have a chance to test.

@joeyparrish joeyparrish removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label Mar 31, 2017
@albertcsm
Copy link
Contributor Author

The problem seems solved in the master branch, thanks.

@joeyparrish
Copy link
Member

Thank you for letting us know!

@shaka-project shaka-project locked and limited conversation to collaborators Mar 22, 2018
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

4 participants