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

Commit f181c4d

Browse files
authored
[web] flip browser image codec flag to opt-out (#30681)
1 parent c726121 commit f181c4d

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

lib/web_ui/dev/steps/compile_tests_step.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,6 @@ Future<bool> compileUnitTest(FilePath input, { required bool forCanvasKit }) asy
258258
'-DFLUTTER_WEB_AUTO_DETECT=false',
259259
'-DFLUTTER_WEB_USE_SKIA=$forCanvasKit',
260260

261-
// Enable the image decoder experiment in tests so we can test the new
262-
// functionality. WASM decoders are still tested by forcing the value of
263-
// `browserSupportsImageDecoder` to false in the test. See also:
264-
//
265-
// lib/web_ui/test/canvaskit/image_golden_test.dart
266-
// TODO(yjbanov): https://github.com/flutter/flutter/issues/95277
267-
'-DEXPERIMENTAL_IMAGE_DECODER=true',
268-
269261
'-O2',
270262
'-o',
271263
targetFileName, // target path.

lib/web_ui/lib/src/engine/safe_browser_api.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,22 @@ html.CanvasElement? tryCreateCanvasElement(int width, int height) {
219219
@JS('window.ImageDecoder')
220220
external Object? get _imageDecoderConstructor;
221221

222-
/// Hides `image_web_codecs.dart` behind a flag.
223-
// TODO(yjbanov): https://github.com/flutter/flutter/issues/95277
224-
const bool _imageDecoderExperimentEnabled = bool.fromEnvironment(
225-
'EXPERIMENTAL_IMAGE_DECODER',
226-
defaultValue: false,
222+
/// Environment variable that allows the developer to opt out of using browser's
223+
/// `ImageDecoder` API, and use the WASM codecs bundled with CanvasKit.
224+
///
225+
/// While all reported severe issues with `ImageDecoder` have been fixed, this
226+
/// API remains relatively new. This option will allow developers to opt out of
227+
/// it, if they hit a severe bug that we did not anticipate.
228+
// TODO(yjbanov): remove this flag once we're fully confident in the new API.
229+
// https://github.com/flutter/flutter/issues/95277
230+
const bool _browserImageDecodingEnabled = bool.fromEnvironment(
231+
'BROWSER_IMAGE_DECODING_ENABLED',
232+
defaultValue: true,
227233
);
228234

229235
/// Whether the current browser supports `ImageDecoder`.
230236
bool browserSupportsImageDecoder =
231-
_imageDecoderExperimentEnabled &&
237+
_browserImageDecodingEnabled &&
232238
_imageDecoderConstructor != null &&
233239
browserEngine == BrowserEngine.blink;
234240

0 commit comments

Comments
 (0)