Skip to content

[wpe-2.38] <video> element is never destoyed when using modern media controls #1285

Description

@asurdej-comcast

We observe increased memory consumption for wpe webkit 2.38 (comparing to 2.28) when running YT cert tests. It sometimes leads to OOM killer as WPEWebProcess uses ~550MB of memory despite much lower memory pressure settings.

YT creates separete <video> element for each test. Initial analysis shows that HTMLMediaElement (s) are never destroyed during execution. Also manually triggering GarbageCollector from RWI doesn't help, nothing is destoryd.
Together with HTMLMediaElement there are many other objects that are connected, like SourceBuffers, MediaKeys, etc. As a result memory usage is growing constantly triggering OOM eventually.

Looking into JS sources it looks like enabling video controls attribute is the reason here. When media controls are disabled then issue is not observed. With 2.38 media controls impl changed -> modern media controls was enabled that seems to be the reason here.

Here is a javascript code that reproduces the issue. I use "collect garbage" button from RWI to trigger GC and check if ~HTMLMediaElement() is called:

var vid;
var ms;

function test() {
    vid = document.createElement("video");
    document.body.appendChild(vid);

    vid.controls = true;

    ms = new MediaSource;
    ms.addEventListener('sourceopen', function(e) {
        vid.pause();
        URL.revokeObjectURL(vid.src);
        vid.src = '';
        vid.removeAttribute('src');
        vid.load();
        vid.parentNode.removeChild(vid);

        vid = null;
        ms = null;
    });
    vid.src = URL.createObjectURL(ms);
}

Note that skipping video.controls(true) or not attaching video element into document's body works perfectly fine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

upstreamRelated to an upstream bug (or should be at some point)wpe-2.38

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions