Bug 47129 - PluginDocumentParser::pluginWidgetFromDocument should look for "embed" element rather than just use the first child
Summary: PluginDocumentParser::pluginWidgetFromDocument should look for "embed" elemen...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-04 16:04 PDT by sanjeevr
Modified: 2010-10-06 18:43 PDT (History)
4 users (show)

See Also:


Attachments
Patch for the fix (2.19 KB, patch)
2010-10-04 16:44 PDT, sanjeevr
fishd: review-
fishd: commit-queue-
Details | Formatted Diff | Diff
Updated patch with unrelated changes removed. (1.63 KB, patch)
2010-10-04 17:28 PDT, sanjeevr
no flags Details | Formatted Diff | Diff
Fixed spaces. (1.59 KB, patch)
2010-10-04 18:30 PDT, sanjeevr
no flags Details | Formatted Diff | Diff
New implementation that relies on PluginDocument remembering the plugin node. (3.70 KB, patch)
2010-10-05 15:51 PDT, sanjeevr
no flags Details | Formatted Diff | Diff
Fixed memory leak caused by circular ref count (1.65 KB, patch)
2010-10-06 17:03 PDT, sanjeevr
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sanjeevr 2010-10-04 16:04:25 PDT
PluginDocumentParser::pluginWidgetFromDocument assumes that the "embed" element is the first child of the body. However, for Chromium, an extension can modify the DOM to add other elements before the "embed" element. The method should search for the "embed" element rather than use the first child. Working on a fix for this. This causes the Chromium bug (http://crbug.com/51342).
Comment 1 sanjeevr 2010-10-04 16:44:35 PDT
Created attachment 69719 [details]
Patch for the fix
Comment 2 Darin Fisher (:fishd, Google) 2010-10-04 17:04:09 PDT
Comment on attachment 69719 [details]
Patch for the fix

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

> WebCore/html/PluginDocument.cpp:-87
> -#if ENABLE(OFFLINE_WEB_APPLICATIONS)

oops
Comment 3 sanjeevr 2010-10-04 17:28:46 PDT
Created attachment 69726 [details]
Updated patch with unrelated changes removed.
Comment 4 sanjeevr 2010-10-04 18:30:58 PDT
Created attachment 69727 [details]
Fixed spaces.
Comment 5 WebKit Commit Bot 2010-10-05 01:43:00 PDT
Comment on attachment 69727 [details]
Fixed spaces.

Clearing flags on attachment: 69727

Committed r69097: <http://trac.webkit.org/changeset/69097>
Comment 6 WebKit Commit Bot 2010-10-05 01:43:05 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Alexey Proskuryakov 2010-10-05 11:42:29 PDT
There is a discussion of this change on webkit-changes mailing list.
Comment 8 sanjeevr 2010-10-05 15:51:32 PDT
Created attachment 69856 [details]
New implementation that relies on PluginDocument remembering the plugin node.
Comment 9 sanjeevr 2010-10-05 15:55:05 PDT
Uploaded new implementation as per discussion on webkit-changes.
Comment 10 Darin Fisher (:fishd, Google) 2010-10-05 15:59:57 PDT
Comment on attachment 69856 [details]
New implementation that relies on PluginDocument remembering the plugin node.

This does seem much better.  Thanks!
Comment 11 mitz 2010-10-05 16:07:26 PDT
Comment on attachment 69856 [details]
New implementation that relies on PluginDocument remembering the plugin node.

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

> WebCore/html/PluginDocument.h:60
> +    RefPtr<Node> m_pluginNode;

Is it okay for a Document to hold a reference to a node like this? Won’t it create a ref cycle and cause a leak?
Comment 12 WebKit Commit Bot 2010-10-05 16:15:21 PDT
Comment on attachment 69856 [details]
New implementation that relies on PluginDocument remembering the plugin node.

Clearing flags on attachment: 69856

Committed r69159: <http://trac.webkit.org/changeset/69159>
Comment 13 WebKit Commit Bot 2010-10-05 16:15:27 PDT
All reviewed patches have been landed.  Closing bug.
Comment 14 sanjeevr 2010-10-05 17:33:05 PDT
Comment on attachment 69856 [details]
New implementation that relies on PluginDocument remembering the plugin node.

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

>> WebCore/html/PluginDocument.h:60
>> +    RefPtr<Node> m_pluginNode;
> 
> Is it okay for a Document to hold a reference to a node like this? Won’t it create a ref cycle and cause a leak?

Yeah I was concerned about that too. But I was also afraid of holding on to a pointer that was no longer valid. I did some debugging and found that it does indeed cause a ref cycle. I can change it to Node* but I am not sure when to clear this variable. Any suggestions?
Comment 15 mitz 2010-10-05 17:36:47 PDT
(In reply to comment #14)
> (From update of attachment 69856 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=69856&action=review
> 
> >> WebCore/html/PluginDocument.h:60
> >> +    RefPtr<Node> m_pluginNode;
> > 
> > Is it okay for a Document to hold a reference to a node like this? Won’t it create a ref cycle and cause a leak?
> 
> Yeah I was concerned about that too. But I was also afraid of holding on to a pointer that was no longer valid. I did some debugging and found that it does indeed cause a ref cycle. I can change it to Node* but I am not sure when to clear this variable. Any suggestions?

I asked and was told that this does not cause a leak.
Comment 16 sanjeevr 2010-10-05 17:54:46 PDT
Comment on attachment 69856 [details]
New implementation that relies on PluginDocument remembering the plugin node.

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

>>>> WebCore/html/PluginDocument.h:60
>>>> +    RefPtr<Node> m_pluginNode;
>>> 
>>> Is it okay for a Document to hold a reference to a node like this? Won’t it create a ref cycle and cause a leak?
>> 
>> Yeah I was concerned about that too. But I was also afraid of holding on to a pointer that was no longer valid. I did some debugging and found that it does indeed cause a ref cycle. I can change it to Node* but I am not sure when to clear this variable. Any suggestions?
> 
> I asked and was told that this does not cause a leak.

Hmm, I did some debugging on Windows Chromium and it did seem to cause a leak. Maybe I missed something. I will debug some more and update this bug. Thanks for the help.
Comment 17 sanjeevr 2010-10-06 17:03:24 PDT
Created attachment 70014 [details]
Fixed memory leak caused by circular ref count
Comment 18 sanjeevr 2010-10-06 17:03:45 PDT
Last patch had a memory leak. Fixed that.
Comment 19 Darin Fisher (:fishd, Google) 2010-10-06 17:06:46 PDT
Comment on attachment 70014 [details]
Fixed memory leak caused by circular ref count

R=me, thanks Sanjeev!
Comment 20 WebKit Commit Bot 2010-10-06 18:43:10 PDT
Comment on attachment 70014 [details]
Fixed memory leak caused by circular ref count

Clearing flags on attachment: 70014

Committed r69268: <http://trac.webkit.org/changeset/69268>
Comment 21 WebKit Commit Bot 2010-10-06 18:43:16 PDT
All reviewed patches have been landed.  Closing bug.