From 165c942d3280eab321a08586ca76d382a6a285cc Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Tue, 17 Oct 2023 11:29:03 +0800 Subject: [PATCH 1/2] fix: low-resolution screen sharing for safari 17. --- lib/src/support/platform.dart | 15 +++++++++++++++ lib/src/support/platform/io.dart | 4 ++++ lib/src/support/platform/web.dart | 3 +++ lib/src/track/local/local.dart | 8 ++++++++ 4 files changed, 30 insertions(+) diff --git a/lib/src/support/platform.dart b/lib/src/support/platform.dart index ebf552583..979924f04 100644 --- a/lib/src/support/platform.dart +++ b/lib/src/support/platform.dart @@ -36,6 +36,8 @@ bool lkPlatformIsTest() => Platform.environment.containsKey('FLUTTER_TEST'); BrowserType lkBrowser() => lkBrowserImplementation(); +BrowserVersion lkBrowserVersion() => lkBrowserVersionImplementation(); + enum PlatformType { web, windows, @@ -54,3 +56,16 @@ enum BrowserType { wkWebView, unknown, } + +class BrowserVersion { + const BrowserVersion(this.major, this.minor, this.patch); + + /// The major version number: "1" in "1.2.3". + final int major; + + /// The minor version number: "2" in "1.2.3". + final int minor; + + /// The patch version number: "3" in "1.2.3". + final int patch; +} diff --git a/lib/src/support/platform/io.dart b/lib/src/support/platform/io.dart index fcf25ffe2..f06e7dca1 100644 --- a/lib/src/support/platform/io.dart +++ b/lib/src/support/platform/io.dart @@ -39,3 +39,7 @@ bool lkE2EESupportedImplementation() { BrowserType lkBrowserImplementation() { return BrowserType.unknown; } + +BrowserVersion lkBrowserVersionImplementation() { + return const BrowserVersion(0, 0, 0); +} diff --git a/lib/src/support/platform/web.dart b/lib/src/support/platform/web.dart index 06bd7378a..e50a904a8 100644 --- a/lib/src/support/platform/web.dart +++ b/lib/src/support/platform/web.dart @@ -41,3 +41,6 @@ BrowserType lkBrowserImplementation() { if (browser.isWKWebView) return BrowserType.wkWebView; return BrowserType.unknown; } + +BrowserVersion lkBrowserVersionImplementation() => BrowserVersion( + browser.version.major, browser.version.minor, browser.version.patch); diff --git a/lib/src/track/local/local.dart b/lib/src/track/local/local.dart index b469ea36e..5bad923b3 100644 --- a/lib/src/track/local/local.dart +++ b/lib/src/track/local/local.dart @@ -154,6 +154,14 @@ abstract class LocalTrack extends Track { if (options.selfBrowserSurface != null) { constraints['selfBrowserSurface'] = options.selfBrowserSurface!; } + + // Remove resolution settings to avoid capturing low-resolution screen sharing + // streams in Safari 17. + // related bug for safari 17: https://bugs.webkit.org/show_bug.cgi?id=263015 + if (lkBrowser() == BrowserType.safari && + lkBrowserVersion().major == 17) { + constraints['video'] = true; + } } stream = await rtc.navigator.mediaDevices.getDisplayMedia(constraints); } else { From 5345f3bed49da5d4636ea315b54ef34d953d2b63 Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Tue, 17 Oct 2023 11:43:44 +0800 Subject: [PATCH 2/2] update. --- lib/src/track/local/local.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/src/track/local/local.dart b/lib/src/track/local/local.dart index 5bad923b3..f8df8625d 100644 --- a/lib/src/track/local/local.dart +++ b/lib/src/track/local/local.dart @@ -155,9 +155,8 @@ abstract class LocalTrack extends Track { constraints['selfBrowserSurface'] = options.selfBrowserSurface!; } - // Remove resolution settings to avoid capturing low-resolution screen sharing - // streams in Safari 17. - // related bug for safari 17: https://bugs.webkit.org/show_bug.cgi?id=263015 + // Remove resolution settings to fix low-resolution screen share on Safari 17. + // related bug: https://bugs.webkit.org/show_bug.cgi?id=263015 if (lkBrowser() == BrowserType.safari && lkBrowserVersion().major == 17) { constraints['video'] = true;