RESOLVED FIXED 45306
Media elements should derive from ActiveDOMObjects
https://bugs.webkit.org/show_bug.cgi?id=45306
Summary Media elements should derive from ActiveDOMObjects
Eric Carlson
Reported 2010-09-07 09:57:47 PDT
Media elements should derive from ActiveDOMObjects instead of implementing documentWillBecomeInactive/documentDidBecomeActive. It will allow us to prevent the object from being collected when it has pending events in the async event queue, which causes an assert in a debug build and a potential crash in a release build, and to remove the <audio> specific code from isObservableThroughDOM.
Attachments
proposed patch (4.63 KB, patch)
2010-09-07 10:39 PDT, Eric Carlson
darin: review+
Eric Carlson
Comment 1 2010-09-07 09:58:54 PDT
Eric Carlson
Comment 2 2010-09-07 10:39:35 PDT
Created attachment 66739 [details] proposed patch
WebKit Review Bot
Comment 3 2010-09-07 10:41:34 PDT
Attachment 66739 [details] did not pass style-queue: Failed to run "['WebKitTools/Scripts/check-webkit-style']" exit_code: 1 WebCore/html/HTMLMediaElement.h:32: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 1 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
Eric Carlson
Comment 4 2010-09-07 10:42:26 PDT
This patch doesn't add a test case because https://bugs.webkit.org/show_bug.cgi?id=45309 allows the object to be collected even when it has pending events. Getting these changes in now will make it easier to reproduce that crash.
Simon Fraser (smfr)
Comment 5 2010-09-07 10:50:13 PDT
Want to take bug 24030 too?
Darin Adler
Comment 6 2010-09-07 10:59:14 PDT
Comment on attachment 66739 [details] proposed patch Do we already have tests that cover a media element with pending events where we force the last reference to be garbage collected? > + // ActiveDOMObject methods. I prefer that we use the C++ terminology. So "functions" rather than "methods". > + virtual bool canSuspend() const { return true; } There doesn’t seem to be significant benefit to putting this definition in the header, since it’s a virtual function that will only be called through a function pointer. I suggest putting it in the .cpp file instead. It's too bad that the stop function is calling another virtual function, suspend, doing an unnecessary virtual dispatch. Not a major problem, but slightly unpleasant. Instead it could call HTMLMediaElement::suspend(), but that would strange enough that we probably shouldn't do it. The headers in HTMLMediaElement.h should stay sorted alphabetically. I bet that is what our stylebot is complaining about.
Eric Carlson
Comment 7 2010-09-07 11:09:13 PDT
(In reply to comment #6) > (From update of attachment 66739 [details]) > Do we already have tests that cover a media element with pending events where we force the last reference > to be garbage collected? > The crashing test case attached to https://bugs.webkit.org/show_bug.cgi?id=45309 does exactly that. > > + // ActiveDOMObject methods. > > I prefer that we use the C++ terminology. So "functions" rather than "methods". > Done. > > + virtual bool canSuspend() const { return true; } > > There doesn’t seem to be significant benefit to putting this definition in the header, since it’s a virtual function > that will only be called through a function pointer. I suggest putting it in the .cpp file instead. > Done. > > The headers in HTMLMediaElement.h should stay sorted alphabetically. I bet that is what our stylebot is > complaining about. Fixed that too. Thanks!
Eric Carlson
Comment 8 2010-09-07 11:30:34 PDT
Alexey Proskuryakov
Comment 9 2010-09-08 13:13:35 PDT
As discussed in person, a problem with this is that ActiveDOMObjects are also suspended below modal dialogs and alerts, as well as by Web Inspector. We probably don't want that for media elements, although we do want to consolidate document inactivation code.
Eric Carlson
Comment 10 2010-09-14 13:11:48 PDT
(In reply to comment #9) > As discussed in person, a problem with this is that ActiveDOMObjects are also suspended below > modal dialogs and alerts, as well as by Web Inspector. We probably don't want that for media > elements, although we do want to consolidate document inactivation code. http://trac.webkit.org/changeset/67432 fix this.
Ademar Reis
Comment 11 2011-01-24 12:18:00 PST
Revision r66895 cherry-picked into qtwebkit-2.2 with commit e5e1392 <http://gitorious.org/webkit/qtwebkit/commit/e5e1392>
Note You need to log in before you can comment on or make changes to this bug.