Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions lib/web_ui/lib/src/engine/browser_detection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,29 +212,26 @@ bool get isIOS15 {
/// rendering to be flipped upside down.
// TODO(harryterkelsen): Remove this check once we stop supporting Chrome 110
// and earlier, https://github.com/flutter/flutter/issues/139186.
bool get isChrome110OrOlderOnWindows {
if (debugIsChrome110OrOlderOnWindows != null) {
return debugIsChrome110OrOlderOnWindows!;
bool get isChrome110OrOlder {
if (debugIsChrome110OrOlder != null) {
return debugIsChrome110OrOlder!;
}
if (_cachedIsChrome110OrOlderOnWindows != null) {
return _cachedIsChrome110OrOlderOnWindows!;
}
if (operatingSystem != OperatingSystem.windows) {
return _cachedIsChrome110OrOlderOnWindows = false;
if (_cachedIsChrome110OrOlder != null) {
return _cachedIsChrome110OrOlder!;
}
final RegExp chromeRegexp = RegExp(r'Chrom(e|ium)\/([0-9]+)\.');
final RegExpMatch? match =
chromeRegexp.firstMatch(domWindow.navigator.userAgent);
if (match != null) {
final int chromeVersion = int.parse(match.group(2)!);
return _cachedIsChrome110OrOlderOnWindows = chromeVersion <= 110;
return _cachedIsChrome110OrOlder = chromeVersion <= 110;
}
return _cachedIsChrome110OrOlderOnWindows = false;
return _cachedIsChrome110OrOlder = false;
}

// Cache the result of checking if the app is running on Chrome 110 on Windows
// since we check this on every frame.
bool? _cachedIsChrome110OrOlderOnWindows;
bool? _cachedIsChrome110OrOlder;

/// If set to true pretends that the current browser is iOS Safari.
///
Expand Down Expand Up @@ -267,7 +264,7 @@ bool get isWasm => const bool.fromEnvironment('dart.library.ffi');
bool? debugIsIOS15;

/// Use in tests to simulated the detection of Chrome 110 or older on Windows.
bool? debugIsChrome110OrOlderOnWindows;
bool? debugIsChrome110OrOlder;

int? _cachedWebGLVersion;

Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/dom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3674,7 +3674,7 @@ bool debugDisableCreateImageBitmapSupport = false;

bool get browserSupportsCreateImageBitmap =>
_createImageBitmapFunction != null &&
!isChrome110OrOlderOnWindows &&
!isChrome110OrOlder &&
!debugDisableCreateImageBitmapSupport;

@JS()
Expand Down
4 changes: 2 additions & 2 deletions lib/web_ui/test/canvaskit/no_create_image_bitmap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void testMain() {

tearDown(() {
debugDisableCreateImageBitmapSupport = false;
debugIsChrome110OrOlderOnWindows = null;
debugIsChrome110OrOlder = null;
});

test('can render without createImageBitmap', () async {
Expand Down Expand Up @@ -69,7 +69,7 @@ void testMain() {
test(
'createImageBitmap support is disabled on '
'Windows on Chrome version 110 or older', () async {
debugIsChrome110OrOlderOnWindows = true;
debugIsChrome110OrOlder = true;
debugDisableCreateImageBitmapSupport = false;

expect(browserSupportsCreateImageBitmap, isFalse);
Expand Down