Bug 109644 - MediaKeySession should not be GCd while firing event listeners or with custom properties.
Summary: MediaKeySession should not be GCd while firing event listeners or with custom...
Status: RESOLVED DUPLICATE of bug 129841
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jer Noble
URL:
Keywords:
Depends on: 109702
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-12 18:09 PST by Jer Noble
Modified: 2014-06-04 00:34 PDT (History)
3 users (show)

See Also:


Attachments
Patch (5.28 KB, patch)
2013-02-12 22:16 PST, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (9.28 KB, patch)
2013-02-12 22:19 PST, Jer Noble
no flags Details | Formatted Diff | Diff
Patch (21.50 KB, patch)
2013-02-15 15:24 PST, Jer Noble
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jer Noble 2013-02-12 18:09:45 PST
MediaKeySession should not be GCd while firing event listeners or with custom properties.
Comment 1 Jer Noble 2013-02-12 21:46:58 PST
I find that I'm having a very hard time writing a LayoutTest for this case.  How does one write a layout test to check whether an object has been GCd without holding a reference to that object (and thus keeping it from being GCd)?
Comment 2 Jer Noble 2013-02-12 22:16:21 PST
Created attachment 188011 [details]
Patch
Comment 3 Jer Noble 2013-02-12 22:19:49 PST
Created attachment 188012 [details]
Patch

This time, with project changes.
Comment 4 Geoffrey Garen 2013-02-14 10:53:51 PST
> I find that I'm having a very hard time writing a LayoutTest for this case.  How does one write a layout test to check whether an object has been GCd without holding a reference to that object (and thus keeping it from being GCd)?

mediaKeys.mediaKeySession.customProperty = 1;
gc();
if (mediaKeys.mediaKeySession.customProperty)
    pass();
else
    fail();

Here, your only explicit reference is to the MediaKeys object, and not the MediaKeySession object.
Comment 5 Geoffrey Garen 2013-02-14 10:55:52 PST
Comment on attachment 188012 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=188012&action=review

> Source/WebCore/bindings/js/JSMediaKeySessionCustom.cpp:54
> +    return visitor.containsOpaqueRoot(mediaKeySession->keys());

This line will only keep the MediaKeySession object alive if another object has called "visitor.addOpaqueRoot(keys)".

If you want a MediaKeys object to keep a MediaKeySession object alive, you also need MediaKeys to call "visitor.addOpaqueRoot(keys)".
Comment 6 Geoffrey Garen 2013-02-14 11:24:36 PST
Further review on IRC:

ggaren: jer: so, here's what you need:
[11:14am] ggaren: jer: (1) MediaKeySession needs to adopt the ActiveDOMObject API, so it won't GC in the middle of scheduled stuff
[11:15am] jer: yep.
[11:15am] ggaren: jer: (2) MediaKeySession needs to adopt the isReachable API, but only for the purpose of event listeners, and this should be automatic for any subclass of EventTarget -- so just double-check that it is auto-generated
[11:16am] jer: okay, i looked into that, and it does do it for event listeners, but not custom properties…. *double checks*
[11:17am] jer: oh never mind, it's both
[11:17am] jer: ok
[11:18am] ggaren: jer: (3) double-check that the automatic isReachable for event listener checks for isFiringEventListeners -- this might be an oversight in the auto generated code, which you should fix (one-line change in the auto generater)
[11:18am] jer: so, what about the "isFiringEventLiseteners" part? that should be handled by bumping ...
[11:18am] jer: okay, EventTarget doesn't check isFiringEventLiseteners.
[11:18am] ggaren: jer: i think that's a missing feature in the auto generator, which you should correct
[11:18am] jer: lol. ok.
[11:19am] ggaren: (4) MediaKeys needs to to check visitor.containsOpaqueRoot(root(HTMLMediaElement)) -- because of the HTMLMediaElement.mediaKeys API
Comment 7 Jer Noble 2013-02-15 15:24:46 PST
Created attachment 188652 [details]
Patch
Comment 8 Jer Noble 2013-02-15 15:48:34 PST
Depends on bug #109702 for the mediaElement accessor on MediaKeys.
Comment 9 Jer Noble 2013-02-15 15:59:10 PST
Whoops, an extra entry in the LayoutTests/ChangeLog.  I'll remove it before landing (or an upcoming version, depending).
Comment 10 Brent Fulgham 2014-04-24 09:21:35 PDT
(In reply to comment #9)
> Whoops, an extra entry in the LayoutTests/ChangeLog.  I'll remove it before landing (or an upcoming version, depending).

Wow -- did this ever get landed? Seems important!
Comment 11 Jer Noble 2014-04-25 10:27:12 PDT
This was fixed by bug #129841.

*** This bug has been marked as a duplicate of bug 129841 ***
Comment 12 Csaba Osztrogonác 2014-06-04 00:34:30 PDT
Comment on attachment 188652 [details]
Patch

Cleared review? from attachment 188652 [details] so that this bug does not appear in http://webkit.org/pending-review.  If you would like this patch reviewed, please attach it to a new bug (or re-open this bug before marking it for review again).