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

fix: race condition preventing qualityLevels from being populating #707

Merged
merged 6 commits into from
Jan 10, 2020

Conversation

brandonocasey
Copy link
Contributor

@brandonocasey brandonocasey commented Jan 7, 2020

Description

Quality levels is not being populated due to a race condition where the tech is not ready until after we have fired selectedintialmedia. You can get this to happen by in chrome by loading the tab in the background for 10s or by using a slow browser like ie 11, where it will happen in the main tab.

Steps to reproduce

  1. Open index.html
  2. Open the link to Stats in a new page, and wait 10s before switching to that tab.
  3. Note that the qualityLevels do not show up on the page, and player.qualityLevels().levels_ is a 0 length array
  4. Note that player.representations() has the correct representations in the returned array.
  5. Note that the qualityLevels buttons do not show up on the page.

Specific Changes proposed

  1. The first commit deploys the stats page, and fixes a bug with the stats page. That allows this bug to be tested before the fix.
  2. The second commit remove the tech ready wrapper around this.setupQualityLevels_()

Testing

  1. Open the netlify deploy from #708 and follow the steps to reproduce.
  2. Open netlify deploy for this pull request and follow the steps to reproduce, noting that steps 3, 4, and 5 are no longer an issue.

Requirements Checklist

  • Feature implemented / Bug fixed
  • Reviewed by Two Core Contributors

Closes #708
Fixes #677

@brandonocasey brandonocasey changed the title fix: qualityLevels isn't populated in background tabs or slow computers/browsers fix: Prevent a race condition that caused qualityLevels from populating Jan 7, 2020
@brandonocasey brandonocasey changed the title fix: Prevent a race condition that caused qualityLevels from populating fix: Prevent a race condition that prevented qualityLevels from being populating Jan 7, 2020
@brandonocasey brandonocasey changed the title fix: Prevent a race condition that prevented qualityLevels from being populating fix: race condition preventing qualityLevels from being populating Jan 7, 2020
const files = [vjs, vjsCss, eme];

const files = [
'node_modules/video.js/dist/video-js.css',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming files what getting a bit absurd in here

@@ -92,6 +92,9 @@ let renditionSelectionMixin = function(hlsHandler) {

// Add a single API-specific function to the HlsHandler instance
hlsHandler.representations = () => {
if (!playlists || !playlists.master || !playlists.master.playlists) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably return an empty array if we don't have playlists yet, Right now we will just throw an error and some of the tests where failing due to this.

this.qualityLevels_ = player.qualityLevels();
// if there isn't a player or there isn't a qualityLevels plugin
// or qualityLevels_ listeners have already been setup, do nothing.
if (!player || !player.qualityLevels || this.qualityLevels_) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only setup quality levels listeners once, the rest of the code is the same except we return early instead of adding the logic in an if scope.

@@ -20,7 +20,7 @@

<!-- player stats visualization -->
<link href="stats.css" rel="stylesheet">
<script src="/node_modules/d3/d3.min.js"></script>
<script src="../../node_modules/d3/d3.min.js"></script>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have to use local paths to get it to work on netlify.

@@ -345,25 +345,23 @@ <h3>Timed Metadata</h3>
videojs.Hls.displayStats(document.querySelector('.switching-stats'), player);
videojs.Hls.displayCues(document.querySelector('.segment-timeline'), player);

player.ready(function() {
var qualityLevels = player.qualityLevels();
var qualityLevels = player.qualityLevels();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quality levels can exist before tech/player ready

@@ -3094,8 +3094,7 @@ QUnit.test('passes useCueTags hls option to master playlist controller', functio
videojs.options.hls = origHlsOptions;
});

// TODO: This test fails intermittently. Turn on when fixed to always pass.
QUnit.skip('populates quality levels list when available', function(assert) {
QUnit.test('populates quality levels list when available', function(assert) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was previously skipped because of intermittent failures. I think fixing this bug fixes the test.

Copy link
Contributor

@gesinger gesinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment, but looks good, though netlify step failed with "System Error." Maybe jut needs a retry?

@@ -20,5 +22,5 @@ files

// copy over files, dist, and html files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but this comment is out-of-date. May be worth just removing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the comment to make it more relevant

@gkatsev
Copy link
Member

gkatsev commented Jan 8, 2020

This fixes #677 as well.

@gkatsev gkatsev added the tested label Jan 10, 2020
@gkatsev gkatsev merged commit 8c4a11f into 1.x Jan 10, 2020
@gkatsev gkatsev deleted the fix/quality-levels-race branch January 10, 2020 18:42
@gkatsev
Copy link
Member

gkatsev commented Jan 10, 2020

@brandonocasey can you make this change against master as well? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants