Skip to content

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

Closed

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

  1. self-assigned this
    on Feb 19, 2024
  2. added
    upstreamRelated to an upstream bug (or should be at some point)
    on Mar 8, 2024
  3. eocanha commented on Mar 8, 2024

    @eocanha
    Member

    Fix patch submitted upstream for review as https://bugs.webkit.org/show_bug.cgi?id=270571 / WebKit/WebKit#25625.

  4. eocanha commented on Apr 10, 2024

    @eocanha
    Member

    The patch landed upstream as WebKit/WebKit@80dd62a and was backported to wpe-2.38 as 7877902.

  5. eocanha commented on Apr 11, 2024

    @eocanha
    Member

    ...and to the calvaris/wpe-2.42/upstream branch as 6de0ae1. Closing Issue.

  6. asurdej-comcast commented on Apr 15, 2024

    @asurdej-comcast
    Author

    Tested with the latest webkit build and all my cases work fine now. HTMLMediaElement is correctly destroyed.
    Also YT cert tests look much better now.
    Thanks @eocanha

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