From 4ca6cd58b73dea09b0ad1be789400be953d3f059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Tyczy=C5=84ski?= Date: Wed, 20 Nov 2024 10:41:14 +0100 Subject: [PATCH] fix: Disable smooth codec switch on webOS 6 (#7636) In our preliminary tests webOS 6 does not support smooth codec switch, but webOS 22 (so the next one) does, so hopefully this will be the last adjustment in this method. --- lib/util/platform.js | 15 ++++++++++++++- test/util/platform_unit.js | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/util/platform.js b/lib/util/platform.js index ba4a7ce8a7..f438396879 100644 --- a/lib/util/platform.js +++ b/lib/util/platform.js @@ -205,6 +205,17 @@ shaka.util.Platform = class { shaka.util.Platform.chromeVersion() === 68; } + /** + * Check if the current platform is a WebOS 6. + * + * @return {boolean} + */ + static isWebOS6() { + // See: https://webostv.developer.lge.com/develop/specifications/web-api-and-web-engine#useragent-string + return shaka.util.Platform.isWebOS() && + shaka.util.Platform.chromeVersion() === 79; + } + /** * Check if the current platform is a Google Chromecast. * @@ -637,7 +648,9 @@ shaka.util.Platform = class { static supportsSmoothCodecSwitching() { const Platform = shaka.util.Platform; // All Tizen versions (up to Tizen 8) do not support SMOOTH so far. - if (Platform.isTizen() || Platform.isPS4() || Platform.isPS5()) { + // webOS seems to support SMOOTH from webOS 22. + if (Platform.isTizen() || Platform.isPS4() || Platform.isPS5() || + Platform.isWebOS6()) { return false; } // Older chromecasts without GoogleTV seem to not support SMOOTH properly. diff --git a/test/util/platform_unit.js b/test/util/platform_unit.js index 1020b26e56..c8614ce8af 100644 --- a/test/util/platform_unit.js +++ b/test/util/platform_unit.js @@ -19,6 +19,7 @@ describe('Platform', () => { const webOs3 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.2.1 Chrome/38.0.2125.122 Safari/537.36 WebAppManager'; const webOs4 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.34 Safari/537.36 WebAppManager'; const webOs5 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 WebAppManager'; + const webOs6 = 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36 WebAppManager'; /* eslint-enable max-len */ afterEach(() => { @@ -79,6 +80,8 @@ describe('Platform', () => { expect(shaka.util.Platform.isWebOS3()).toBe(false); setUserAgent(webOs5); expect(shaka.util.Platform.isWebOS3()).toBe(false); + setUserAgent(webOs6); + expect(shaka.util.Platform.isWebOS3()).toBe(false); }); it('checks is webOS 4', () => { @@ -90,6 +93,8 @@ describe('Platform', () => { expect(shaka.util.Platform.isWebOS4()).toBe(true); setUserAgent(webOs5); expect(shaka.util.Platform.isWebOS4()).toBe(false); + setUserAgent(webOs6); + expect(shaka.util.Platform.isWebOS4()).toBe(false); }); it('checks is webOS 5', () => { @@ -101,6 +106,21 @@ describe('Platform', () => { expect(shaka.util.Platform.isWebOS5()).toBe(false); setUserAgent(webOs5); expect(shaka.util.Platform.isWebOS5()).toBe(true); + setUserAgent(webOs6); + expect(shaka.util.Platform.isWebOS5()).toBe(false); + }); + + it('checks is webOS 6', () => { + setUserAgent(tizen50); + expect(shaka.util.Platform.isWebOS6()).toBe(false); + setUserAgent(webOs3); + expect(shaka.util.Platform.isWebOS6()).toBe(false); + setUserAgent(webOs4); + expect(shaka.util.Platform.isWebOS6()).toBe(false); + setUserAgent(webOs5); + expect(shaka.util.Platform.isWebOS6()).toBe(false); + setUserAgent(webOs6); + expect(shaka.util.Platform.isWebOS6()).toBe(true); }); describe('isMediaKeysPolyfilled', () => {