Detect available memory inside of a WebView

前端 未结 1 1604
后悔当初
后悔当初 2021-02-07 11:02

I\'m building an app that contains a WebView that runs some JavaScript code. That JavaScript code is quite allocation heavy and can require a lot of memory.

1条回答
  •  攒了一身酷
    2021-02-07 11:24

    I have discussed this with the Chromium team and the Android team and at the moment (they think and I believe them) that this is impossible.

    Sometimes, the amount of required memory exceeds the amount JavaScript can require and crashes the Chromium process of the WebView which crashes my app.

    You can however catch out of memory crashes in Android 8.0+ using the new termination handle API. So this works around my problem by not having to check the available memory required in the first place.

    By overriding onRenderProcessGone - we get to catch the bug and recreate the WebView.

    0 讨论(0)
提交回复
热议问题