Multiple detached webview instances seen in chrome devices while navigating in hybrid android app

Communitynullpointer提出了一个问题:Multiple detached webview instances seen in chrome devices while navigating in hybrid android app,或许与您遇到的问题类似。

回答者Sunny R Gupta给出了该问题的处理方式:

So the way these web inspectors work is that they use the RemoteDebug Protocol.

This protocol defines the various messages and commands that are exchanged to let you 'inspect' your pages.

One instance of the inspector can only connect to one client at a time. So assuming that you are switching to and fro web-views and native context, you are basically spawning new webviews for every new context switch.

This would indicate that the previously opened webviews are now 'orphaned' and for all practical purposes detached.

You can try to inform the VM that a webview is no longer in use by calling destroy() on the webview to let the garbage collector know it is no longer required.

Hope this provides a deeper understanding on what is happening behind the scenes.

希望本文对你有帮助,欢迎支持JavaScript中文网