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

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
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 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
Contributor

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
flutter/packages@3bddf2c...c197455

2026-02-05 [email protected] Roll Flutter from
bf701fe to f916dd6 (44 revisions) (flutter/packages#10967)
2026-02-05 [email protected] [webview_flutter] Fix crash in iOS
external native API (flutter/packages#10959)
2026-02-04 8014077[email protected] [google_fonts] Fix
file type priority in asset path lookup (flutter/packages#10907)

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

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

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
LongCatIsLooong pushed a commit to LongCatIsLooong/flutter that referenced this pull request Feb 6, 2026
…r#181962)

flutter/packages@3bddf2c...c197455

2026-02-05 [email protected] Roll Flutter from
bf701fe to f916dd6 (44 revisions) (flutter/packages#10967)
2026-02-05 [email protected] [webview_flutter] Fix crash in iOS
external native API (flutter/packages#10959)
2026-02-04 8014077[email protected] [google_fonts] Fix
file type priority in asset path lookup (flutter/packages#10907)

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

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

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Feb 10, 2026
…r#181962)

flutter/packages@3bddf2c...c197455

2026-02-05 [email protected] Roll Flutter from
bf701fe to f916dd6 (44 revisions) (flutter/packages#10967)
2026-02-05 [email protected] [webview_flutter] Fix crash in iOS
external native API (flutter/packages#10959)
2026-02-04 8014077[email protected] [google_fonts] Fix
file type priority in asset path lookup (flutter/packages#10907)

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

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

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
rickhohler pushed a commit to rickhohler/flutter that referenced this pull request Feb 19, 2026
…r#181962)

flutter/packages@3bddf2c...c197455

2026-02-05 [email protected] Roll Flutter from
bf701fe to f916dd6 (44 revisions) (flutter/packages#10967)
2026-02-05 [email protected] [webview_flutter] Fix crash in iOS
external native API (flutter/packages#10959)
2026-02-04 8014077[email protected] [google_fonts] Fix
file type priority in asset path lookup (flutter/packages#10907)

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

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

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
mboetger pushed a commit to mboetger/flutter that referenced this pull request Mar 26, 2026
…r#181962)

flutter/packages@3bddf2c...c197455

2026-02-05 [email protected] Roll Flutter from
bf701fe to f916dd6 (44 revisions) (flutter/packages#10967)
2026-02-05 [email protected] [webview_flutter] Fix crash in iOS
external native API (flutter/packages#10959)
2026-02-04 8014077[email protected] [google_fonts] Fix
file type priority in asset path lookup (flutter/packages#10907)

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

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

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
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

[^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.
Nakiha pushed a commit to Nakiha/VoidPlayer-Flutter that referenced this pull request Sep 28, 2026
flutter/packages@3bddf2c...c197455

2026-02-05 [email protected] Roll Flutter from
8654097 to 5401377 (44 revisions) (flutter/packages#10967)
2026-02-05 [email protected] [webview_flutter] Fix crash in iOS
external native API (flutter/packages#10959)
2026-02-04 [email protected] [google_fonts] Fix
file type priority in asset path lookup (flutter/packages#10907)

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

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

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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