https://kotlinlang.org logo
#compose
Title
# compose
n

Noé Casas

02/16/2021, 3:19 PM
when using a WebView through AndroidView, sometimes the page is not shown. It appears to be random (the same page appears sometime, but sometimes it does not). When the problem happens, sometimes the following error shows up in logcat:
Copy code
2021-02-16 16:08:34.866 9683-9698/... E/System: Uncaught exception thrown by finalizer
2021-02-16 16:08:34.909 9683-9698/... E/System: java.lang.IllegalStateException: Warning: Router objects should be explicitly closed when no longer required otherwise you may leak handles.
        at w4.finalize(chromium-TrichromeWebViewGoogle.aab-stable-432415233:4)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:289)
        at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:276)
        at java.lang.Daemons$Daemon.run(Daemons.java:137)
        at java.lang.Thread.run(Thread.java:919)
     Caused by: java.lang.Exception: AutocloseableRouter allocated at:
        at w4.<init>(chromium-TrichromeWebViewGoogle.aab-stable-432415233:4)
        at vu.<init>(chromium-TrichromeWebViewGoogle.aab-stable-432415233:8)
        at org.chromium.content.browser.framehost.RenderFrameHostImpl.<init>(chromium-TrichromeWebViewGoogle.aab-stable-432415233:10)
        at org.chromium.content.browser.framehost.RenderFrameHostImpl.create(chromium-TrichromeWebViewGoogle.aab-stable-432415233:1)
        at J.N.MZAK3_Tx(Native Method)
        ...
The way I instantiate webview is :
Copy code
@Composable
fun WebViewView(html: String, ...) {
    AndroidView({ context ->
        val webView = WebView(context)
        // configure webview
        webview
    })
}
This have been happening in all compose versions I have tried. I have not found any similar problem in the bug tracker. Am I doing something wrong? Should I report a bug?
m

Mihai Popa

02/19/2021, 1:36 PM
Hey, yes, please do
52 Views