I am trying to send web message to WebView in Android.
When running code from this example: https://github.com/commonsguy/cw-omnibus/tree/master/WebKit/SensorPort
Calling:
wv.postWebMessage(new WebMessage("", new WebMessagePort[]{channel[1]}), Uri.EMPTY);
causes following exception:
com.commonsware.android.webkit.bridge.port E/System: Uncaught exception thrown by finalizer
com.commonsware.android.webkit.bridge.port E/System: java.lang.IllegalStateException: Warning: Router objects should be explicitly closed when no longer required otherwise you may leak handles.
at TM.finalize(chromium-TrichromeWebViewGoogle.apk-stable-410410681:4)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:291)
at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:278)
at java.lang.Daemons$Daemon.run(Daemons.java:139)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.Exception: AutocloseableRouter allocated at:
at TM.<init>(chromium-TrichromeWebViewGoogle.apk-stable-410410681:7)
at DP.<init>(chromium-TrichromeWebViewGoogle.apk-stable-410410681:6)
at org.chromium.content.browser.framehost.RenderFrameHostImpl.<init>(chromium-TrichromeWebViewGoogle.apk-stable-410410681:10)
at org.chromium.content.browser.framehost.RenderFrameHostImpl.create(chromium-TrichromeWebViewGoogle.apk-stable-410410681:1)
at J.N.MjidYpBx(Native Method)
at org.chromium.content.browser.webcontents.WebContentsImpl.r0(chromium-TrichromeWebViewGoogle.apk-stable-410410681:3)
at K7.g(chromium-TrichromeWebViewGoogle.apk-stable-410410681:5)
at com.android.webview.chromium.WebViewChromium.postMessageToMainFrame(chromium-TrichromeWebViewGoogle.apk-stable-410410681:4)
at android.webkit.WebView.postWebMessage(WebView.java:1971)
at com.commonsware.android.webkit.bridge.MainActivity.initPort(MainActivity.java:118)
at com.commonsware.android.webkit.bridge.MainActivity.access$100(MainActivity.java:35)
at com.commonsware.android.webkit.bridge.MainActivity$1.onPageFinished(MainActivity.java:60)
at Fa.b(chromium-TrichromeWebViewGoogle.apk-stable-410410681:2)
at Cs.handleMessage(chromium-TrichromeWebViewGoogle.apk-stable-410410681:65)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I am using emulator with api 30.
What does this exception mean? Does the code have a memory leak? How can I fix it?