overlay_webview
overlay_webview copied to clipboard
PlatformException(webview_not_found, WebView with ID webview_1 not found, null, null)
The plugin is awesome.
We use this plugin to show trading charts in our mobile app. Which is one of the most crucial feature in a trading app.
Every time the app runs there are several instances of this error which gets logged. This decreases our crash free users percentage also. We know that this a silent exception and doesn't bothers our users. But we want to dig into this and fix it.
Please help to fix. Any basic context on how to debug this will be kind enough. @ajinasokan CC - @amit-astha
PlatformException(webview_not_found, WebView with ID webview_1 not found, null, null)
I/flutter ( 7474): From Zoned Guarded
I/flutter ( 7474): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
I/flutter ( 7474): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18)
I/flutter ( 7474): <asynchronous suspension>
I/flutter ( 7474): #2 WebViewController.load (package:overlay_webview/src/controller.dart:203:5)
I/flutter ( 7474): <asynchronous suspension>
So this plugin is actually not in a condition for public use 😅, it was written specifically for the apps I work on. Thats why it is still not on pub.dev. I haven't really covered all the edge cases. I think you are hitting one of them.
This error happens when the native webview is either not initialized or got disposed before loading the URL. Do you keep an instance of WebViewController
separately and supply it to WebView
? Do you call WebViewController.dispose()
anywhere in the code? If yes you have to make sure you do that only in the State's dispose function.
If you could paste a wire frame code snippet of how you use WebViewController
and WebView
classes I can check where it might go wrong.
In the crash logs is it always webview_1
? Or do you see webview_2
or webview_3
etc.?
Also post the result of WebViewController.activeWebViews()
after you open the webview normally once. This would give a hint on if the a webview is created and disposed unnecessarily somewhere else.