[Webkit-unassigned] [Bug 66878] New: HTMLAudioElement can be garbage collected while it playing

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Aug 24 12:15:11 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=66878

           Summary: HTMLAudioElement can be garbage collected while it
                    playing
           Product: WebKit
           Version: 420+
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P1
         Component: Media Elements
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: enal at google.com


According to

http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#playing-the-media-resource

"4.8.10.8 Playing the media resource [...] 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. [...]"

Unfortunately, that is not so with HTMLAudioElement. Original bug is Chrome one:

http://code.google.com/p/chromium/issues/detail?id=62604

That happens because Chrome internally uses HTMLAudioElement for its media player, and that element is garbage collected. Here is simple script that demonstrates the problem:

<html>
<body>
<hl> Test page </hl>
<script type="text/javascript">
function gc()
{
 if (window.GCController)
   return GCController.collect();

 for (var i = 0; i < 1000; i++) {
   var s = new ArrayBuffer(10000);
 }
}

var begin_ms;
var a = new Audio("file://c:/temp/bwep.wav");
a.addEventListener('ended', function() {
 var end_ms = new Date().getTime();
 var duration_ms = end_ms - begin_ms;
 document.write("<p>Ended: " + duration_ms + "</p>");
});
a.addEventListener('canplaythrough', function() {
 document.write("<p>CanPlayThrough</p>");
 begin_ms = new Date().getTime();
 a.play();
 a = null;
 gc();
});
</script>
</body>
</html>

You can use any sound file that is longer than ~1 second.

On Chrome, sound starts playing, but then abruptly stops, and no 'ended' event is ever fired.

I believe I have simple fix, will submit is shortly.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list