Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ab77461

Browse files
[canvaskit] Revert to drawImage rendering on Chrome 110 or earlier (#48515)
This updates a fix for Chrome 110 and earlier to always activate, not just on Windows. Fixes flutter/flutter#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
1 parent 0880b3d commit ab77461

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

lib/web_ui/lib/src/engine/browser_detection.dart

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,35 +206,33 @@ bool get isIOS15 {
206206
domWindow.navigator.userAgent.contains('OS 15_');
207207
}
208208

209-
/// Detect if running on Chrome version 110 or older on Windows.
209+
/// Detect if running on Chrome version 110 or older.
210210
///
211-
/// These versions of Chrome have a bug on Windows which causes
212-
/// rendering to be flipped upside down.
211+
/// These versions of Chrome have a bug which causes rendering to be flipped
212+
/// upside down when using `createImageBitmap`: see
213+
/// https://chromium.googlesource.com/chromium/src/+/a7f9b00e422a1755918f8ca5500380f98b6fddf2
213214
// TODO(harryterkelsen): Remove this check once we stop supporting Chrome 110
214215
// and earlier, https://github.com/flutter/flutter/issues/139186.
215-
bool get isChrome110OrOlderOnWindows {
216-
if (debugIsChrome110OrOlderOnWindows != null) {
217-
return debugIsChrome110OrOlderOnWindows!;
216+
bool get isChrome110OrOlder {
217+
if (debugIsChrome110OrOlder != null) {
218+
return debugIsChrome110OrOlder!;
218219
}
219-
if (_cachedIsChrome110OrOlderOnWindows != null) {
220-
return _cachedIsChrome110OrOlderOnWindows!;
221-
}
222-
if (operatingSystem != OperatingSystem.windows) {
223-
return _cachedIsChrome110OrOlderOnWindows = false;
220+
if (_cachedIsChrome110OrOlder != null) {
221+
return _cachedIsChrome110OrOlder!;
224222
}
225223
final RegExp chromeRegexp = RegExp(r'Chrom(e|ium)\/([0-9]+)\.');
226224
final RegExpMatch? match =
227225
chromeRegexp.firstMatch(domWindow.navigator.userAgent);
228226
if (match != null) {
229227
final int chromeVersion = int.parse(match.group(2)!);
230-
return _cachedIsChrome110OrOlderOnWindows = chromeVersion <= 110;
228+
return _cachedIsChrome110OrOlder = chromeVersion <= 110;
231229
}
232-
return _cachedIsChrome110OrOlderOnWindows = false;
230+
return _cachedIsChrome110OrOlder = false;
233231
}
234232

235233
// Cache the result of checking if the app is running on Chrome 110 on Windows
236234
// since we check this on every frame.
237-
bool? _cachedIsChrome110OrOlderOnWindows;
235+
bool? _cachedIsChrome110OrOlder;
238236

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

269267
/// Use in tests to simulated the detection of Chrome 110 or older on Windows.
270-
bool? debugIsChrome110OrOlderOnWindows;
268+
bool? debugIsChrome110OrOlder;
271269

272270
int? _cachedWebGLVersion;
273271

lib/web_ui/lib/src/engine/dom.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3674,7 +3674,7 @@ bool debugDisableCreateImageBitmapSupport = false;
36743674

36753675
bool get browserSupportsCreateImageBitmap =>
36763676
_createImageBitmapFunction != null &&
3677-
!isChrome110OrOlderOnWindows &&
3677+
!isChrome110OrOlder &&
36783678
!debugDisableCreateImageBitmapSupport;
36793679

36803680
@JS()

lib/web_ui/test/canvaskit/no_create_image_bitmap_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void testMain() {
2424

2525
tearDown(() {
2626
debugDisableCreateImageBitmapSupport = false;
27-
debugIsChrome110OrOlderOnWindows = null;
27+
debugIsChrome110OrOlder = null;
2828
});
2929

3030
test('can render without createImageBitmap', () async {
@@ -69,7 +69,7 @@ void testMain() {
6969
test(
7070
'createImageBitmap support is disabled on '
7171
'Windows on Chrome version 110 or older', () async {
72-
debugIsChrome110OrOlderOnWindows = true;
72+
debugIsChrome110OrOlder = true;
7373
debugDisableCreateImageBitmapSupport = false;
7474

7575
expect(browserSupportsCreateImageBitmap, isFalse);

0 commit comments

Comments
 (0)