While using a webview inside our own app, the webview process continually starts using more and more memory while alternating (every 20 seconds or so) between:
a) showing a 1080p video (which uses the exynos video decoder) behind some divs with text
b) a page which contains no video.
Every 15 minutes (give or take) the ActivityManager reports this:
system_process I/ActivityManager: Low on memory:
system_process I/ActivityManager: MemInfo: 34,992K slab, 15,776K shmem, 27,964K vm alloc, 11,576K page tables 5,936K kernel stack
820K buffers, 165,836K cached, 77,344K mapped, 179,596K free
Free RAM: 268,908K
Used RAM: 96,244K
Lost RAM: 1,681,576K
The low memory message happens a couple of times before crashing the webview process.
I've enable out-of-process webviews to see if that changes behaviour, but this does not help.
I've also tried to destroy each WebView before recreating a new one, instead of using the same one continuously, this does not help either. (Not suprising, since it doesn't seem to spawn a new process on the machine, but keeps on using the same WebView process). Force-closing the app and restarting does help ofcourse, but this is obviously not the intended way to handle this.
Under Android 5.1.1, this just crashes the app within 15-minutes with a OOM error. Under Android 7.1 this takes a bit longer, but eventually also crashes the app (with the ActivityManager reports above still happening every 15 minutes).
We're able to reproduce it 100% of the time. We've tried Chrome as a Webview, but also the Android system webview and AOSP webview (compiled by myself).
We're also using the Odroid C2 on Android 5.1.1 and on this system, this crash does not occur, no matter how long we run the pages.
Alternating between these pages on stock Chrome also causes memory leaks and eventually a crash. But since we're using webviews in our app (and having to manually click play on every video), WebView's our primary concern.
The debug messages that most stand out to me are:
02-16 15:29:12.999 16578-23771/com.my.app.name W/cr_MediaCodecBridge: calling MediaCodec.release() on OMX.Exynos.AVC.Decoder
02-16 15:29:13.007 2945-23788/? W/libexynosv4l2: failed to ioctl: VIDIOC_DQBUF (22 - Invalid argument)
02-16 15:29:13.014 16578-23774/com.my.app.name E/BufferQueueProducer: [SurfaceTexture-55-16578-58] cancelBuffer: BufferQueue has been abandoned
(That last message is repeated 8 times with slightly changing timestamps)
It crashes with out of memory errors on Android 5.1.1.
It crashes without out of memory error on Android 7.1.
I'm able to quickly compile Android and WebView myself, so if i can assist in squating this bug, i'd love to help.
(In my limited understanding of the V4L2 subsystem, i think the video buffer isn't released properly while unloading the page containing the video, i've attached the full logcat while running under Android 7.1)