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

Chromecast player stalling when gap in live manifest #1720

Closed
maxi297 opened this issue Dec 5, 2018 · 16 comments
Closed

Chromecast player stalling when gap in live manifest #1720

maxi297 opened this issue Dec 5, 2018 · 16 comments
Assignees
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@maxi297
Copy link

maxi297 commented Dec 5, 2018

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

What version of Shaka Player are you using?: v2.4.4

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?: Both

If custom app, can you reproduce the issue using our demo app?: Yes

What browser and OS are you using?:
Chromecast (for example: V1, V2, Ultra)

What are the manifest and license server URIs?:
Our manifest contains SegmentTemplate with a gap like this:

             <SegmentTemplate timescale="10000000" media="S!dxIDVP7...8BFgZnDU9QUEUtV0lERVZJTkV4IOIBFQGv/QualityLevels($Bandwidth$)/Fragments(video=$Time$)" initialization="S!dxIDVP7...8BFgZnDU9QUEUtV0lERVZJTkV4IOIBFQGv/QualityLevels($Bandwidth$)/Fragments(video=Init)">
                <SegmentTimeline>
                    <S t="15440366781137770" d="30000000" r="12"/>
                    <S d="20000000"/>
                    <S t="15440367201137770" d="30000000"/>
                </SegmentTimeline>
            </SegmentTemplate>

Our stream is DRM protected which will make it hard to reproduce. We could provide the URIs in private and more information if needed.

What did you do?
We have played a live stream with gaps in the manifest on Chromecast. When the gap occurs, the player buffers for many seconds. We do not own the manifest and have to deal with those gaps.

What did you expect to happen?
There is a jump over the gap and continue.

What actually happened?
The player got stalled until it was outside of the availability window.

