Skip to content

Commit

Permalink
Work around MSE rounding errors in Edge
Browse files Browse the repository at this point in the history
Edge bug: https://goo.gl/3ZTzse

Issue #1281

Change-Id: I03fcef7d52afc3a15b7cd7c4b873bff774087f82
  • Loading branch information
joeyparrish committed Mar 1, 2018
1 parent 1f1c05f commit 8262d7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,13 @@ shaka.media.MediaSourceEngine.prototype.flush_ = function(contentType) {
*/
shaka.media.MediaSourceEngine.prototype.setTimestampOffset_ =
function(contentType, timestampOffset) {
// Work around for https://github.com/google/shaka-player/issues/1281:
// TODO(https://goo.gl/3ZTzse): follow up when this is fixed in Edge
if (timestampOffset < 0) {
// Try to prevent rounding errors in Edge from removing the first keyframe.
timestampOffset += 0.001;
}

this.sourceBuffers_[contentType].timestampOffset = timestampOffset;

// Fake 'updateend' event to resolve the operation.
Expand Down
6 changes: 5 additions & 1 deletion lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,14 @@ shaka.media.StreamingEngine.MediaState_;
* The fudge factor for the appendWindowStart. By adjusting the window
* backward, we avoid rounding errors that could cause us to remove the keyframe
* at the start of the Period.
*
* NOTE: This was increased as part of the solution to
* https://github.com/google/shaka-player/issues/1281
*
* @const {number}
* @private
*/
shaka.media.StreamingEngine.APPEND_WINDOW_START_FUDGE_ = 0.00001;
shaka.media.StreamingEngine.APPEND_WINDOW_START_FUDGE_ = 0.1;


/** @override */
Expand Down
2 changes: 1 addition & 1 deletion test/media/streaming_engine_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ describe('StreamingEngine', function() {
// 20, but reduced by a small fudge factor.
let lt20 = {
asymmetricMatch: function(val) {
return val > 19.9 && val < 20;
return val >= 19.9 && val < 20;
}
};
expect(mediaSourceEngine.setStreamProperties)
Expand Down

0 comments on commit 8262d7a

Please sign in to comment.