-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Remove image codecs from Canvaskit Chromium #40309
Conversation
| bool _defaultBrowserSupportsImageDecoder = | ||
| _browserImageDecodingEnabled && | ||
| _imageDecoderConstructor != null && | ||
| browserEngine == BrowserEngine.blink; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yjbanov I made this change to make sure we always reset it to the correct default (it looks like at some point things got out of sync).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not too much trouble, can you please move the browserEngine == BrowserEngine.blink into a constant with a TODO and a Github issue, something like this:
// TODO(yjbanov): $LINK_TO_GITHUB_ISSUE
// Frequently when a browser launches an API that other browsers already support
// there are subtle incompatibilities that may cause apps to crash if we blindly
// adopt the new implementation. This variable prevents us from picking up potentially
// incompatible implementations of ImagdeDecoder API. Instead, when a new browser
// engine launches the API, we'll evaluate it and enable it explicitly.
final bool _kProtectFromImageDecoderIncompatibilities = browserEngine == BrowserEngine.blink;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice if we differentiated between _browserImageDecodingEnabled explicitly being set and defaulting to true. That way, if it is explicitly set, it can override the browserEngine == BrowserEngine.blink, so that it is easy to test against browsers that have implemented the ImageDecoder API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eyebrowsoffire are you talking about overriding for tests or apps?
In tests, we already do override it e.g:
engine/lib/web_ui/test/canvaskit/image_golden_test.dart
Lines 64 to 79 in 7a4542c
| group('($mode)', () { | |
| setUp(() { | |
| browserSupportsImageDecoder = useBrowserImageDecoder; | |
| warnings.clear(); | |
| }); | |
| setUpAll(() { | |
| oldPrintWarning = printWarning; | |
| printWarning = (String warning) { | |
| warnings.add(warning); | |
| }; | |
| }); | |
| tearDown(() { | |
| debugResetBrowserSupportsImageDecoder(); | |
| }); |
As for apps, do we really want users to play with this? Whoever wants to test this in different browsers likely already knows how to modify and build the engine, so they can just change the boolean value in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant in apps. If we wanted to test the viability of this in a browser, I'd much rather just be able to pass in a flag and try out a bunch of different apps than to rebuild the engine entirely. If a user stumbles upon the flag and misuses it, it's not the end of the world IMO. Let's just document this as well as we can, and if a user files a bug saying "I turned this flag on and it doesn't work" then we just say "don't do that" and close the bug and move on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, adding an ability to force a specific mode when building using the Flutter Tool SGTM. If we add such a thing, consider adding it somewhere in the configuration.dart file, so we don't have options like that scattered across the codebase.
third_party/canvaskit/BUILD.gn
Outdated
| skia_use_client_icu = true | ||
| skia_icu_bidi_third_party_dir = "//flutter/third_party/canvaskit/icu_bidi" | ||
|
|
||
| # Remove image codecs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would instead explain that in Chromium we use ImageDecoder instead of the wasm codecs.
| gn_args['skia_use_libjpeg_turbo_decode'] = True | ||
| gn_args['skia_use_libjpeg_turbo_encode'] = False | ||
| gn_args['skia_use_libpng_decode'] = True | ||
| gn_args['skia_use_libpng_encode'] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please file an issue to remove this as well? We can implement this by piping the image through a 2D canvas.
eyebrowsoffire
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! One nitpick.
| // picking up potentially incompatible implementations of ImagdeDecoder API. | ||
| // Instead, when a new browser engine launches the API, we'll evaluate it and | ||
| // enable it explicitly. | ||
| bool get _kProtectFromImageDecoderIncompatibilities => browserEngine == BrowserEngine.blink; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complete nitpick, but I don't like the name of this variable. On its face, the name seems to imply the opposite of what it does. If something called ProtectFromImageDecoderIncompatibilities is true, I would think that means that you are protecting from incompatibilities, and if it's false, I would think you would not be protecting from incompatibilities. In general, either way, the name is a bit confusing as a name of a boolean. Might I suggest something like _kImageDecoderIsStable or _kImageDecoderIsBlessed or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I also removed the k prefix since these are getters and not consts anymore.
…122942) * e6334f166 [web] Remove image codecs from Canvaskit Chromium (flutter/engine#40309) * 56727d62c Revert "[Impeller] mark decoded images as optimized for GPU access (#40356)" (flutter/engine#40387) * 2cd19e3d1 Wrap the iOS platform message handler in an autorelease pool block (flutter/engine#40373) * bab7853ad Update analyzer for api_conform_test (flutter/engine#40386) * 87b2e82d1 Roll Fuchsia Mac SDK from z32cF6YFs6CvZbY3g... to 4ZrEK2uzGdp_Gz3DU... (flutter/engine#40385) * fc57995fe Ignore some MTLCompiler failures in impeller unit tests (flutter/engine#40391) * 2398c5222 Add doc comment to Pipeline (flutter/engine#40388) * f585d4bc5 [macOS] Remove a single accessibility root assumption (flutter/engine#40316) * 940cf3c98 remove temporary flag and make FlutterTest the default font for real (flutter/engine#40352) * a1bf9fd2a drawTextBlob should not be compatible with opacity inheritance (flutter/engine#40396) * 55bf0d85e Use bundled analyzer everywhere (flutter/engine#40398) * 8e580414a Roll Skia from 9bfb45d3e065 to 49b902e5fb91 (11 revisions) (flutter/engine#40397) * 77c53d25e Default the CanvasKit base URL to local artifacts. (flutter/engine#40293) * 625ea5395 Roll Skia from 49b902e5fb91 to aa983f5486f0 (7 revisions) (flutter/engine#40404) * 867679fac [Impeller] Add playground flag to render for a specific amount of time. (flutter/engine#40377) * d74169608 [Impeller] Remove unused bounds method from typographer interface (flutter/engine#40406) * 941323d77 Provisional iOS impeller flag flip (flutter/engine#40405) * bb971ab55 Revert "Default the CanvasKit base URL to local artifacts. (#40293)" (flutter/engine#40415)
Size difference of CanvasKit Chromium:
Ran the flutter gallery locally with this change. Visited many pages that contain images and text. Everything looks normal.
Closes flutter/flutter#122331