Skip to content

Commit

Permalink
fix: low-resolution screen sharing for safari 17. (#387)
Browse files Browse the repository at this point in the history
* fix: low-resolution screen sharing for safari 17.

* update.
  • Loading branch information
cloudwebrtc authored Oct 18, 2023
1 parent 401cb2e commit 42f4132
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/src/support/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ bool lkPlatformIsTest() => Platform.environment.containsKey('FLUTTER_TEST');

BrowserType lkBrowser() => lkBrowserImplementation();

BrowserVersion lkBrowserVersion() => lkBrowserVersionImplementation();

enum PlatformType {
web,
windows,
Expand All @@ -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;
}
4 changes: 4 additions & 0 deletions lib/src/support/platform/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ bool lkE2EESupportedImplementation() {
BrowserType lkBrowserImplementation() {
return BrowserType.unknown;
}

BrowserVersion lkBrowserVersionImplementation() {
return const BrowserVersion(0, 0, 0);
}
3 changes: 3 additions & 0 deletions lib/src/support/platform/web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
7 changes: 7 additions & 0 deletions lib/src/track/local/local.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ abstract class LocalTrack extends Track {
if (options.selfBrowserSurface != null) {
constraints['selfBrowserSurface'] = options.selfBrowserSurface!;
}

// 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;
}
}
stream = await rtc.navigator.mediaDevices.getDisplayMedia(constraints);
} else {
Expand Down

0 comments on commit 42f4132

Please sign in to comment.