Symptom
After an autoplay sound page H5 access, Activity carrying H5 page is still playing in the background after the finish sound, can not be stopped, only the end of the process or the App acquisition system audio focus in another place so that the sound webview audio player loses focus sound stopped playing.
Troubleshooting steps
- Chrome, use
chrome://inspect
the link ADB commissioning - Activity H5 finish bearer page
- Chrome observed H5 page is still retained, and no garbage collection
solution
GC corresponds webview not recovered after this issue is very clear where the Activity is --WebView finish off.
So it should be active during the recovery WebView finish the corresponding Activity.
But not in a simple and crude method onDestory Activity recovered in the webview, as follows:
1 |
|
This issue will lead to that, when executed Activity onDestory, possible internal webview also attached to the parent control, then when the question of the establishment, the following exception is thrown, causing the program to stop running:Error: WebView.destroy() called while still attached
Therefore, the correct solution to this problem should be in the Activity of onDetachedFromWindow
the treatment method, a treatment protocol as follows:
1 |
|
Original: Big Box Android WebView memory leak pit