perf: Disable ContentWorkarounds on Safari >=26.4 (#10204)

Since this version we don't need to fake encryption on audio segments.
This commit is contained in:
Wojciech Tyczyński
2026-06-11 12:39:19 +02:00
committed by GitHub
parent a92699fe4d
commit 697816d3d9
+28 -16
View File
@@ -19,23 +19,20 @@ shaka.device.AppleBrowser = class extends shaka.device.AbstractDevice {
constructor() {
super();
/** @private {!shaka.util.Lazy<?number>} */
/** @private {!shaka.util.Lazy<!Array<number>>} */
this.version_ = new shaka.util.Lazy(() => {
// This works for iOS Safari and desktop Safari, which contain something
// like "Version/13.0" indicating the major Safari or iOS version.
let match = navigator.userAgent.match(/Version\/(\d+)/);
if (match) {
return parseInt(match[1], /* base= */ 10);
// like "Version/13.0" indicating the major.minor Safari or iOS version.
let match = navigator.userAgent.match(/Version\/(\d+)(?:\.(\d+))?/);
if (!match) {
// This works for all other browsers on iOS, which contain something
// like "OS 13_3" indicating the major & minor iOS version.
match = navigator.userAgent.match(/OS (\d+)(?:_(\d+))?/);
}
// This works for all other browsers on iOS, which contain something like
// "OS 13_3" indicating the major & minor iOS version.
match = navigator.userAgent.match(/OS (\d+)(?:_\d+)?/);
if (match) {
return parseInt(match[1], /* base= */ 10);
return [parseInt(match[1], 10), parseInt(match[2] || '0', 10)];
}
return null;
return [0, 0];
});
/** @private {!shaka.util.Lazy<!shaka.device.IDevice.DeviceType>} */
@@ -58,7 +55,7 @@ shaka.device.AppleBrowser = class extends shaka.device.AbstractDevice {
* @override
*/
getVersion() {
return this.version_.value();
return this.version_.value()[0];
}
/**
@@ -93,21 +90,23 @@ shaka.device.AppleBrowser = class extends shaka.device.AbstractDevice {
* @override
*/
requiresEncryptionInfoInAllInitSegments(keySystem, contentType) {
return contentType === 'audio';
return !this.supportsMixedClearEncryptedContent_() &&
contentType === 'audio';
}
/**
* @override
*/
insertEncryptionDataBeforeClear() {
return true;
return !this.supportsMixedClearEncryptedContent_();
}
/**
* @override
*/
requiresTfhdFix(contentType) {
return contentType === 'audio';
return !this.supportsMixedClearEncryptedContent_() &&
contentType === 'audio';
}
/**
@@ -133,6 +132,19 @@ shaka.device.AppleBrowser = class extends shaka.device.AbstractDevice {
return false;
}
/**
* Apple has fixed the mixed clear/encrypted content issue in Safari 26.4
* @return {boolean}
* @private
*/
supportsMixedClearEncryptedContent_() {
const version = this.version_.value();
if (version[0] >= 27) {
return true;
}
return version[0] === 26 && version[1] >= 4;
}
/**
* @return {boolean}
* @private