Skip to content

Commit

Permalink
fix(hls): Fix type error in lazy-loading (#4687)
Browse files Browse the repository at this point in the history
There was a potential type error in an edge case in lib/player.js. It
would have been caught by the latest compiler, so this upgrades the
compiler and fixes another type error in one other place, as well.
  • Loading branch information
joeyparrish authored Nov 11, 2022
1 parent 7af357c commit 28b73b9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 29 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ jobs:
# Install a launcher that can execute a shell script to launch this
npm install karma-script-launcher --save-dev
# Some CI images (self-hosted or otherwise) don't have the minimum Java
# version necessary for the compiler (Java 11).
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11

- name: Build Player
run: python build/all.py

Expand Down
8 changes: 4 additions & 4 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2160,15 +2160,15 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
// Unless the user has already picked a variant, anyway, by calling
// selectVariantTrack before this loading stage.
let initialVariant = null;
const activeVariantTrack = this.getVariantTracks().find((t) => t.active);
if (!activeVariantTrack) {
const activeVariant = this.streamingEngine_.getCurrentVariant();
if (!activeVariant) {
initialVariant = this.chooseVariant_();
goog.asserts.assert(initialVariant, 'Must choose an initial variant!');
}

// Lazy-load the stream, so we will have enough info to make the playhead.
const createSegmentIndexPromises = [];
const toLazyLoad = activeVariantTrack || initialVariant;
const toLazyLoad = activeVariant || initialVariant;
for (const stream of [toLazyLoad.video, toLazyLoad.audio]) {
if (stream && !stream.segmentIndex) {
createSegmentIndexPromises.push(stream.createSegmentIndex());
Expand All @@ -2189,7 +2189,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
this.startBufferManagement_(rebufferThreshold);

// Now we can switch to the initial variant.
if (!activeVariantTrack) {
if (!activeVariant) {
goog.asserts.assert(initialVariant,
'Must have choosen an initial variant!');

Expand Down
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"eslint-plugin-shaka-rules": "file:./build/eslint-plugin-shaka-rules",
"esprima": "^4.0.1",
"fontfaceonload": "^1.0.2",
"google-closure-compiler-java": "^20220301.0.0",
"google-closure-deps": "https://gitpkg.now.sh/google/closure-library/closure-deps?d7736da6",
"google-closure-library": "^20220301.0.0",
"google-closure-compiler-java": "^20221102.0.0",
"google-closure-deps": "^20221102.0.0",
"google-closure-library": "^20221102.0.0",
"htmlhint": "^1.1.3",
"jasmine-ajax": "^4.0.0",
"jimp": "^0.16.1",
Expand Down
2 changes: 1 addition & 1 deletion third_party/closure-uri/uri.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ goog.Uri.QueryData.prototype.add = function(key, value) {
// Invalidate the cache.
this.encodedQuery_ = null;

var values = this.keyMap_.hasOwnProperty(key) && this.keyMap_[key];
var values = this.keyMap_.hasOwnProperty(key) ? this.keyMap_[key] : null;
if (!values) {
this.keyMap_[key] = (values = []);
}
Expand Down

0 comments on commit 28b73b9

Please sign in to comment.