Skip to content

Commit

Permalink
perf(live-tracker): disable live tracker on IE11 when document is hid…
Browse files Browse the repository at this point in the history
…den (#5896)

Disable the live tracker on IE11 when the document is hidden to fix the slow down and eventual crashing of web pages on IE11.

After #5879 was completed, we noticed that live streams still have an issue. This is because the live tracker we have also uses setInterval. Unfortunately, just disabling setInterval in the live tracker was not enough. Instead, we decided the best course of action is to just disable the live tracker altogether.
  • Loading branch information
brandonocasey authored and gkatsev committed Mar 28, 2019
1 parent 6c644fe commit 511f729
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/js/live-tracker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Component from './component.js';
import mergeOptions from './utils/merge-options.js';
import document from 'global/document';
import * as browser from './utils/browser.js';

/* track when we are at the live edge, and other helpers for live playback */
class LiveTracker extends Component {
Expand All @@ -13,6 +15,25 @@ class LiveTracker extends Component {
this.reset_();

this.on(this.player_, 'durationchange', this.handleDurationchange);

// we don't need to track live playback if the document is hidden,
// also, tracking when the document is hidden can
// cause the CPU to spike and eventually crash the page on IE11.
if (browser.IE_VERSION && 'hidden' in document && 'visibilityState' in document) {
this.on(document, 'visibilitychange', this.handleVisibilityChange);
}
}

handleVisibilityChange() {
if (this.player_.duration() !== Infinity) {
return;
}

if (document.hidden) {
this.stopTracking();
} else {
this.startTracking();
}
}

isBehind_() {
Expand Down

0 comments on commit 511f729

Please sign in to comment.