question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling Player#unload followed by Player#load allows loading to proceed even though Player#mediaSource_ and Player#mediaSourceOpen_ are null

See original GitHub issue

Hello!

As part of our application’s preparation process before playback, we call Player.prototype.unload, then perform some other work before calling Player.prototype.load. We have observed this produces a race condition when you attempt to load content while content is currently being played. Since load also calls unload, it is possible for the player to get into a state where both this.mediaSource_ and this.mediaSourceOpen_ are null, but the loading process is allowed to proceed. This is because when load calls unload, which in turn calls resetStreaming_ it observes that nothing is being played and simply returns Promise.resolve().

I believe we exclusively see this problem with protected content. I was able to produce it in the Shaka demo app with this content:

  • Sintel 4k (multicode, Widevine)
  • Tears of Steel (Widevine)

Simply add a call to unload before load in shakaDemo.load:

player.unload();
// Load the manifest.
player.load(asset.manifestUri).then(function() {
...

Steps to reproduce in the demo app (with the above change):

  • Select content for playback
  • Press Load
  • Observe video is playing
  • Press Load again

Observed behaviour: Assertion failed, and Cannot read property 'readyState' of null. (The MediaSource object being passed into the MediaSourceEngine constructor is null.)

Expected behaviour: Player should load video normally.

The proposed fix is to store the unloading process on the player as a Promise. When unload is called, check if the player is already unloading. If so, do not initiate a new unloading process, but instead continue with the existing one.

I have submitted PR #613

I wrote a test in the player_integration suite which correctly fails, though it is not included in the PR. Truthfully, I am not aware of the prevailing wisdom around testing for race conditions, and at any rate the test would need some more work before being included.

The PR is accepted by the compiler, however it nukes a few player_unit tests. I am unsure about how to proceed with regard to these now-failing tests and am open to feedback/suggestions.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
joeyparrishcommented, Jan 9, 2017

The fix for this has just been released in v2.0.3.

0reactions
joeyparrishcommented, Dec 19, 2016

I take it back. I kept toying with it, and after several tries it finally blew up. For me, it fails if I select “Dig the Uke”, click “Load”, wait a second or two, then click “Load” again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling Player#unload followed by Player#load allows loading ...
mediaSourceOpen_ are null , but the loading process is allowed to proceed. This is because when load calls unload , which in turn...
Read more >
What is Player Load? - Catapult Support
It is a volume measure. The number itself is an arbitrary unit, meaning it is to be used as a scaling factor to...
Read more >
Understanding Player Load: Meanings and Limitations - PMC
We concluded that a deeper discussion of Player Load as a descriptor of external load is warranted in the sports sciences literature. Key...
Read more >
Adding GPS Player Load to Your Monitoring Protocols
The Titan Sports System defines GPS load as “a scoring value accounting for the intensity and duration of effort based on GPS readings....
Read more >
Assessing the External Load Associated With High-Intensity ...
Load monitoring in basketball is fundamental to develop training programs, maximizing performance while reducing injury risk.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found