Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Issue 2586633002: Dispose a persisted plugin widget if the content frame is detached. (Closed)

Created:
4 years ago by dcheng
Modified:
4 years ago
Reviewers:
esprehn, sof
CC:
blink-reviews, blink-reviews-html_chromium.org, bokan, chromium-reviews, dglazkov+blink
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Dispose a persisted plugin widget if the content frame is detached. HTMLPlugInElement::removedFrom() clears persisted plugin widgets, to prevent reuse of a widget associated with a destroyed object. However, when nodes containing connected subframes are removed from a Document, it is possible to synchronously trigger script after subframes are detached, but before the nodes themselves are actually removed. This can cause a FrameView for a detached frame to be incorrectly reused. BUG=671331 Committed: https://crrev.com/9485e0d3ee1ec3d8bd5578b7ed4493855cfc9898 Cr-Commit-Position: refs/heads/master@{#439339}

Patch Set 1 #

Total comments: 10

Patch Set 2 : Make layout test more testharness.js-y and address comments. #

Patch Set 3 : Fix typos #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+56 lines, -7 lines) Patch
A third_party/WebKit/LayoutTests/fast/plugins/update-plugin-after-detachment-crash.html View 1 2 1 chunk +40 lines, -0 lines 2 comments Download
M third_party/WebKit/Source/core/html/HTMLFrameOwnerElement.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/html/HTMLPlugInElement.h View 4 chunks +8 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp View 2 chunks +7 lines, -0 lines 6 comments Download

Messages

