Skip to content

[wimp] Adds wimp-heavy variant for non-chrome browsers - #189953

Open
gaaclarke wants to merge 2 commits into
flutter:masterfrom
gaaclarke:wimp-heavy
Open

[wimp] Adds wimp-heavy variant for non-chrome browsers#189953
gaaclarke wants to merge 2 commits into
flutter:masterfrom
gaaclarke:wimp-heavy

Conversation

@gaaclarke

@gaaclarke gaaclarke commented Jul 23, 2026

Copy link
Copy Markdown
Member

issue: #187212

This gets wimp_heavy loading on firefox. There are still some webgl errors though.

video

Before this change nothing rendered for counter, now it works as long as you don't hover over the floating button.

firefox.mov

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 23, 2026
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@gaaclarke gaaclarke changed the title Wimp heavy [wimp] Adds wimp-heavy variant for non-chrome browsers Jul 23, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for a heavy variant of the Wimp renderer, 'wimp_heavy', by updating build targets, artifact copying steps, and the Web SDK configuration. Additionally, the loader logic in 'skwasm_loader.js' is updated to resolve 'wimp_heavy' when a heavy build is required and Wimp is enabled. Feedback suggests using optional chaining on the 'config' object in the loader to prevent potential runtime errors if 'config' is undefined.

const needsHeavy = (!browserEnvironment.hasImageCodecs || !browserEnvironment.hasChromiumBreakIterators)
const fileStem = needsHeavy
? 'skwasm_heavy'
? (config.enableWimp ? 'wimp_heavy' : 'skwasm_heavy')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To prevent potential runtime errors if the config object is null or undefined (for example, in certain test environments or custom embeddings), consider using optional chaining (config?.enableWimp) when checking the configuration.

Suggested change
? (config.enableWimp ? 'wimp_heavy' : 'skwasm_heavy')
? (config?.enableWimp ? 'wimp_heavy' : 'skwasm_heavy')

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team labels Jul 23, 2026

@eyebrowsoffire eyebrowsoffire left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will actually need some kind of solution for how to deal with image decoding. As of right now, just flipping the heavy flag just compiles in SkAnimatedImage, which will have skia do image decoding for us on non-Chrome browsers. But that just produces an SkImage, which is incompatible with wimp, and will basically cause things to crash if the web engine attempts to render an image this way.

The reason the "light" version of skwasm/wimp gets away with this is because on Chrome, all code paths on the dart side use the browser-based ImageDecoder API to produce an ImageBitmap and so the animated image path is never used. I think the newest versions of Firefox and Safari support this API now, so theoretically we could do the same there, but in practice we haven't turned that on on the dart side for browsers other than Chrome. In the past we used to feature gate things by the existence of the browser API rather than explicitly turning it on per-browser, but we got burned by that when browsers would release a buggy version of their API that we hadn't vetted yet and we were left scrambling to put a patch in to disable it.

If it turns out that both Firefox's and Safari's ImageDecoder APIs are actually ready for prime time and available in all supported versions of our browser, we could consider completely removing the SkAnimatedImage path and then it's one less vector to worry about for the heavy vs. light conversation. But we'll need to talk to the other web folks to move forward on that and make sure we change things on the dart side to always use the browser-based ImageDecoder API.

@gaaclarke

Copy link
Copy Markdown
Member Author

@eyebrowsoffire okay, that probably explains the weird errors I've been trying to get to the bottom of.

If it turns out that both Firefox's and Safari's ImageDecoder APIs are actually ready for prime time

I don't actually think that is the case for Safari: https://developer.mozilla.org/en-US/docs/Web/API/ImageDecoder

It is an explicit omission on safari.

@gaaclarke

Copy link
Copy Markdown
Member Author

@eyebrowsoffire I'll look into the ImageDecoder in a separate PR. This actually renders something in firefox, whereas before this it rendered nothing.

@gaaclarke
gaaclarke requested a review from eyebrowsoffire July 23, 2026 22:50
@gaaclarke

Copy link
Copy Markdown
Member Author

@eyebrowsoffire okay, that probably explains the weird errors I've been trying to get to the bottom of.

Actually the problem was the one fixed in #189958. Firefox webgl2 is stricter in this case.

@gaaclarke

Copy link
Copy Markdown
Member Author

Chatted with @eyebrowsoffire offline. He would like a fallback path for image decoding and enabling some felt integration tests as part of this pr.

His notes:

This is the spot in the code where we decide what kind of image decoding strategy to use: https://github.com/flutter/flutter/blob/master/engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/renderer.dart#L355

We'll need some way to determine whether the underlying skwasm/wimp binary supports animated image codec, and then bail out to the dom encoder if it doesn't (which will probably just give us a still of the animated image, which seems like a pretty reasonable fallback)

As for enabling unit tests, we'll probably want to add two configs similar to this one, but one on firefox and one on safari: https://github.com/flutter/flutter/blob/master/engine/src/flutter/lib/web_ui/test/felt_config.yaml#L150
Once you've added it to felt_config.yaml you can run felt generate-builder-json and it will modify the appropriate engine_v2 json file to add the test suites to our CI runs

Also, once you've added it to felt_config.yaml you could do like felt test --suite=firefox-dart2wasm-wimp-ui to actually run the unit tests (you'll have to build wimp_heavy and all that first)

In terms of a mechanism for exposing whether the binary actually supports the animated image path, it's going to look similar to the way we expose the skwasmIsHeavy function: https://github.com/flutter/flutter/blob/master/engine/src/flutter/skwasm/text/paragraph_builder_client_icu.cc#L12

We're basically decoupling the idea of "heavy" to mean "has builtin ICU support" and "has animated image support". Previously, heavy just meant both of these, but now the wimp_heavy is going to have builtin ICU support but no animated image support.

@gaaclarke

Copy link
Copy Markdown
Member Author

rebasing to get our opengles fix (#189958)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants