Skip to content

Commit 7d43ee4

Browse files
authored
fix(HLS): Fix resync issues on Safari (#8808)
Removes duplicated logic around timestamp offset checks - now check is only in `resync()` method. It should stay there, because it ensures it will be executed only in sequence mode and also avoids otherwise unnecessary `abort()` call. Increases threshold to 150 ms as it was the originally proposed value and gives better experience. Now timestamp offset change won't be applied in sequence mode if it's less than 150ms from buffer end, regardless of manifest type.
1 parent 1b2b6b8 commit 7d43ee4

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

lib/media/media_source_engine.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,7 @@ shaka.media.MediaSourceEngine = class {
15511551
// Avoid changing timestampOffset when the difference is less than 100 ms
15521552
// from the end of the current buffer.
15531553
const bufferEnd = this.bufferEnd(contentType);
1554-
if (bufferEnd && Math.abs(bufferEnd - timestampOffset) < 0.1) {
1554+
if (bufferEnd && Math.abs(bufferEnd - timestampOffset) < 0.15) {
15551555
return;
15561556
}
15571557

@@ -1807,21 +1807,7 @@ shaka.media.MediaSourceEngine = class {
18071807
timestampOffset += 0.001;
18081808
}
18091809

1810-
1811-
let shouldChangeTimestampOffset = true;
1812-
if (this.manifestType_ == shaka.media.ManifestParser.HLS) {
1813-
// Avoid changing timestampOffset when the difference is less than 150 ms
1814-
// from the end of the current buffer when using sequenceMode
1815-
const bufferEnd = this.bufferEnd(contentType);
1816-
if (!bufferEnd || Math.abs(bufferEnd - timestampOffset) > 0.15) {
1817-
shouldChangeTimestampOffset = true;
1818-
} else {
1819-
shouldChangeTimestampOffset = false;
1820-
}
1821-
}
1822-
if (shouldChangeTimestampOffset) {
1823-
this.sourceBuffers_.get(contentType).timestampOffset = timestampOffset;
1824-
}
1810+
this.sourceBuffers_.get(contentType).timestampOffset = timestampOffset;
18251811

18261812
// Fake an 'updateend' event to resolve the operation.
18271813
this.onUpdateEnd_(contentType);

0 commit comments

Comments
 (0)