flutter-webview-windows icon indicating copy to clipboard operation
flutter-webview-windows copied to clipboard

Webview freeze and stuck parent widget in KeepAliveClientMixin child

Open filipenanclarez opened this issue 3 years ago • 4 comments

Using a custom dynamic tab widget, webview freeze entire app.

Please see the reproducible example in this repository ( please click on add button and wait 15 seconds to see the interface stucks )

https://github.com/filipenanclarez/poc_webview_windows_dinamic_tabs_flutter

Seems to be a dispose problem, but i'cant discover.

With flutter native webview widget, this problem no happens, so i think my custom tab widget is not the source of problem.

filipenanclarez avatar Dec 22 '21 02:12 filipenanclarez

When use with a tabview, the tabview widget build the widget without make widget visible, and then, the mounted return false.

In this case, the webview stucks whole interface.

To solve this problem, we surround initPlatformState in if (mounted) then problem is gone.

  @override
  void initState() {
    super.initState();

    WidgetsBinding.instance?.addPostFrameCallback((_) async {
      if (mounted) {
        initPlatformState();
      }
    });
  }

  Future<void> initPlatformState() async {
  .
  .
  .

Thanks @rodrigorahman for the amazing help

filipenanclarez avatar Dec 22 '21 16:12 filipenanclarez

Thanks for the great plugin and the possibility to display webviews under Windows.

I have a similar project to @filipenanclarez . A kind of In App Browser with dynamic tabs. I have the problem when creating a new webview and jumping to the new view - webview returns mounted false (with the workaround here) and the view is not initialised. The tab is changed but the content does not change.

I do not get an error message. If I jump back and forth between the tabs again, the view is initialised.

Can you give me a hint as to what this could be?

Normally 2 init calls are made. In the first one mounted is false and in the second one mounted is true and the view is initialised.

Sometimes, however, the second init call does not take place.

🐛 animate to:1 🐛 not mounted

Spitzbua avatar Jan 28 '22 10:01 Spitzbua

This issue seems to be fixed in my case with Flutter SDK 2.10.1.

Spitzbua avatar Feb 24 '22 16:02 Spitzbua

I use Flutter 3.10, but this issue still exists. May I ask if there is a solution?

pufaqi avatar May 18 '23 09:05 pufaqi