[canvaskit] Revert to drawImage rendering on Chrome 110 or earlier (flutter/engine#48515)

This updates a fix for Chrome 110 and earlier to always activate, not
just on Windows.

Fixes https://github.com/flutter/flutter/issues/138827

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
This commit is contained in:
Harry Terkelsen 2023-11-30 12:41:23 -08:00 committed by GitHub
parent 767eee79a7
commit 9b26cdc88c
3 changed files with 16 additions and 18 deletions

View File

@ -206,35 +206,33 @@ bool get isIOS15 {
domWindow.navigator.userAgent.contains('OS 15_');
}
/// Detect if running on Chrome version 110 or older on Windows.
/// Detect if running on Chrome version 110 or older.
///
/// These versions of Chrome have a bug on Windows which causes
/// rendering to be flipped upside down.
/// These versions of Chrome have a bug which causes rendering to be flipped
/// upside down when using `createImageBitmap`: see
/// https://chromium.googlesource.com/chromium/src/+/a7f9b00e422a1755918f8ca5500380f98b6fddf2
// 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.
///
@ -267,7 +265,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;

View File

@ -3674,7 +3674,7 @@ bool debugDisableCreateImageBitmapSupport = false;
bool get browserSupportsCreateImageBitmap =>
_createImageBitmapFunction != null &&
!isChrome110OrOlderOnWindows &&
!isChrome110OrOlder &&
!debugDisableCreateImageBitmapSupport;
@JS()

View File

@ -24,7 +24,7 @@ void testMain() {
tearDown(() {
debugDisableCreateImageBitmapSupport = false;
debugIsChrome110OrOlderOnWindows = null;
debugIsChrome110OrOlder = null;
});
test('can render without createImageBitmap', () async {
@ -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);