Skip to content

Reply null asynchronously to ignored web platform messages and unskip missing-asset tests - #197267

Merged
auto-submit[bot] merged 6 commits into
flutter:masterfrom
harryterkelsen:web-flutter-tester-emulation-replies-null-to
Nov 25, 2026
Merged

auto-submit[bot] merged 6 commits into
flutter:masterfrom
harryterkelsen:web-flutter-tester-emulation-replies-null-to

Conversation

@harryterkelsen

Copy link
Copy Markdown
Contributor

Make the web engine's flutter_tester emulation (ui_web.TestEnvironment.ignorePlatformMessages) reply null asynchronously to outgoing platform messages instead of dropping their response callbacks, and unskip the missing-asset framework tests on web.

Previously, when running flutter test --platform chrome (TestEnvironment.flutterTester()), EnginePlatformDispatcher._sendPlatformMessage returned early without ever invoking callback. Any caller awaiting an unmocked platform channel—such as rootBundle.load or ExactAssetImage loading a nonexistent asset—hung until the 30-second test timeout instead of receiving the standard empty (null) unhandled-channel reply that native flutter_tester and production web 404 responses return. With #196329 switching RendererBinding._handleWebFirstFrame (flutter/service_worker) to OptionalMethodChannel, replying null uniformly across all channels in ignorePlatformMessages mode aligns web tests with native flutter_tester without triggering spurious MissingPluginException errors.

Fixes #56314

