pichillilorenzo / flutter_inappwebview

A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
https://inappwebview.dev
Apache License 2.0
3.32k stars 1.64k forks source link

macOS: PlatformException on Hot Restart #2405

Open ToniTornado opened 3 weeks ago

ToniTornado commented 3 weeks ago

Is there an existing issue for this?

Current Behavior

When I run the example application on macOS and perform a hot restart, I get the following exception: [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(recreating_view, trying to create an already created view, view id: '0', null)

Expected Behavior

The widget tree is rebuilt and a fresh instance of InAppWebView is created without throwing an exception.

Steps with code example to reproduce

Steps with code example to reproduce ```dart // Paste your code here ```

Stacktrace/Logs

Stacktrace/Logs ``` ```

Flutter version

3.24.4

Operating System, Device-specific and/or Tool

macOS

Plugin version

6.2.0-beta.1

Additional information

No response

Self grab

pichillilorenzo commented 3 weeks ago

For unknown reasons, the Flutter PlatformView is not disposed automatically on Hot Restart. It works as expected on Android, iOS, and Windows but not on macOS. I think this has something to do with how Flutter manages the native PlatformView under the hood as this plugin is using the Flutter official API to render native views. Probably, you should open an issue on the Flutter official repo and you can mention this issue.

hhcme commented 1 week ago

I also found similar issues in my project

giorgiogross commented 5 days ago

Experiencing the same issue; wasn't aware it only happens on hot restart but a full rebuild helps