Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web] Ensure handleNavigationMessage can receive null arguments. #26406

Merged
merged 3 commits into from May 26, 2021
Merged

[web] Ensure handleNavigationMessage can receive null arguments. #26406

merged 3 commits into from May 26, 2021

Conversation

ditman
Copy link
Member

@ditman ditman commented May 25, 2021

In a recent update to handleNavigationMessage some extra messages were added that don't require any arguments. From the framework side, those messages are sent without arguments (OK), but the engine was never modified to accept null arguments, so it fails with:

Error: Expected a value of type 'Map<String, dynamic>', but got one of type 'Null'
...
    at _engine.EngineSingletonFlutterWindow.new.handleNavigationMessage 
...
    at _engine.EnginePlatformDispatcher.__.sendPlatformMessage 
...
    at OptionalMethodChannel.invokeMethod
...
    at Function.selectSingleEntryHistory (framework)

Since that unhandled exception bubbles up to the browser, web apps in master display a red error message, which may break all web integration tests like so:

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞═════════════════
The following TypeErrorImpl was thrown running a test:
Expected a value of type 'Map<String, dynamic>', but got one of type 'Null'

When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 251:49      throw_
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 84:3        castError
...
lib/_engine/engine/window.dart 116:32                                             handleNavigationMessage
...
packages/flutter/src/services/system_channels.dart.js 1007:20                     invokeMethod
packages/flutter/src/services/system_navigator.dart.js 26:56                      selectSingleEntryHistory
packages/flutter/src/widgets/inherited_model.dart.js 25905:42                     initState

Fixes flutter/flutter#83158

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.
  • The reviewer has submitted any presubmit flakes in this PR using the engine presubmit flakes form before re-triggering the failure.

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

@ditman ditman requested review from Hixie and ferhatb May 25, 2021 19:05
@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label May 25, 2021
@google-cla google-cla bot added the cla: yes label May 25, 2021
@ditman ditman requested a review from ferhatb May 25, 2021 22:18
@ditman ditman added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label May 26, 2021
@fluttergithubbot fluttergithubbot merged commit 052471f into flutter:master May 26, 2021
@ditman ditman deleted the nullable-navigation-arguments branch May 26, 2021 01:10
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 26, 2021
naudzghebre pushed a commit to naudzghebre/engine that referenced this pull request Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes platform-web Code specifically for the web engine waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
4 participants