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

Issue 2743653002: Make context initialization order deterministic in WebFrame::swap(). (Closed)

Created:
3 years, 9 months ago by Alexander Semashko
Modified:
3 years, 9 months ago
Reviewers:
haraken, dcheng, Yuki
CC:
chromium-reviews, blink-reviews, mlamouri+watch-blink_chromium.org, kinuko+watch, blink-reviews-bindings_chromium.org, dcheng, haraken
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Make context initialization order deterministic in WebFrame::swap(). DCHECK(m_globalProxy != context()->Global()) sometimes fail. In builds with DCHECKs turned off this issue manifests with "Type Error: no access" errors in console and scripts not working. Started happening approx. in M56. Repro steps: 1. Install several extensions; 2. Visit a number of pages in a tab; 3. Do a lot of back and forward navigations quickly (not waiting till pages load). This is caused by setting the global object in WindowProxy after it was initialized. This happens when WindowProxyManagerBase::setGlobals processes a non-main world first. It sends out a didCreateScriptContext call. ExtensionFrameHelper::DidCreateScriptContext wants to know whether it is the main world script context, and compares with WebLocalFrameImpl::mainWorldScriptContext(). As a result, main world script context is initialized. At this point the call stack is like this: 1 blink::LocalWindowProxy::initialize 2 blink::ScriptController::windowProxy 3 blink::toV8Context 4 blink::ScriptState::forMainWorld 5 blink::WebLocalFrameImpl::mainWorldScriptContext 6 extensions::ExtensionFrameHelper::DidCreateScriptContext 7 content::RenderFrameImpl::didCreateScriptContext 8 blink::LocalWindowProxy::initialize 9 blink::WindowProxy::setGlobal 10 blink::WindowProxyManagerBase::setGlobals 11 blink::WebFrame::swap 12 content::RenderFrameImpl::SwapIn 13 content::RenderFrameImpl::didCommitProvisionalLoad 14 blink::FrameLoaderClientImpl::dispatchDidCommitLoad 15 blink::FrameLoader::receivedFirstData 16 blink::DocumentLoader::createWriterFor 17 blink::DocumentLoader::ensureWriter 18 blink::DocumentLoader::commitData After that WindowProxyManagerBase::setGlobals continues its work and sets the global object for the main world WindowProxy, and it becomes broken. BUG=700077 Review-Url: https://codereview.chromium.org/2743653002 Cr-Commit-Position: refs/heads/master@{#455951} Committed: https://chromium.googlesource.com/chromium/src/+/1993f6e8c0fe533f411ae5764231072e212221ad

Patch Set 1 #

Total comments: 3

Patch Set 2 : Add comment. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+18 lines, -15 lines) Patch
M third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h View 1 1 chunk +7 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.cpp View 1 chunk +10 lines, -10 lines 0 comments Download
M third_party/WebKit/Source/web/WebFrame.cpp View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 32 (17 generated)
Alexander Semashko
PTAL I think that something is missing here. Something like a [D]CHECK in WindowProxy::setGlobal that ...
3 years, 9 months ago (2017-03-09 13:52:52 UTC) #8
dcheng
Thanks for reproing it locally. I suspected this to be the cause of the bug ...
3 years, 9 months ago (2017-03-09 18:33:06 UTC) #9
dcheng
Oh never mind, it's because we made the ordering deterministic.
3 years, 9 months ago (2017-03-09 18:33:28 UTC) #10
dcheng
LGTM, but with some nits for the CL description. For the CL subject / first ...
3 years, 9 months ago (2017-03-09 19:09:56 UTC) #12
dcheng
3 years, 9 months ago (2017-03-09 19:10:16 UTC) #13
Alexander Semashko
On 2017/03/09 19:09:56, dcheng wrote: > LGTM, but with some nits for the CL description. ...
3 years, 9 months ago (2017-03-09 19:58:04 UTC) #16
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/2743653002/1
3 years, 9 months ago (2017-03-09 19:58:36 UTC) #18
commit-bot: I haz the power
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presubmit/builds/382220)
3 years, 9 months ago (2017-03-09 20:06:57 UTC) #20
haraken
LGTM https://codereview.chromium.org/2743653002/diff/1/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h File third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h (right): https://codereview.chromium.org/2743653002/diff/1/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h#newcode34 third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h:34: Vector<std::pair<DOMWrapperWorld*, v8::Local<v8::Object>>>; Would you add a comment and ...
3 years, 9 months ago (2017-03-09 22:04:47 UTC) #22
dcheng
https://codereview.chromium.org/2743653002/diff/1/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h File third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h (right): https://codereview.chromium.org/2743653002/diff/1/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h#newcode34 third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h:34: Vector<std::pair<DOMWrapperWorld*, v8::Local<v8::Object>>>; On 2017/03/09 22:04:46, haraken wrote: > > ...
3 years, 9 months ago (2017-03-09 22:10:21 UTC) #23
Alexander Semashko
https://codereview.chromium.org/2743653002/diff/1/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h File third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h (right): https://codereview.chromium.org/2743653002/diff/1/third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h#newcode34 third_party/WebKit/Source/bindings/core/v8/WindowProxyManager.h:34: Vector<std::pair<DOMWrapperWorld*, v8::Local<v8::Object>>>; On 2017/03/09 22:10:20, dcheng wrote: > On ...
3 years, 9 months ago (2017-03-09 22:26:10 UTC) #24
dcheng
Comment LGTM
3 years, 9 months ago (2017-03-09 22:30:14 UTC) #25
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/2743653002/20001
3 years, 9 months ago (2017-03-09 22:33:51 UTC) #28
commit-bot: I haz the power
Committed patchset #2 (id:20001) as https://chromium.googlesource.com/chromium/src/+/1993f6e8c0fe533f411ae5764231072e212221ad
3 years, 9 months ago (2017-03-10 01:35:06 UTC) #31
Yuki
3 years, 9 months ago (2017-03-10 06:35:57 UTC) #32
Message was sent while issue was closed.
LGTM!  This is a great catch!!

Powered by Google App Engine
This is Rietveld 408576698