Reduce technical debt around null checks for OOPIF things |
||
Issue descriptionI was doing some cleanup and noticed that there are null checks all over the place. Some are because the frame is a provisional, others are because the frame is detached. Often it is not always why the null checks are needed. This makes it very hard to understand what conditions are true. There are multiple reasons for the current confusion: 1. Initialization order issues: when creating a web local frame, we create the WebLocalFrameImpl, then the LocalFrame, then the WebFrameWidget. This is problematic, because layout code might start running immediately. Since WebFrameWidget is not created until later, code must handle a lot of potential null cases. We should get rid of this by creating WebFrameWidget *before* creating the WebLocalFrame. 2. Provisional local frames are another big source of technical debt. Currently, I think there is no WebFrameWidget attached to them at all. Can we attach a WebFrameWidget even to provisional local frames? That would reduce the amount of special cases... 3. Code is not properly shutting down and keeps running even after the frame is detached. This really should not be happening. There are lots of examples in this in ChromeClientImpl: it seems the root graphics layer is often cleared "too late" when the widget is already gone. All this cleanup work should be properly sequenced to avoid running into these null checks. The various getters should be changed to return mutable references instead. For null checks that are still needed, they should be changed to explicitly check for the state they are interested in. Null checks on blink::Frame::Client() should check: - blink::Frame::IsAttached(): this is often needed due to potential reentrancy during detach. Null checks on: blink::WebLocalFrame::FrameWidget() should check: - blink::WebLocalFrame::IsLocalRoot() (not yet added) - blink::WebLocalFrame::IsAttached (not yet added) - blink::WebLocalFrame::IsProvisional (not yet added, and should eventually be removed) Null checks on blink::WebLocalFrameImpl::Client() should check: - blink::WebLocalFrame::IsAttached() (but see below) - Ideally nothing because code on WebLocalFrameImpl shouldn't be called after frame detach. Null checks on blink::WebFrameWidgetBase::Client() should check: - Ideally nothing because WebFrameWidgetBase shouldn't be used after the local root frame is detached.
,
Mar 11 2018
,
Mar 12 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/dc7390f7d4dc428563b1a37ea74ee138ee4560b9 commit dc7390f7d4dc428563b1a37ea74ee138ee4560b9 Author: Daniel Cheng <dcheng@chromium.org> Date: Mon Mar 12 10:58:42 2018 [OOPIF] Add WebLocalFrame helpers IsLocalRoot() and IsProvisional(). IsLocalRoot() is needed since WebLocalFrame::FrameWidget() is changing to always return a WebFrameWidget. IsProvisional() is useful to have a common check for the workarounds for provisional frames so they can be easily cleaned up later. Bug: 478281, 578349, 820782 Change-Id: Icf1411261a044b2fa393c614c9bec93b3f3bc4b7 Reviewed-on: https://chromium-review.googlesource.com/958582 Commit-Queue: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Kentaro Hara <haraken@chromium.org> Cr-Commit-Position: refs/heads/master@{#542455} [modify] https://crrev.com/dc7390f7d4dc428563b1a37ea74ee138ee4560b9/third_party/WebKit/Source/core/exported/WebFrame.cpp [modify] https://crrev.com/dc7390f7d4dc428563b1a37ea74ee138ee4560b9/third_party/WebKit/Source/core/frame/Frame.cpp [modify] https://crrev.com/dc7390f7d4dc428563b1a37ea74ee138ee4560b9/third_party/WebKit/Source/core/frame/Frame.h [modify] https://crrev.com/dc7390f7d4dc428563b1a37ea74ee138ee4560b9/third_party/WebKit/Source/core/frame/LocalFrame.cpp [modify] https://crrev.com/dc7390f7d4dc428563b1a37ea74ee138ee4560b9/third_party/WebKit/Source/core/frame/LocalFrame.h [modify] https://crrev.com/dc7390f7d4dc428563b1a37ea74ee138ee4560b9/third_party/WebKit/Source/core/frame/RemoteFrame.cpp [modify] https://crrev.com/dc7390f7d4dc428563b1a37ea74ee138ee4560b9/third_party/WebKit/Source/core/frame/WebLocalFrameImpl.cpp [modify] https://crrev.com/dc7390f7d4dc428563b1a37ea74ee138ee4560b9/third_party/WebKit/Source/core/frame/WebLocalFrameImpl.h [modify] https://crrev.com/dc7390f7d4dc428563b1a37ea74ee138ee4560b9/third_party/WebKit/Source/core/loader/FrameLoader.cpp [modify] https://crrev.com/dc7390f7d4dc428563b1a37ea74ee138ee4560b9/third_party/WebKit/Source/core/page/ChromeClientImpl.cpp [modify] https://crrev.com/dc7390f7d4dc428563b1a37ea74ee138ee4560b9/third_party/WebKit/public/web/WebLocalFrame.h |
||
►
Sign in to add a comment |
||
Comment 1 by dcheng@chromium.org
, Mar 11 2018