Bug 82421 - REGRESSION(r110064): audio elements can keep the DOM alive after the user has navigated away
Summary: REGRESSION(r110064): audio elements can keep the DOM alive after the user has...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac Unspecified
: P1 Normal
Assignee: Stephanie Lewis
URL:
Keywords: InRadar
: 81781 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-03-27 20:30 PDT by Stephanie Lewis
Modified: 2012-03-28 18:03 PDT (History)
10 users (show)

See Also:


Attachments
patch (2.12 KB, patch)
2012-03-27 20:40 PDT, Stephanie Lewis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephanie Lewis 2012-03-27 20:30:40 PDT
Testing on Lion.  Regression occurred http://trac.webkit.org/projects/webkit/changeset/110064.  

I believe this change has a typo.  I think the ! needs to be eliminated.

-            if (!static_cast<HTMLAudioElement*>(node)->paused())
+            if (!static_cast<HTMLAudioElement*>(node)->hasPendingActivity())


As it stands an HTMLAudioElement is observable when it is not waiting for any events.  This means that the DOM can never be cleaned up when a user navigates away from the page.  Observed on http://twitter.com.

<rdar://problem/11135186> REGRESSION: audio elements with pending activity progressively slow down the PLT3.
Comment 1 Stephanie Lewis 2012-03-27 20:40:00 PDT
Created attachment 134210 [details]
patch

Uploaded a patch to fix the if statement, but I'm not sure if it is possible to write a test to show the bug.
Comment 2 Philippe Normand 2012-03-27 23:58:35 PDT
*** Bug 81781 has been marked as a duplicate of this bug. ***
Comment 3 Philippe Normand 2012-03-28 00:02:34 PDT
(In reply to comment #1)
> Created an attachment (id=134210) [details]
> patch
> 
> Uploaded a patch to fix the if statement, but I'm not sure if it is possible to write a test to show the bug.

A nice list of media tests are flaky on GTK because of this issue, thanks for looking into it and sorry, I'm a bit embarassed :)
Comment 4 Philippe Normand 2012-03-28 00:19:42 PDT
I've just checked that with your patch those media tests are no longer flaky on GTK:

media/W3C/audio/networkState/networkState_during_loadstart.html
media/audio-delete-while-step-button-clicked.html
media/audio-mpeg-supported.html
media/audio-repaint.html
media/media-controls-clone-crash.html
media/audio-repaint.html


If you could unskip them as part of your patch it'd be great.

media/audio-garbage-collect.html is now failing though. I'll have a look at this one again soon.
Comment 5 Alexey Proskuryakov 2012-03-28 11:56:45 PDT
I don't think that this kind of change requires a regression test. Please upload an updated patch and mark it for review.
Comment 6 Geoffrey Garen 2012-03-28 12:55:19 PDT
I think it would be even better just to revert http://trac.webkit.org/projects/webkit/changeset/110064 and consult Eric and Jer about what the best fix is. It's not clear that HTMLAudioElement::hasPendingActivity is the right test for GC.
Comment 7 Stephanie Lewis 2012-03-28 14:59:14 PDT
Jer wasn't convinced that the original fix was correct, but said I should talk to Eric.  Since it is such a bad performance bug I'm rolling out until I can catch up with Eric and find the right fix.
Comment 8 Geoffrey Garen 2012-03-28 15:33:41 PDT
In the end, what we need is a DOM API that is true when the audio node is waiting for an event to fire, for a load to complete, or for playing to end, and is *guaranteed* to become false if the node is removed from the document or the window is closed or navigated away from.
Comment 9 Eric Carlson 2012-03-28 17:41:24 PDT
(In reply to comment #6)
> I think it would be even better just to revert http://trac.webkit.org/projects/webkit/changeset/110064 and consult Eric and Jer about what the best fix is. It's not clear that HTMLAudioElement::hasPendingActivity is the right test for GC.

HTMLAudioElement::hasPendingActivity is definitely NOT the correct test. The reason that we care about this is that the spec says when a media element can be collected:

    Media elements that are potentially playing while not in a Document 
    must not play any video, but should play any audio component. Media 
    elements must not stop playing just because all references to them 
    have been removed; only once a media element is in a state where 
    no further audio could ever be played by that element may the 
    element be garbage collected.

and "potentially playing" is defined as:

    A media element is said to be potentially playing when its paused 
    attribute is false, the element has not ended playback, playback has 
    not stopped due to errors, the element either has no current media 
    controller or has a current media controller but is not blocked on its 
    media controller, and the element is not a blocked media element.

As it happens, we have HTMLMediaElement::potentiallyPlaying because "potentially playing" is used in other parts of the media element spec.
Comment 10 Stephanie Lewis 2012-03-28 18:03:50 PDT
Rolled out in http://trac.webkit.org/projects/webkit/changeset/112483

I reopened the original bug for doing the correct fix. (https://bugs.webkit.org/show_bug.cgi?id=72698)