Skip to content

[Wasm] ColorFiltered broken when running with Wasm #159697

Closed

Description

@JaffaKetchup

Steps to reproduce

Open https://demo.fleaflet.dev/tile_builder. Select the menu icon in the top left and verify that it states "Running with WASM". Notice the screen is completely white. Toggle the switch located next to the moon icon to reveal the map.

image

Open https://fleaflet-firebase--no-wasm-6h38zqtu.web.app/tile_builder. Select the menu icon in the top left and verify that it states "Running without WASM". Notice the map appears with an altered color.

image

I tested this with Chrome Dev 133.0.6847.2 & Microsoft Edge 132.0.2957.11. Unable to test on non-Chromium browsers.


The ColorFilter used is:

const ColorFilter.matrix(<double>[
      -1,
      0,
      0,
      0,
      255,
      0,
      -1,
      0,
      0,
      255,
      0,
      0,
      -1,
      0,
      255,
      0,
      0,
      0,
      1,
      0,
    ])

In flutter_map, we wrap this around a TileLayer using a ColorFiltered in the example app. The TileLayer is an OverflowBox > Transform.rotate > Stack > Positioned > AnimatedBuilder > RawImage. I suspect RawImage isn't interacting with the color filter correctly for some reason.

Expected results

Both maps should appear as maps (not white screens).

Actual results

See above.

Code sample

The concerned example page is https://github.com/fleaflet/flutter_map/blob/master/example/lib/pages/tile_builder.dart. This uses https://github.com/fleaflet/flutter_map/blob/master/lib/src/layer/tile_layer/tile_builder.dart and eventually the RawImage is used in https://github.com/fleaflet/flutter_map/blob/master/lib/src/layer/tile_layer/tile.dart.

Screenshots or Video

No response

Logs

No logs in any console.

Flutter Doctor output

Doctor output

image

Activity

  1. darshankawar commented on Dec 3, 2024

    @darshankawar
    Member

    Thanks for the report @JaffaKetchup
    I see that the code example you shared is external package. Is there a chance to check with google_maps_flutter to see if same behavior occurs ? Also if you could check on upgraded stable or master to see if you still get same behavior or not.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Dec 3, 2024
  3. JaffaKetchup commented on Dec 3, 2024

    @JaffaKetchup
    ContributorAuthor

    TLDR: The child can be anything, not just an image. It occurs on both stable and beta.

    I can't easily test whether google_maps_flutter has the same issue, and it's a very very different situation. flutter_map is 100% Flutter and just boils down to a ColorFiltered applied to a RawImage. google_maps_flutter boils down to JavaScript via https://pub.dev/packages/google_maps. I'm not really sure if its relevant whether google_maps works.

    The demo.fleaflet.dev site is built from stable by https://github.com/fleaflet/flutter_map/blob/master/.github/workflows/master.yml. So this would suggest it occurs across beta and stable. I cannot currently test master.

    I can however, confirm it occurs just with the following code sample in a standalone MRE:

    ColorFiltered(
              colorFilter: const ColorFilter.matrix(<double>[
                -1,
                0,
                0,
                0,
                255,
                0,
                -1,
                0,
                0,
                255,
                0,
                0,
                -1,
                0,
                255,
                0,
                0,
                0,
                1,
                0,
              ]),
              child: Image(
                image: AssetImage('assets/icon.png'),
              ),
            ),

    and the same issue occurs when using colored Text instead of Image.

    The issue is not specific to RawImage or flutter_map.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Dec 3, 2024
  5. darshankawar commented on Dec 4, 2024

    @darshankawar
    Member

    Thanks for the update. I was able to replicate this on latest sdk versions (stable and master) using below code sample:

    code
    
    import 'package:flutter/material.dart';
    
    /// Flutter code sample for [ColorFiltered].
    
    void main() => runApp(const ColorFilteredExampleApp());
    
    class ColorFilteredExampleApp extends StatelessWidget {
      const ColorFilteredExampleApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(title: const Text('ColorFiltered Sample')),
            body: const ColorFilteredExample(),
          ),
        );
      }
    }
    
    class ColorFilteredExample extends StatelessWidget {
      const ColorFilteredExample({super.key});
    
      @override
      Widget build(BuildContext context) {
        return SingleChildScrollView(
          child: Column(
            children: <Widget>[
              ColorFiltered(
                colorFilter: const ColorFilter.matrix(<double>[
                  -1,
                  0,
                  0,
                  0,
                  255,
                  0,
                  -1,
                  0,
                  0,
                  255,
                  0,
                  0,
                  -1,
                  0,
                  255,
                  0,
                  0,
                  0,
                  1,
                  0,
                ]),
                child: Image(
                  image: AssetImage('assets/red-letter.jpg'),
                ),
              ),
              ColorFiltered(
                colorFilter: const ColorFilter.mode(
                  Colors.grey,
                  BlendMode.saturation,
                ),
                child: Image.network(
                  'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg',
                ),
              ),
            ],
          ),
        );
      }
    }
    
    
    
    1. With --wasm, the image is not displayed:
    Screenshot 2024-12-04 at 10 59 19 AM
    1. Without wasm, the image is rendered properly with applied color filters:
    Screenshot 2024-12-04 at 10 59 57 AM
    stable : 3.24.5
    master : 3.27.0-1.0.pre.682
    
  6. added
    platform-webWeb applications specifically
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    e: wasmIssues related to the wasm build of Flutter Web.
    team-webOwned by Web platform team
    and removed
    in triagePresently being triaged by the triage team
    on Dec 4, 2024
  7. added
    P2Important issues not at the top of the work list
    e: web_skwasmSkwasm rendering backend for web
    triaged-webTriaged by Web platform team
    on Dec 26, 2024
  8. eyebrowsoffire commented on Jan 8, 2025

    @eyebrowsoffire
    Contributor

    Fixed with #161109

  9. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jan 9, 2025
  10. github-actions commented on Jan 23, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  11. locked as resolved and limited conversation to collaborators on Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P2Important issues not at the top of the work liste: wasmIssues related to the wasm build of Flutter Web.e: web_skwasmSkwasm rendering backend for webfound in release: 3.24Found to occur in 3.24found in release: 3.27Found to occur in 3.27has 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