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

Issue 656113002: Refactor Script(Loader|Runner): don't access Resources all over the place... (Closed)

Created:
6 years, 2 months ago by marja
Modified:
6 years, 2 months ago
CC:
blink-reviews, blink-reviews-dom_chromium.org, dglazkov+blink, eae+blinkwatch, rwlbuis, oilpan-reviews
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Project:
blink
Visibility:
Public.

Description

Refactor Script(Loader|Runner): don't access Resources all over the place... ... but use proper layering instead. PendingScript holds a Resource, and many places in the code are using both the PendingScript and the underlying Resource. For example, ScriptRunner holds a collection of PendingScripts, and ScriptLoaders then listen to the underlying Resources. This is confusing and error prone. The Resource - ScriptLoader - PendingScript - Element love quadrangle is messy in general. Both ScriptLoader and PendingScript refer to the Resource. The way to get ScriptLoader from PendingScript is via Element which PendingScript also holds. But there's no way to get PendingScript from ScriptLoader. This CL makes ScriptRunner access the ScriptLoaders directly and moves the PendingScript to ScriptLoader. In addition, it makes ScriptRunner not access the Resource of the ScriptLoader directly. This CL also cancels the hack from https://bugs.webkit.org/show_bug.cgi?id=92211 (r139942) where it was speculated that a crash can be caused by ScriptLoader getting the notifyFinished notification twice because it doesn't unsubscribe yet when it gets the first one. The speculative fix was to made it nullify ScriptLoader::m_resource and check for the nullity later. This is pretty surprising, since the obvious solution would've been to just unsubscribe early enough (which is done by this CL). Note a behavioral change: It's OK to call Resource::addClient even if the Resource is finished, and in that case, the client will be notified immediately. But PendingScript used to ASSERT that the Resource is not finished. This CL removes that restriction (the underlying Resource already handles adding clients to finished resources + made ScriptStreamer handle it too). Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=183873

Patch Set 1 #

Patch Set 2 : . #

Patch Set 3 : . #

Patch Set 4 : . #

Total comments: 16

Patch Set 5 : code review (haraken) #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+50 lines, -64 lines) Patch
M Source/bindings/core/v8/ScriptStreamer.h View 1 1 chunk +1 line, -1 line 0 comments Download
M Source/core/dom/PendingScript.cpp View 1 2 1 chunk +3 lines, -4 lines 0 comments Download
M Source/core/dom/ScriptLoader.h View 1 2 5 chunks +6 lines, -2 lines 1 comment Download
M Source/core/dom/ScriptLoader.cpp View 1 2 3 5 chunks +20 lines, -27 lines 0 comments Download
M Source/core/dom/ScriptRunner.h View 1 2 3 4 3 chunks +5 lines, -8 lines 0 comments Download
M Source/core/dom/ScriptRunner.cpp View 1 2 5 chunks +15 lines, -22 lines 1 comment Download

Messages