Also updates the skip rationale comment on Failed image loads in debug mode in packages/flutter/test/widgets/image_test.dart (tracked in #74935) to document that Image.asset still requires AssetManifest.bin.json, which web unit tests do not currently serve.

Behavioral Changes

  • Before: When ui_web.TestEnvironment.ignorePlatformMessages is true (including TestEnvironment.flutterTester() under flutter test --platform chrome), EnginePlatformDispatcher.sendPlatformMessage drops outgoing messages without invoking callback. Unmocked platform channel calls (such as rootBundle.load or AssetBundleImageProvider for a missing asset) never complete and hang until test timeout, leaving pending futures in TestDefaultBinaryMessenger and pending entries in ImageCache.
  • After: When ui_web.TestEnvironment.ignorePlatformMessages is true, EnginePlatformDispatcher.sendPlatformMessage still skips engine channel handlers, but schedules callback(null) asynchronously via a zero-duration timer on Zone.root. Unhandled channels receive an empty (null) reply on a subsequent event-loop turn (executed in the caller's registration zone), causing missing-asset loads in web tests to throw FlutterError('Unable to load asset: ...') and evict pending ImageCache entries just as on the VM. Production web apps (ignorePlatformMessages == false, and profile/release builds where assert blocks are stripped) are unaffected.

Where to focus

  • Key Architectural Decisions: EnginePlatformDispatcher._sendPlatformMessage replies null uniformly to every channel when ignorePlatformMessages is enabled rather than special-casing flutter/assets. This matches native flutter_tester semantics for unhandled channels across the board now that RendererBinding._handleWebFirstFrame uses OptionalMethodChannel (Tolerate a missing flutter/service_worker handler in the web first-frame notification #196329).
  • Non-Obvious Logic: The null reply is scheduled with Zone.root.createTimer(Duration.zero, () => callback(null)) rather than synchronously or via replyToPlatformMessage. Synchronous replies violate callers' async expectations, while replyToPlatformMessage uses Future<void>.delayed(Duration.zero) in Zone.current, which registers a FakeAsync timer inside testWidgets and fails end-of-test timer invariants when widgets send platform messages without a subsequent pump(). Because sendPlatformMessage wraps callback in _zonedPlatformMessageResponseCallback, scheduling on Zone.root avoids FakeAsync timers while still running the callback in its registration zone.
  • Primary Review Files:
    • engine/src/flutter/lib/web_ui/lib/src/engine/platform_dispatcher.dart — asynchronous root-zone null reply in _sendPlatformMessage when ignorePlatformMessages is true.
    • engine/src/flutter/lib/web_ui/lib/ui_web/src/ui_web/testing.dart — updated TestEnvironment.ignorePlatformMessages doc comment.
    • engine/src/flutter/lib/web_ui/test/engine/platform_dispatcher/platform_dispatcher_test.dart — unit tests covering async delivery, skipped asset fetches, registration zone preservation, FakeAsync timer isolation, tearDown transitions, and FIFO ordering.

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.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team labels Nov 23, 2026
@harryterkelsen
harryterkelsen marked this pull request as ready for review November 24, 2026 00:29
@harryterkelsen harryterkelsen added the CICD Run CI/CD label Nov 24, 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 updates the web engine's platform dispatcher to emulate flutter_tester by asynchronously replying with null to outgoing platform messages when ignorePlatformMessages is enabled. It also adds tests for this emulation and enables previously skipped tests on the browser. A review comment suggests calling ui_web.TestEnvironment.tearDown() before setting up a new test environment in tests to prevent potential assertion failures or state pollution.

@harryterkelsen

Copy link
Copy Markdown
Contributor Author

Addressed inline on platform_dispatcher_test.dart:1068: TestEnvironment.setUp (testing.dart:45-50) assigns _instance = testEnvironment on an immutable const flag holder without asserting _instance == null, so a preceding tearDown() (_instance = null) is a no-op.

mdebbar
mdebbar previously approved these changes Nov 24, 2026
@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
@auto-submit

auto-submit Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/197267, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 24, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 25, 2026
Merged via the queue into flutter:master with commit ec61052 Nov 25, 2026
21 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 25, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 25, 2026
Roll Flutter from b75c5b30406a to 06f1c24345a2 (37 revisions)

flutter/flutter@b75c5b3...06f1c24

2026-11-25 [email protected] Roll Skia from a60d883b3fe3 to e84ecd98d9f2 (2 revisions) (flutter/flutter#197375)
2026-11-25 [email protected] Roll Skia from ca229e319550 to a60d883b3fe3 (4 revisions) (flutter/flutter#197371)
2026-11-25 [email protected] Roll Skia from 6f75212e5a23 to ca229e319550 (2 revisions) (flutter/flutter#197369)
2026-11-25 [email protected] Roll Skia from 75d95595f14e to 6f75212e5a23 (1 revision) (flutter/flutter#197364)
2026-11-25 [email protected] [Windows] Fix Korean 3-beolsik IME dropping space, digits and punctuation (flutter/flutter#194270)
2026-11-25 [email protected] [flutter_tools] Strip embedded credentials from repository URLs (flutter/flutter#197219)
2026-11-25 [email protected] [flutter_tools] Add structured extension.log notifications for tool extensions (flutter/flutter#196714)
2026-11-25 [email protected] [flutter_tools] Share Depfile in flutter_tools_core and make BuildTarget.targetPlatform optional (flutter/flutter#194965)
2026-11-25 [email protected] Reply null asynchronously to ignored web platform messages and unskip missing-asset tests (flutter/flutter#197267)
2026-11-25 [email protected] Roll Dart SDK from 87f515c52de9 to 5202130a51b8 (1 revision) (flutter/flutter#197363)
2026-11-25 [email protected] [web] Retain queued scene pictures via ContainerLayer render pinning (flutter/flutter#196748)
2026-11-25 [email protected] [flutter_tools] Include dependency manifests in copyAssets depfile (flutter/flutter#196596)
2026-11-25 [email protected] Print the Intel Mac deprecation warning on every command (flutter/flutter#194071)
2026-11-25 [email protected] Roll Skia from 243c0dc9f662 to 75d95595f14e (2 revisions) (flutter/flutter#197351)
2026-11-25 [email protected] iOS: Ignore platform messages after the engine is destroyed (flutter/flutter#197310)
2026-11-24 [email protected] Bump customer tests to pick up material_ui cache extent test updates (flutter/flutter#197266)
2026-11-24 [email protected] [flutter_tools] Use refreshed FlutterVersion for flutter doctor feature flags (flutter/flutter#196944)
2026-11-24 [email protected] [flutter_tools] Do not crash if buildXcodeProject temporary directory is deleted before cleanup (flutter/flutter#195918)
2026-11-24 [email protected] Fix some `parameter_assignments` warnings (flutter/flutter#196815)
2026-11-24 [email protected] [flutter_tools] Extract PlatformDebuggingOptions and move WebDebugConfig (flutter/flutter#197229)
2026-11-24 [email protected] Fix desktop apps installing to the system prefix after a failed build (flutter/flutter#196482)
2026-11-24 [email protected] [flutter_tools] Write flutter test native_assets.json outside targetDir (flutter/flutter#196300)
2026-11-24 [email protected] iOS: Check the presented composition order in platform view tests (flutter/flutter#197302)
2026-11-24 [email protected] Run the shared Vulkan embedder tests under Impeller as well as Skia (flutter/flutter#193004)
2026-11-24 [email protected] Roll Fuchsia Linux SDK from BOgXtIYxLYcCkRou2... to HtAKfFLbfAQ6g96RY... (flutter/flutter#197334)
2026-11-24 [email protected] Roll Skia from b3dec9325fe1 to 243c0dc9f662 (6 revisions) (flutter/flutter#197333)
2026-11-24 [email protected] [flutter_tools] Delete globals.dart and context_runner.dart (flutter/flutter#196095)
2026-11-24 [email protected] Update viewInsets docs for translucent and rounded system UI (flutter/flutter#196355)
2026-11-24 [email protected] [flutter_tools] Check that dartaotruntime can run before starting the frontend server (flutter/flutter#194206)
2026-11-24 [email protected] [framework] Fix DraggableScrollableSheet '_hold == null' assertion when touch lifts during snap (flutter/flutter#195771)
2026-11-24 [email protected] [web] Release ImageSource on GC and fix Picture finalizer cycles (flutter/flutter#197245)
2026-11-24 [email protected] [flutter_tools] Fix web compiler output tracking in web builds (flutter/flutter#196563)
2026-11-24 [email protected] Upgrade CI to Xcode 27.2 (flutter/flutter#196807)
2026-11-24 [email protected] Roll Packages from 5b93485 to f455dfa (6 revisions) (flutter/flutter#197316)
2026-11-24 [email protected] [Linux] Fix deadlock presenting to a Wayland subsurface (flutter/flutter#196945)
2026-11-24 [email protected] Roll Skia from 2140958ee284 to b3dec9325fe1 (1 revision) (flutter/flutter#197309)
2026-11-24 [email protected] Roll Fuchsia Test Scripts from oEU515sDqSTvD8Spx... to GPtykFNizlaauBqzs... (flutter/flutter#197313)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

...
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. framework flutter/packages/flutter repository. See also f: 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.

[Web] AssetImageProvider hangs on failure to load

2 participants