Skip to content

[webview_flutter_android] Adds a WebViewFlutterApi#3324

Merged
auto-submit[bot] merged 9 commits intoflutter:mainfrom
bparrishMines:webview_flutter_api
Mar 8, 2023
Merged

[webview_flutter_android] Adds a WebViewFlutterApi#3324
auto-submit[bot] merged 9 commits intoflutter:mainfrom
bparrishMines:webview_flutter_api

Conversation

@bparrishMines
Copy link
Contributor

@bparrishMines bparrishMines commented Feb 28, 2023

This should fix flutter/flutter#119899

It's possible that a WebView returned in a WebViewClient callback could be one that was not created by Dart. I'm unable to find a reproducible situation, but it's definitely possible that this is the cause of the problem.

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 relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

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

@bparrishMines bparrishMines changed the title add webview flutter api [webview_flutter_android] Adds a WebViewFlutterApi Feb 28, 2023
public void setUp() {
instanceManager = InstanceManager.open(identifier -> {});

instanceManager.addDartCreatedInstance(mockWebView, 0L);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed so that it is tested that it can handle adding the mockWebView.

Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM! One optional change.

if (webViewIdentifier == null) {
throw new IllegalStateException("Could not find identifier for WebView.");
}
final WebViewFlutterApiImpl webViewFlutterApi =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optional: Should we just make a private field with this API on object construction, so we don't need the boilerplate of creating one in every single callback? I know it's cheap to create, but it should also be very cheap to just keep it around.

@bparrishMines bparrishMines added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 8, 2023
@auto-submit auto-submit bot merged commit a4d3d16 into flutter:main Mar 8, 2023
@bparrishMines bparrishMines deleted the webview_flutter_api branch March 8, 2023 15:28
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 8, 2023
@GeylanKalafMohe
Copy link

It is available as a new version on pub.dev?

@stuartmorgan-g
Copy link
Collaborator

@GeylanKalafMohe Yes. In the future, you can just check pub.dev to see what has been published.

@GeylanKalafMohe
Copy link

GeylanKalafMohe commented Mar 8, 2023

@GeylanKalafMohe Yes. In the future, you can just check pub.dev to see what has been published.

But why is it not published on webview_flutter in a new version??

@GeylanKalafMohe
Copy link

@stuartmorgan I know it is endorsed but how does my pubspec.yaml file and the webview_flutter know that there is a new version of an endorsed package in webview_flutter? How can it benefit from it?

@stuartmorgan-g
Copy link
Collaborator

But why is it not published on webview_flutter in a new version?

Because there are no changes to webview_flutter, so there is nothing to publish for that package.

How can it benefit from it?

The same way you would get updates to any other packages you have transitive dependencies on: flutter pub upgrade to get new versions of them.

@GeylanKalafMohe
Copy link

This issue still happens with the latest version.

Fatal Exception: java.lang.NullPointerException: at java.util.Objects.requireNonNull(Objects.java:220) at io.flutter.plugins.webviewflutter.WebChromeClientFlutterApiImpl.onProgressChanged(WebChromeClientFlutterApiImpl.java:13) at io.flutter.plugins.webviewflutter.WebChromeClientHostApiImpl$WebChromeClientImpl.onProgressChanged(WebChromeClientHostApiImpl.java:9) at GE.onProgressChanged(GE.java:3) at M4.handleMessage(M4.java:94) at android.os.Handler.dispatchMessage(Handler.java:117) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:293) at android.app.ActivityThread.main(ActivityThread.java:9435) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:586) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1204)

Device Brand:Huawei Model:ABR-LX9 Orientation: Portrait RAM free: 2.27 GB Disk free: 209.27 GB Operating System Version:Android 12 Orientation: Portrait Rooted:No

nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
[webview_flutter_android] Adds a WebViewFlutterApi
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-android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[webview_flutter]java.lang.IllegalStateException: Could not find identifier for WebView

3 participants