Skip to content

[webview_flutter] Fix crash in iOS external native API#10959

Merged
auto-submit[bot] merged 2 commits into
flutter:mainfrom
stuartmorgan-g:webview-cross-plugin-lookup-crash
Feb 5, 2026
Merged

[webview_flutter] Fix crash in iOS external native API#10959
auto-submit[bot] merged 2 commits into
flutter:mainfrom
stuartmorgan-g:webview-cross-plugin-lookup-crash

Conversation

@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

Fixes a crash if FWFWebViewFlutterWKWebViewExternalAPI's webView(forIdentifier:withPluginRegistry:) is called with a registry that doesn't contain a published webview plugin value. This can happen if the wrong object is passed in (e.g., the FlutterAppDelegate in an app that has adopted UIScene).

Fixes flutter/flutter#181865

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Fixes a crash if `FWFWebViewFlutterWKWebViewExternalAPI`'s
`webView(forIdentifier:withPluginRegistry:)` is called with a registry
that doesn't contain a published webview plugin value. This can happen
if the wrong object is passed in (e.g., the FlutterAppDelegate in an app
that has adopted UIScene).

Fixes flutter/flutter#181865

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

Copy link
Copy Markdown

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 addresses a crash in the iOS external native API by replacing a force-cast with a safe optional cast. This correctly handles cases where the webview plugin isn't found in the provided registry. The change is accompanied by a new unit test to verify the fix, along with corresponding updates to the changelog and package version. The implementation is sound, but I've noted a minor issue in the new test code that will cause a compilation error.

Comment on lines +61 to +63
func registrar(forPlugin pluginKey: String) -> FlutterPluginRegistrar {
return nil
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The registrar(forPlugin:) method for macOS in EmptyRegistry is declared to return a non-optional FlutterPluginRegistrar, but the implementation returns nil. This will cause a compilation error on macOS because the protocol requires a non-optional return value.

To resolve this, you can return the registrar property, which will satisfy the protocol requirement without altering the test's behavior.

Suggested change
func registrar(forPlugin pluginKey: String) -> FlutterPluginRegistrar {
return nil
}
func registrar(forPlugin pluginKey: String) -> FlutterPluginRegistrar {
return registrar
}

@bparrishMines bparrishMines 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.

LGTM

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 5, 2026
@auto-submit auto-submit Bot merged commit 2b6a0b0 into flutter:main Feb 5, 2026
81 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 5, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 5, 2026
github-merge-queue Bot pushed a commit to flutter/flutter that referenced this pull request Feb 5, 2026
LongCatIsLooong pushed a commit to LongCatIsLooong/flutter that referenced this pull request Feb 6, 2026
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Feb 10, 2026
rickhohler pushed a commit to rickhohler/flutter that referenced this pull request Feb 19, 2026
mboetger pushed a commit to mboetger/flutter that referenced this pull request Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App p: webview_flutter platform-ios platform-macos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[webview_flutter] Crash on startup after UISceneDelegate migration when registering Webview with Google Mobile Ads SDK

2 participants