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

Fatal playback failure due to phantom media segment request #3717

Closed
romsil opened this issue Oct 26, 2021 · 7 comments · Fixed by #4009
Closed

Fatal playback failure due to phantom media segment request #3717

romsil opened this issue Oct 26, 2021 · 7 comments · Fixed by #4009
Assignees
Labels
priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@romsil
Copy link

romsil commented Oct 26, 2021

Have you read the FAQ and checked for duplicate open issues?
Yes

What version of Shaka Player are you using?
3.2.0

Can you reproduce the issue with our latest release version?
Yes

Can you reproduce the issue with the latest code from master?
Yes

Are you using the demo app or your own custom app?
Custom app.

If custom app, can you reproduce the issue using our demo app?
I believe so. It is difficult to reproduce the issue since it only happens on certain ads on our player.

What browser and OS are you using?
Chrome, macOS

For embedded devices (smart TVs, etc.), what model and firmware version are you using?
N/A

What are the manifest and license server URIs?
Our manifest URIs are short-lived, so I am pasting the period declaration instead:

<Period duration="PT30.720000S" id="a-2">
      <AssetIdentifier schemeIdUri="urn:com:uplynk:ad-asset-id" value="d4bfa4522c044a968fc4f2a0d944340f" />
      <AdaptationSet audioSamplingRate="48000" contentType="audio" group="1" lang="en" mimeType="audio/mp4" segmentAlignment="true" startWithSAP="1">
         <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main" />
         <Representation bandwidth="127878" codecs="mp4a.40.5" id="v0">
            <AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
            <BaseURL>https://RedactedCDNUrl/slices/d4b/4f59ea65df184a2580ad8fc80d3eaa32/d4bfa4522c044a968fc4f2a0d944340f/</BaseURL>
            <SegmentTemplate duration="184320" initialization="https://RedactedCDNUrl/slices/d4b/4f59ea65df184a2580ad8fc80d3eaa32/d4bfa4522c044a968fc4f2a0d944340f/TK_init.mp4" media="TK_$Number%08d$.m4f" startNumber="0" timescale="90000" />
         </Representation>
      </AdaptationSet>

See notes below on our investigation results.

What configuration are you using? What is the output of player.getConfiguration()?
Mostly default. See attached screenshot for player.getConfiguration() output:

ShakaPlayerConfigs

What did you do?
I just let the asset play until it reaches the ad period.

What did you expect to happen?
Playback will continue with no fatal error.

What actually happened?
Shaka makes a network request to media segment TK_00000015.m4f.
Based on the period declaration for the audio Adaptation Set, the media segments from TK_00000000.m4f to TK_00000014.m4f should have been enough. See attached screenshot of my computation.

AdPeriodMediaSegmentList

We investigated the issue and we think this is caused by small floating points being ceiled in Shaka. We have patched Shaka below to fix the issue.

--- a/lib/dash/segment_template.js
+++ b/lib/dash/segment_template.js
@@ -345,7 +345,7 @@ shaka.dash.SegmentTemplate = class {
       // In period-relative positions (0-based).
       const availablePeriodPositions = [
         Math.ceil(availablePeriodTimes[0] / segmentDuration),
-        Math.ceil(availablePeriodTimes[1] / segmentDuration) - 1,
+        Math.ceil((availablePeriodTimes[1] / segmentDuration).toFixed(10)) - 1,
       ];

It's a small one-line fix but it's causing playback failure.

@romsil romsil added the type: bug Something isn't working correctly label Oct 26, 2021
@shaka-bot shaka-bot added this to the v3.3 milestone Oct 26, 2021
@michellezhuogg michellezhuogg added the priority: P2 Smaller impact or easy workaround label Oct 28, 2021
@michellezhuogg
Copy link
Contributor

Hello @romsil , thank you for finding the root cause! Would you like to send us a Pull Request?

@romsil
Copy link
Author

romsil commented Oct 28, 2021

@romsil
Copy link
Author

romsil commented Oct 28, 2021

@michellezhuogg I just submitted the pull request: #3721

Thank you.

@romsil
Copy link
Author

romsil commented Oct 29, 2021

Just an addendum:

Before the fix above, the actual values that we get on Chrome are:

availablePeriodTimes[1] = 30.720000000000027,
segmentDuration = 2.048,
availablePeriodTimes[1] / segmentDuration = 15.000000000000012
Math.ceil(availablePeriodTimes[1] / segmentDuration) = 16

After the fix, we get:

Math.ceil(availablePeriodTimes[1] / segmentDuration).toFixed(10) = 15

@michellezhuogg
Copy link
Contributor

Thank you!

@boredom2
Copy link

boredom2 commented Jan 8, 2022

Hi there,

as Shaka v3.3 is now initially released, this Problem here would be our biggest issue.
As far as I can see, this has not been included in the 3.3 Release, right?
When can we expect this to be merged into a Release?

Thank you very much and btw - Happy New Year :)

@joeyparrish
Copy link
Member

This issue has not been fixed yet. The fix in PR #3721 was not merged due to some debate that was never resolved. I'll give it another look now.

@joeyparrish joeyparrish self-assigned this Jan 10, 2022
@joeyparrish joeyparrish added priority: P1 Big impact or workaround impractical; resolve before feature release and removed priority: P2 Smaller impact or easy workaround labels Jan 10, 2022
joeyparrish added a commit that referenced this issue Jan 11, 2022
If a rounding error in the DASH parser created an extra "phantom"
segment that extended just beyond the presentation duration, this was
causing a playback failure.  Now StreamingEngine will tolerate these
small offsets and end playback at the correct time.

Fixes #3717

Change-Id: I00780a664aff4148b6b1046d8322a68da745de40
joeyparrish added a commit that referenced this issue Jan 11, 2022
If a rounding error in the DASH parser created an extra "phantom"
segment that extended just beyond the presentation duration, this was
causing a playback failure.  Now StreamingEngine will tolerate these
small offsets and end playback at the correct time.

Fixes #3717

Change-Id: I00780a664aff4148b6b1046d8322a68da745de40
joeyparrish added a commit that referenced this issue Jan 11, 2022
If a rounding error in the DASH parser created an extra "phantom"
segment that extended just beyond the presentation duration, this was
causing a playback failure.  Now StreamingEngine will tolerate these
small offsets and end playback at the correct time.

Fixes #3717

Change-Id: I00780a664aff4148b6b1046d8322a68da745de40
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Mar 12, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
5 participants