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 all commits
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
8 changes: 8 additions & 0 deletions lib/web_ui/dev/steps/compile_tests_step.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ Future<bool> compileUnitTest(FilePath input, { required bool forCanvasKit }) asy
'-DFLUTTER_WEB_AUTO_DETECT=false',
'-DFLUTTER_WEB_USE_SKIA=$forCanvasKit',

// Enable the image decoder experiment in tests so we can test the new
// functionality. WASM decoders are still tested by forcing the value of
// `browserSupportsImageDecoder` to false in the test. See also:
//
// lib/web_ui/test/canvaskit/image_golden_test.dart
// TODO(yjbanov): https://github.com/flutter/flutter/issues/95277
'-DEXPERIMENTAL_IMAGE_DECODER=true',

'-O2',
'-o',
targetFileName, // target path.
Expand Down
11 changes: 10 additions & 1 deletion lib/web_ui/lib/src/engine/safe_browser_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,18 @@ html.CanvasElement? tryCreateCanvasElement(int width, int height) {
@JS('window.ImageDecoder')
external Object? get _imageDecoderConstructor;

/// Hides `image_web_codecs.dart` behind a flag.
// TODO(yjbanov): https://github.com/flutter/flutter/issues/95277
const bool _imageDecoderExperimentEnabled = bool.fromEnvironment(
'EXPERIMENTAL_IMAGE_DECODER',
defaultValue: false,
);

/// Whether the current browser supports `ImageDecoder`.
bool browserSupportsImageDecoder =
_imageDecoderConstructor != null && browserEngine == BrowserEngine.blink;
_imageDecoderExperimentEnabled &&
_imageDecoderConstructor != null &&
browserEngine == BrowserEngine.blink;

/// Sets the value of [browserSupportsImageDecoder] to its default value.
void debugResetBrowserSupportsImageDecoder() {
Expand Down