Total messages: 28 (5 generated)
marja
jochen, ptal haraken, fyi, and you're ofc welcome to have a look too.
6 years, 2 months ago (2014-10-15 14:49:50 UTC) #2
jochen (gone - plz use gerrit)
lgtm
6 years, 2 months ago (2014-10-15 15:08:15 UTC) #3
haraken
This is nice refactoring. https://codereview.chromium.org/656113002/diff/60001/Source/bindings/core/v8/ScriptStreamer.h File Source/bindings/core/v8/ScriptStreamer.h (left): https://codereview.chromium.org/656113002/diff/60001/Source/bindings/core/v8/ScriptStreamer.h#oldcode69 Source/bindings/core/v8/ScriptStreamer.h:69: ASSERT(!isFinished()); Can we keep this ...
6 years, 2 months ago (2014-10-15 15:09:41 UTC) #5
marja
Thanks for having a look. haraken@, I didn't end up actually doing any of the ...
6 years, 2 months ago (2014-10-16 15:19:04 UTC) #6
marja
morrita@, re: our chat discussion. Here I'm moving the "stop watching" call (~ Resource::removeClient) from ...
6 years, 2 months ago (2014-10-16 15:19:50 UTC) #8
Hajime Morrita
On 2014/10/16 15:19:50, marja wrote: > morrita@, re: our chat discussion. > > Here I'm ...
6 years, 2 months ago (2014-10-16 17:04:05 UTC) #9
Hajime Morrita
On 2014/10/16 17:04:05, morrita wrote: > On 2014/10/16 15:19:50, marja wrote: > > morrita@, re: ...
6 years, 2 months ago (2014-10-16 17:05:04 UTC) #10
haraken
On 2014/10/16 15:19:04, marja wrote: > Thanks for having a look. > > haraken@, I ...
6 years, 2 months ago (2014-10-17 06:10:52 UTC) #11
marja
On 2014/10/16 17:04:05, morrita wrote: > On 2014/10/16 15:19:50, marja wrote: > > morrita@, re: ...
6 years, 2 months ago (2014-10-17 07:54:35 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/656113002/80001
6 years, 2 months ago (2014-10-17 07:55:21 UTC) #14
commit-bot: I haz the power
Committed patchset #5 (id:80001) as 183873
6 years, 2 months ago (2014-10-17 10:11:26 UTC) #15
sof
https://codereview.chromium.org/656113002/diff/80001/Source/core/dom/ScriptLoader.h File Source/core/dom/ScriptLoader.h (right): https://codereview.chromium.org/656113002/diff/80001/Source/core/dom/ScriptLoader.h#newcode107 Source/core/dom/ScriptLoader.h:107: PendingScript m_pendingScript; This is a problem; PendingScript has traceable ...
6 years, 2 months ago (2014-10-17 10:23:17 UTC) #17
sof
On 2014/10/17 10:23:17, sof wrote: > https://codereview.chromium.org/656113002/diff/80001/Source/core/dom/ScriptLoader.h > File Source/core/dom/ScriptLoader.h (right): > > https://codereview.chromium.org/656113002/diff/80001/Source/core/dom/ScriptLoader.h#newcode107 > ...
6 years, 2 months ago (2014-10-17 10:30:04 UTC) #18
marja
On 2014/10/17 10:30:04, sof wrote: > On 2014/10/17 10:23:17, sof wrote: > > > https://codereview.chromium.org/656113002/diff/80001/Source/core/dom/ScriptLoader.h ...
6 years, 2 months ago (2014-10-17 10:39:59 UTC) #19
marja
On 2014/10/17 10:39:59, marja wrote: > On 2014/10/17 10:30:04, sof wrote: > > On 2014/10/17 ...
6 years, 2 months ago (2014-10-17 10:41:11 UTC) #20
sof
On 2014/10/17 10:41:11, marja wrote: > On 2014/10/17 10:39:59, marja wrote: > > On 2014/10/17 ...
6 years, 2 months ago (2014-10-17 10:42:21 UTC) #21
sof
https://codereview.chromium.org/656113002/diff/80001/Source/core/dom/ScriptRunner.cpp File Source/core/dom/ScriptRunner.cpp (right): https://codereview.chromium.org/656113002/diff/80001/Source/core/dom/ScriptRunner.cpp#newcode146 Source/core/dom/ScriptRunner.cpp:146: visitor->trace(m_scriptsToExecuteInOrder); Vector<ScriptLoader*> isn't traceable. Hmm, I wonder if we ...
6 years, 2 months ago (2014-10-17 10:55:50 UTC) #22
sof
On 2014/10/17 10:55:50, sof wrote: > https://codereview.chromium.org/656113002/diff/80001/Source/core/dom/ScriptRunner.cpp > File Source/core/dom/ScriptRunner.cpp (right): > > https://codereview.chromium.org/656113002/diff/80001/Source/core/dom/ScriptRunner.cpp#newcode146 > ...
6 years, 2 months ago (2014-10-17 11:26:27 UTC) #23
marja
On 2014/10/17 11:26:27, sof wrote: > On 2014/10/17 10:55:50, sof wrote: > > > https://codereview.chromium.org/656113002/diff/80001/Source/core/dom/ScriptRunner.cpp ...
6 years, 2 months ago (2014-10-17 11:27:27 UTC) #24
aboxhall
A revert of this CL (patchset #5 id:80001) has been created in https://codereview.chromium.org/662863002/ by aboxhall@chromium.org. ...
6 years, 2 months ago (2014-10-17 20:10:31 UTC) #25
aboxhall
On 2014/10/17 20:10:31, aboxhall wrote: > A revert of this CL (patchset #5 id:80001) has ...
6 years, 2 months ago (2014-10-17 20:19:43 UTC) #26
sof
On 2014/10/17 20:19:43, aboxhall wrote: > On 2014/10/17 20:10:31, aboxhall wrote: > > A revert ...
6 years, 2 months ago (2014-10-17 20:24:10 UTC) #27
dstockwell
6 years, 2 months ago (2014-10-19 23:19:15 UTC) #28
Message was sent while issue was closed.
A revert of this CL (patchset #5 id:80001) has been created in
https://codereview.chromium.org/669503003/ by dstockwell@chromium.org.

The reason for reverting is: Introduced leaks in the following tests:

fast/dom/HTMLScriptElement/append-child-adopt-node-error-crash.html
fast/dom/HTMLScriptElement/script-async-attr.html
fast/dom/HTMLScriptElement/script-load-events.html
fast/dom/URL-attribute-reflection.html
fast/events/onerror-bubbling.html
http/tests/cache/loaded-from-cache-after-reload.html
http/tests/cache/subresource-expiration-2.html
http/tests/cache/subresource-multiple-instances.html
http/tests/htmlimports/import-script-block-crossorigin-dynamic.html
http/tests/loading/script-priorities.html.

Powered by Google App Engine
This is Rietveld 408576698