Total messages: 26 (10 generated)
dcheng
Widgets are the gift that keep on giving. bokan's original CL (https://codereview.chromium.org/2560803002/) addressed one other ...
4 years ago (2016-12-17 01:40:49 UTC) #4
esprehn
lgtm w/ some nits. I have such nightmares from the widget tree. :( https://codereview.chromium.org/2586633002/diff/1/third_party/WebKit/LayoutTests/fast/plugins/update-plugin-after-detachment-crash.html File ...
4 years ago (2016-12-17 01:47:56 UTC) #5
dcheng
I ended up rewriting the test to be more testharness.js-y, just to familiarize myself with ...
4 years ago (2016-12-17 09:08:13 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2586633002/40001
4 years ago (2016-12-17 09:08:16 UTC) #11
dcheng
(Adding some review comments for things that mystified me in the reduced test case... maybe ...
4 years ago (2016-12-17 09:09:43 UTC) #12
commit-bot: I haz the power
Committed patchset #3 (id:40001)
4 years ago (2016-12-17 12:35:36 UTC) #15
commit-bot: I haz the power
Patchset 3 (id:??) landed as https://crrev.com/9485e0d3ee1ec3d8bd5578b7ed4493855cfc9898 Cr-Commit-Position: refs/heads/master@{#439339}
4 years ago (2016-12-17 12:41:37 UTC) #17
sof
https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp File third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp (right): https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp#newcode212 third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp:212: // TODO(dcheng): This UpdateSuspendScope doesn't seem to provide much; ...
4 years ago (2016-12-17 15:01:53 UTC) #18
dcheng
https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp File third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp (right): https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp#newcode212 third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp:212: // TODO(dcheng): This UpdateSuspendScope doesn't seem to provide much; ...
4 years ago (2016-12-17 20:20:02 UTC) #19
sof
https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp File third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp (right): https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp#newcode212 third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp:212: // TODO(dcheng): This UpdateSuspendScope doesn't seem to provide much; ...
4 years ago (2016-12-17 21:47:28 UTC) #20
dcheng
https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp File third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp (right): https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp#newcode212 third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp:212: // TODO(dcheng): This UpdateSuspendScope doesn't seem to provide much; ...
4 years ago (2016-12-18 06:40:39 UTC) #21
sof
On 2016/12/18 06:40:39, dcheng wrote: > https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp > File third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp (right): > > https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp#newcode212 > ...
4 years ago (2016-12-18 06:54:41 UTC) #22
dcheng
On 2016/12/18 06:54:41, sof wrote: > On 2016/12/18 06:40:39, dcheng wrote: > > > https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp ...
4 years ago (2016-12-18 07:05:54 UTC) #23
sof
On 2016/12/18 07:05:54, dcheng wrote: > On 2016/12/18 06:54:41, sof wrote: > > On 2016/12/18 ...
4 years ago (2016-12-18 07:29:08 UTC) #24
dcheng
On 2016/12/18 07:29:08, sof wrote: > On 2016/12/18 07:05:54, dcheng wrote: > > On 2016/12/18 ...
4 years ago (2016-12-18 08:09:42 UTC) #25
dcheng
4 years ago (2016-12-18 10:40:37 UTC) #26
Message was sent while issue was closed.
On 2016/12/18 08:09:42, dcheng wrote:
> On 2016/12/18 07:29:08, sof wrote:
> > On 2016/12/18 07:05:54, dcheng wrote:
> > > On 2016/12/18 06:54:41, sof wrote:
> > > > On 2016/12/18 06:40:39, dcheng wrote:
> > > > >
> > > >
> > >
> >
>
https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Sour...
> > > > > File third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp
(right):
> > > > > 
> > > > >
> > > >
> > >
> >
>
https://codereview.chromium.org/2586633002/diff/40001/third_party/WebKit/Sour...
> > > > > third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp:212: //
> > > > TODO(dcheng):
> > > > > This UpdateSuspendScope doesn't seem to provide much;
> > > > > On 2016/12/17 21:47:28, sof wrote:
> > > > > > On 2016/12/17 20:20:02, dcheng wrote:
> > > > > > > On 2016/12/17 15:01:53, sof wrote:
> > > > > > > > Given that the persisted-widget detach happens slightly earlier
> now,
> > > is
> > > > > this
> > > > > > > > override still needed?
> > > > > > > 
> > > > > > > For now, yes. If I understand this correctly, PluginViews won't be
> > > > detached
> > > > > by
> > > > > > > disconnectContentFrame(). My long-term plan is to move  widget
> > disposal
> > > > into
> > > > > > > ChildFrameDisconnector, which will allow this to be removed. I
also
> > plan
> > > > on
> > > > > > > making plugin loads respect SubframeLoadingDisabler.
> > > > > > > 
> > > > > > 
> > > > > > WebPluginContainerImpl won't separately call removedFrom(), as far
as
> i
> > > > know.
> > > > > 
> > > > > WebPluginContainerImpl won't, but things like
ContainerNode::removeChild
> > > will
> > > > > detach the layout tree (which may persist a widget), and then notify
the
> > > Node
> > > > > that it was removed (which is when we clear any persisted widget).
This
> > path
> > > > is
> > > > > not covered by frame disconnection.
> > > > 
> > > > Hmm, removeChild() always runs willRemoveChild() first.
> > > 
> > > It does... but something with a PluginView won't have a content frame, and
> > won't
> > > get processed by ChildFrameDisconnector.
> > 
> > ok, we're probably looking at different code, but ChildFrameDisconnector
works
> > over frame owners. Which HTMLPluginElement is.
> 
> Ah, I understand now. I was mixing up persisted widget and widget when
reasoning
> through this. I think you're right, and I'll try cleaning that up in a follow
> up.
> 
> The reason it's OK to skip this in removedFrom is because the AttachContext
> during Node removal will never be marked as for reattach, so we will never
> persist a widget in that case. Thus, by the time we get to removedFrom, we
> should be able to assert that there is no persisted widget at all.

Actually, I thought about this a bit more, and the removedFrom block is still
necessary.
ChildFrameDisconnector only disconnects connected subframes. Embeds with actual
plugins loaded aren't considered connected subframes, and won't have
disconnectContentFrame() called.

My plan is to make ChildFrameDiconnector also handle loaded widgets, though
there's a question of how best to track them: we currently maintain connected
subframe count in NodeRareData, so we can optimize the tree walk to only visit
nodes that actually have connected subframes. I'm thinking of resurrecting
https://codereview.chromium.org/1770523002/ for this purpose: our current frame
limit is set based on how many bits we have to use in NodeRareData for counting
this.

Or we could just say that plugins count againt your connected subframe limit (I
can't really imagine a case where someone would want an unlimited number of
plugins, but who knows...)

Powered by Google App Engine
This is Rietveld 408576698