Skip to content

[Web][CanvasKit] Web App crashes if using ImageFiltered. #144015

@liuzs0666

Description

@liuzs0666

Steps to reproduce

Use ImageFiltered with simple ColorFilter or ImageFilter.compose of two ColorFilter

Expected results

Should see the filtered child widget.

Actual results

App crashes. Throws Error: TypeError: Instance of 'EngineColorFilter': type 'EngineColorFilter' is not a subtype of type 'CkManagedSkImageFilterConvertible' in Chrome DevTools

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  static const _darkenImageFilter = ColorFilter.mode(
    Color.fromARGB(0xff, 0x60, 0x60, 0x60),
    BlendMode.darken,
  );

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: ImageFiltered(
            imageFilter: _darkenImageFilter,
            child: const Icon(Icons.abc_rounded),
          ),
        ),
      ),
    );
  }
}
https://dartpad.dev/?id=d01d7447b2d8fed2a2f9cf7ed7906b50

Screenshots or Video

Screenshots / Video demonstration Screenshot 2024-02-23 at 22 08 52

Logs

Logs
errors.dart:297 Uncaught (in promise) Error: TypeError: Instance of 'EngineColorFilter': type 'EngineColorFilter' is not a subtype of type 'CkManagedSkImageFilterConvertible'
    at Object.throw_ [as throw] (errors.dart:297:3)
    at Object._failedAsCheck (rti.dart:1385:3)
    at dart_rti.Rti.new._generalAsCheckImplementation (rti.dart:1363:3)
    at dart_rti.Rti.new._installSpecializedAsCheck (rti.dart:1258:30)
    at _engine.ImageFilterEngineLayer.new.preroll (layer.dart:399:14)
    at _engine.OffsetEngineLayer.new.prerollChildren (layer.dart:122:12)
    at _engine.OffsetEngineLayer.new.preroll (layer.dart:356:9)
    at _engine.OffsetEngineLayer.new.prerollChildren (layer.dart:122:12)
    at _engine.OffsetEngineLayer.new.preroll (layer.dart:356:9)
    at _engine.TransformEngineLayer.new.prerollChildren (layer.dart:122:12)
    at _engine.TransformEngineLayer.new.preroll (layer.dart:356:9)
    at _engine.RootLayer.new.prerollChildren (layer.dart:122:12)
    at _engine.RootLayer.new.preroll (layer.dart:111:19)
    at _engine.LayerTree.new.preroll (layer_tree.dart:29:5)
    at layer_tree.dart:89:16
    at Object.timeAction (profiler.dart:41:18)
    at _engine.Frame.new.raster (layer_tree.dart:88:5)
    at _engine.Rasterizer.new.draw (rasterizer.dart:48:20)
    at draw.next (<anonymous>)
    at runBody (async_patch.dart:84:54)
    at Object._async [as async] (async_patch.dart:127:5)
    at _engine.Rasterizer.new.draw (rasterizer.dart:32:20)
    at _engine.CanvasKitRenderer.new.renderScene (renderer.dart:415:21)
    at renderScene.next (<anonymous>)
    at runBody (async_patch.dart:84:54)
    at Object._async [as async] (async_patch.dart:127:5)
    at _engine.CanvasKitRenderer.new.renderScene (renderer.dart:400:27)
    at _engine.EnginePlatformDispatcher.new.render (platform_dispatcher.dart:777:22)
    at render.next (<anonymous>)
    at runBody (async_patch.dart:84:54)
    at Object._async [as async] (async_patch.dart:127:5)
    at _engine.EnginePlatformDispatcher.new.render (platform_dispatcher.dart:758:22)
    at _engine.EngineFlutterWindow.__.render (window.dart:93:5)
    at binding$2._ReusableRenderView.new.compositeFrame (view.dart:256:7)
    at binding$.WidgetsFlutterBinding.new.drawFrame (binding.dart:587:19)
    at binding$.WidgetsFlutterBinding.new.drawFrame (binding.dart:991:13)
    at [_handlePersistentFrameCallback] (binding.dart:448:5)
    at [_invokeFrameCallback] (binding.dart:1386:7)
    at binding$.WidgetsFlutterBinding.new.handleDrawFrame (binding.dart:1311:9)
    at [_handleDrawFrame] (binding.dart:1169:5)
    at Object.invoke (platform_dispatcher.dart:1346:5)
    at _engine.EnginePlatformDispatcher.new.invokeOnDrawFrame (platform_dispatcher.dart:260:5)
    at initialization.dart:185:36
    at Object._checkAndCall (operations.dart:550:37)
    at Object.dcall (operations.dart:555:39)
    at ret (js_allow_interop_patch.dart:17:11)

Flutter Doctor output

I'm running under a separate branch of Flutter SDK but this bug can be reproduced in stable channel on DartPad, based on Dart SDK 3.3.0 and Flutter SDK 3.19.0.

Screenshot 2024-02-23 at 22 09 55

Metadata

Metadata

Labels

P2Important issues not at the top of the work listc: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowfound in release: 3.16Found to occur in 3.16found in release: 3.19Found to occur in 3.19found in release: 3.20Found to occur in 3.20has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions