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

Conversation

@mdebbar
Copy link
Contributor

@mdebbar mdebbar commented Mar 15, 2023

Size difference of CanvasKit Chromium:

Before After Delta
Gzip -9 1.489 MB 1.406 MB 85 KB
Brotli -9 1.332 MB 1.256 MB 78 KB

Ran the flutter gallery locally with this change. Visited many pages that contain images and text. Everything looks normal.

Closes flutter/flutter#122331

@mdebbar mdebbar requested a review from yjbanov March 15, 2023 21:35
@mdebbar mdebbar marked this pull request as ready for review March 15, 2023 21:35
Comment on lines 227 to 230
bool _defaultBrowserSupportsImageDecoder =
_browserImageDecodingEnabled &&
_imageDecoderConstructor != null &&
browserEngine == BrowserEngine.blink;
Copy link
Contributor Author

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).

Copy link
Contributor

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;

Copy link
Contributor

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.

Copy link
Contributor Author

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:

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Mar 15, 2023
skia_use_client_icu = true
skia_icu_bidi_third_party_dir = "//flutter/third_party/canvaskit/icu_bidi"

# Remove image codecs.
Copy link
Contributor

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
Copy link
Contributor

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.

@mdebbar mdebbar requested a review from eyebrowsoffire March 17, 2023 13:44
Copy link
Contributor

@eyebrowsoffire eyebrowsoffire left a 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;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 17, 2023
@auto-submit auto-submit bot merged commit e6334f1 into flutter:main Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
zanderso pushed a commit to flutter/flutter that referenced this pull request Mar 18, 2023
…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)
zanderso pushed a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] Remove image codecs from CanvasKit Chromium

3 participants