Do you have any idea why this happens?
1- In GapJumpingController.onPollGapJump_, We successfully jumped over the gap. We then exit GapJumpingController.onPollGapJump_
2- We return in GapJumpingController.onPollGapJump_ and enter in handleStall_. Conditions are met (we haven't understood what this implies entirely) so that the player prints 'Flushing media pipeline due to stall inside buffered range'
3- The player is stalled until it was outside of the availability window.
4- The player returns in the seek range and can play again until the next gap.

Workaround for now
We are not completely clear about why the Chromecast is stalling. We believe that this device is not fast enough to seek. We can see that this problem does not occur on web with a Chrome browser.

We have implemented a workaround and are eager to see what you think of it. Our workaround is to add a grace period after a jump before stalling. Basically, everytime we jump, we keep the timestamp of NOW and before stalling, we check if we have jumped recently over gap. Here is the interesting part:

// shaka.media.GapJumpingController.prototype.onPollGapJump_ ...
  if (gapIndex == -1) {
    if (this.gracePeriodIsPast_(currentTime)) {
      this.handleStall_();
      return;
    } else {
      shaka.log.info('Stalling within grace period');
      return;
    }
// ...
  if (isGapSmall || jumpLargeGap) {
// ...
    this.lastJumpPerformedTime_ = this.getNow_();
  }

/**
 * @param {number} currentTime
 * @return {boolean} if the grace period is past
 */
shaka.media.GapJumpingController.prototype.gracePeriodIsPast_ =
 function(currentTime) {
  return this.lastJumpPerformedTime_ +
    this.config_.gapJumpingGracePeriodInSeconds
    <= this.getNow_();
};

/**
 * @return {number} now
 */
shaka.media.GapJumpingController.prototype.getNow_ = function() {
  return new Date().getTime() / 1000;
};

EDIT: The gaps on the live streams occur only once every 22m30s. Therefore, we do not fear to have many gaps in a short period of time. This fix would not work in that case because we might jump over the first gap, might end up near another gap and our gapJumpingGracePeriodInSeconds would not allow the player to jump again. As of now, we are trying to gather more data with a gapJumpingGracePeriodInSeconds = 3. We might revisit this value if we see any side effects.

Questions:
1- Have you already experienced this issue? If so, how did you dealt with?
2- Do you have any comment/solution for our workaround?

@theodab
Copy link
Collaborator

theodab commented Dec 5, 2018

We've definitely had problems with slow hardware problems with Chromecasts before. See issue #1411, for example. So your assumption about the cause of this seems reasonable, though without being able to reproduce the issue I can't say for certain.

Looking at the code, it also seems possible that our current check for stalling inside a buffered range is too aggressive. It assumes that if the media is "playing" but has had a playback rate of 0 for more than a second straight, the video has stalled. Maybe on slow hardware, like on Chromecasts, it simply sometimes takes more than one second to seek sometimes, so we are assuming the stream has stalled prematurely?

You can send details on reproduction to shaka-player-issues@google.com.

@theodab
Copy link
Collaborator

theodab commented Dec 5, 2018

To be clear, there are some ideas we could try, but we will need to be able to test them to be sure they actually solve the problem.

@maxi297
Copy link
Author

maxi297 commented Dec 10, 2018

I have sent you the information by email. If anything else is need, tell us and we will provide the information as soon as possible!

@joeyparrish
Copy link
Member

We received the info by email. Thank you!

@theodab theodab self-assigned this Dec 10, 2018
shaka-bot pushed a commit that referenced this issue Jan 4, 2019
It appears that Chromecasts stop a fraction of a second before a gap.
This would sometimes cause them to stall on gaps in a way that the
stall prevention would not fix.
This changes Chromecasts to use the large gap threshold, to fix those
cases.

Issue #1720

Change-Id: Ifc6720e55ab35b81b8592dad2ba7e7293983a755
@theodab
Copy link
Collaborator

theodab commented Jan 4, 2019

Ok, I was able to reproduce the problem with a (short) custom manifest. This change solves the problem on that custom manifest; I haven't tested the fix on your sample. I'll try it later, or you can try it yourself if you want. I won't close the issue until I know it's an actual fix.

@alexgerv
Copy link

alexgerv commented Jan 4, 2019

Hi @theodab, the changes on e5b2428 are helping, but we actually observed delays greater than 0.5 seconds for the player to recover from a gap, more in the 1 or 2 seconds range, sometimes even more on a Chromecast V1 or embedded. Ideally, this value would be configurable. Any thoughts ?

@theodab
Copy link
Collaborator

theodab commented Jan 4, 2019

We plan on gathering more thorough data on platform-specific gap behavior in the future. Hopefully that will help us better account for V1 Chromecasts, and other platforms with weak hardware.
I can write a CL for a configurable gap threshold, in the meantime, and see what the rest of the team thinks. That'd be straightforward enough.

@TheModMaker
Copy link
Contributor

That number specifies the distance from a gap where we will jump it. So with that change, we'll jump a gap once we are 0.5 seconds from it. This ensures we seek before the browser stalls due to not enough media. This value has no effect on the stall detection. What is probably happening is the Chromecast is taking too long to start playing after the gap jump so the stall detection kicks in and we do another seek. The delay before we handle a stall would be better to be configurable.

@alexgerv
Copy link

alexgerv commented Jan 4, 2019

It probably does not hurt to attempt the seek a bit earlier, but that's correct, we observed that the real issue was the stall detection kicking in too fast, before the chromecast even had the chance to seek and resume.
Detecting the stall is under the gapJumpTimer .25 seconds loop, but it can also be short-circuited by a segment being appended.
The "grace period" logic proposed by @maxi297 really did alleviate the issue.

joeyparrish pushed a commit that referenced this issue Jan 18, 2019
It appears that Chromecasts stop a fraction of a second before a gap.
This would sometimes cause them to stall on gaps in a way that the
stall prevention would not fix.
This changes Chromecasts to use the large gap threshold, to fix those
cases.

Issue #1720

Backported to v2.4.x

Change-Id: Ifc6720e55ab35b81b8592dad2ba7e7293983a755
@joeyparrish
Copy link
Member

Work so far cherry-picked for v2.4.6.

@vaage
Copy link
Contributor

vaage commented Mar 19, 2019

@alexgerv I am sorry that progress on this issue has been dormant for so long.

I noticed that you mentioned in your last comment that stall detection is kicking too fast. As part of Issue #1839 we are making the stall detection logic configurable. Would that help you make progress until we find time to investigate gaps and stalls more carefully?

In offline converstaions, @joeyparrish and I have talked about how buffering, gap detection, and stall detection may need to be more cooperative, which would be in-line with your idea of grace periods. I'm confident that we'll find a solution that will work for you and others, but we will need time.

What may help this issue get more attention and slotted for a milestone is if you were to summarize what behaviors you need and open an enhancement request. Enhancement requests are easier for community members to rally behind, increasing their priority, and increasing the odds that they'll get resources directed to them.

@vaage vaage added the status: waiting on response Waiting on a response from the reporter(s) of the issue label Mar 19, 2019
@shaka-bot
Copy link
Collaborator

Closing due to inactivity. If this is still an issue for you or if you have further questions, you can ask us to reopen or have the bot reopen it by including @shaka-bot reopen in a comment.

@shaka-bot shaka-bot removed needs triage status: waiting on response Waiting on a response from the reporter(s) of the issue labels Mar 26, 2019
@vaage vaage reopened this Mar 26, 2019
@vaage vaage added needs triage status: waiting on response Waiting on a response from the reporter(s) of the issue labels Mar 26, 2019
@shaka-bot
Copy link
Collaborator

Closing due to inactivity. If this is still an issue for you or if you have further questions, you can ask us to reopen or have the bot reopen it by including @shaka-bot reopen in a comment.

@maxi297
Copy link
Author

maxi297 commented Apr 5, 2019

As requested, here is the enhancement request: #1864
Thanks a lot for the guidance!

@michellezhuogg michellezhuogg self-assigned this Apr 22, 2019
@joeyparrish joeyparrish added type: bug Something isn't working correctly and removed needs triage labels Jul 11, 2019
@shaka-bot shaka-bot added this to the v2.6 milestone Jul 11, 2019
@michellezhuogg michellezhuogg removed their assignment Oct 10, 2019
@joeyparrish
Copy link
Member

It's not clear why this is still open. It seems like it is superseded by the feature request #1864. May we close this issue?

@joeyparrish joeyparrish added the status: waiting on response Waiting on a response from the reporter(s) of the issue label Jan 23, 2020
@maxi297
Copy link
Author

maxi297 commented Jan 28, 2020

I think this one can be close. As requested by @vaage, our request is now fully documented in the following ticket: #1864
Thanks!

@maxi297 maxi297 closed this as completed Jan 28, 2020
@shaka-bot shaka-bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label Jan 28, 2020
@shaka-project shaka-project locked and limited conversation to collaborators Mar 28, 2020
@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

8 participants