Commit 4286d3b8 authored by danakj's avatar danakj Committed by Commit Bot

Clean up remaining TODOs for moving RenderWidget to RenderFrameImpl

This removes the remaining TODOs pointing to bug 419087, 583347, and
912193 when they are about RenderWidget and not RenderWidgetHost. TODOs
about the RenderWidgetHost are clarified to explain that RenderWidget is
destroyed now.

R=avi@chromium.org

Bug: 419087, 583347, 912193
Change-Id: Ia491d2644997bac9d93bd319fb2ca0133997d86e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006209Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737954}
parent 9c7aced8
...@@ -2511,9 +2511,13 @@ void RenderFrameHostManager::CommitPending( ...@@ -2511,9 +2511,13 @@ void RenderFrameHostManager::CommitPending(
} }
} }
// For top-level frames, the RenderWidget{Host} will not be destroyed when the // For top-level frames, the RenderWidgetHost will not be destroyed when the
// local frame is detached. https://crbug.com/419087 // local frame is detached. https://crbug.com/419087
// //
// The RenderWidget in the renderer process is destroyed, but the
// RenderWidgetHost and RenderWidgetHostView are still kept alive for a remote
// main frame.
//
// To work around that, we hide it here. Truly this is to hit all the hide // To work around that, we hide it here. Truly this is to hit all the hide
// paths in the browser side, but has a side effect of also hiding the // paths in the browser side, but has a side effect of also hiding the
// renderer side RenderWidget, even though it will get frozen anyway in the // renderer side RenderWidget, even though it will get frozen anyway in the
...@@ -2524,15 +2528,15 @@ void RenderFrameHostManager::CommitPending( ...@@ -2524,15 +2528,15 @@ void RenderFrameHostManager::CommitPending(
// RenderFrameHost crashed. // RenderFrameHost crashed.
// //
// TODO(crbug.com/419087): This is only done for the main frame, as for sub // TODO(crbug.com/419087): This is only done for the main frame, as for sub
// frames the RenderWidget and its view will be destroyed when the frame is // frames the RenderWidgetHost and its view will be destroyed when the frame
// detached, but for the main frame it is not. This call to Hide() can go away // is detached, but for the main frame it is not. This call to Hide() can go
// when the main frame's RenderWidget is destroyed on frame detach. Note that // away when the main frame's RenderWidgetHost is destroyed on frame detach.
// calling this on a subframe that is not a local root would be incorrect as // Note that calling this on a subframe that is not a local root would be
// it would hide an ancestor local root's RenderWidget when that frame is not // incorrect as it would hide an ancestor local root's RenderWidget when that
// necessarily navigating. Removing this Hide() has previously been attempted // frame is not necessarily navigating. Removing this Hide() has previously
// without success in r426913 (https://crbug.com/658688) and r438516 (broke // been attempted without success in r426913 (https://crbug.com/658688) and
// assumptions about RenderWidgetHosts not changing RenderWidgetHostViews over // r438516 (broke assumptions about RenderWidgetHosts not changing
// time). // RenderWidgetHostViews over time).
// //
// |old_rvh| and |new_rvh| can be the same when navigating same-site from a // |old_rvh| and |new_rvh| can be the same when navigating same-site from a
// crashed RenderFrameHost. When RenderDocument will be implemented, this will // crashed RenderFrameHost. When RenderDocument will be implemented, this will
......
...@@ -860,9 +860,6 @@ void RenderViewHostImpl::OnRouteCloseEvent() { ...@@ -860,9 +860,6 @@ void RenderViewHostImpl::OnRouteCloseEvent() {
// This is only used when the RenderViewHost is not active, to signal to // This is only used when the RenderViewHost is not active, to signal to
// the active RenderViewHost that JS has requested the page to close. // the active RenderViewHost that JS has requested the page to close.
// //
// TODO(https://crbug.com/419087): Move to RenderFrameHost or
// RenderFrameProxyHost.
//
// The delegate will route the close request to the active RenderViewHost. // The delegate will route the close request to the active RenderViewHost.
delegate_->RouteCloseEvent(this); delegate_->RouteCloseEvent(this);
} }
......
...@@ -185,9 +185,6 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_ShowFullscreenWidget, ...@@ -185,9 +185,6 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_ShowFullscreenWidget,
// Sent from an inactive renderer for the browser to route to the active // Sent from an inactive renderer for the browser to route to the active
// renderer, instructing it to close. // renderer, instructing it to close.
//
// TODO(http://crbug.com/419087): Move this thing to Frame as it's a signal
// from a swapped out frame to the mainframe of the frame tree.
IPC_MESSAGE_ROUTED0(ViewHostMsg_RouteCloseEvent) IPC_MESSAGE_ROUTED0(ViewHostMsg_RouteCloseEvent)
// Indicates that the current page has been closed, after a ClosePage // Indicates that the current page has been closed, after a ClosePage
......
...@@ -228,26 +228,10 @@ void LayerTreeView::RequestNewLayerTreeFrameSink() { ...@@ -228,26 +228,10 @@ void LayerTreeView::RequestNewLayerTreeFrameSink() {
if (!delegate_) if (!delegate_)
return; return;
// When the compositor is not visible it would not request a // When the compositor is not visible it would not request a
// LayerTreeFrameSink so this is a race where it requested one then became // LayerTreeFrameSink so this is a race where it requested one on the
// not-visible. In that case, we can wait for it to become visible again // compositor thread while becoming non-visible on the main thread. In that
// before replying. // case, we can wait for it to become visible again before replying.
// if (!layer_tree_host_->IsVisible()) {
// This deals with an insidious race when the RenderWidget is swapped-out
// after this task was posted from the compositor. When swapped-out the
// compositor is stopped by making it not visible, and the RenderWidget (our
// delegate) is a zombie which can not be used (https://crbug.com/894899).
// Eventually the RenderWidget/LayerTreeView will not exist at all in this
// case (https://crbug.com/419087). So this handles the case for now since the
// compositor is not visible, and we can avoid using the RenderWidget until
// it marks the compositor visible again, indicating that it is valid to use
// the RenderWidget again.
//
// If there is no compositor thread, then this is a test-only path where
// composite is controlled directly by blink, and visibility is not
// considered. We don't expect blink to ever try composite on a swapped-out
// RenderWidget, which would be a bug, but the race condition can't happen
// in the single-thread case since this isn't a posted task.
if (!layer_tree_host_->IsVisible() && !!compositor_thread_) {
layer_tree_frame_sink_request_failed_while_invisible_ = true; layer_tree_frame_sink_request_failed_while_invisible_ = true;
return; return;
} }
...@@ -261,6 +245,10 @@ void LayerTreeView::DidInitializeLayerTreeFrameSink() {} ...@@ -261,6 +245,10 @@ void LayerTreeView::DidInitializeLayerTreeFrameSink() {}
void LayerTreeView::DidFailToInitializeLayerTreeFrameSink() { void LayerTreeView::DidFailToInitializeLayerTreeFrameSink() {
if (!delegate_) if (!delegate_)
return; return;
// When the RenderWidget is made hidden while an async request for a
// LayerTreeFrameSink is being processed, then if it fails we would arrive
// here. Since the compositor does not request a LayerTreeFrameSink while not
// visible, we can delay trying again until becoming visible again.
if (!layer_tree_host_->IsVisible()) { if (!layer_tree_host_->IsVisible()) {
layer_tree_frame_sink_request_failed_while_invisible_ = true; layer_tree_frame_sink_request_failed_while_invisible_ = true;
return; return;
......
...@@ -87,20 +87,9 @@ class CreateViewParams; ...@@ -87,20 +87,9 @@ class CreateViewParams;
// the owner of it. Thus a tab may have multiple RenderViewImpls, one for the // the owner of it. Thus a tab may have multiple RenderViewImpls, one for the
// main frame, and one for each other frame tree generated. // main frame, and one for each other frame tree generated.
// //
// The RenderViewImpl manages a WebView object from blink, which hosts the // When the main frame is part of this RenderViewImpl's frame tree, then this
// web page and a blink frame tree. If the main frame (root of the tree) is // object acts as the RenderWidgetDelegate for that frame's RenderWidget. Other
// a local frame for this view, then it also manages a RenderWidget for the // RenderWidgets would have a null RenderWidgetDelegate.
// main frame.
//
// The main distinction between RenderView and RenderWidget is that the
// RenderView holds synchronized state across all processes participating in the
// frame tree, whereas the RenderWidget holds per-root-frame state.
//
// TODO(419087): Currently even though the RenderViewImpl "manages" the
// RenderWidget, the RenderWidget owns the RenderViewImpl. This is due to
// RenderViewImpl historically being a subclass of RenderWidget. Breaking
// the ownership relation will require moving the RenderWidget to the main
// frame and updating all the blink objects to understand the lifetime changes.
class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient, class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
public IPC::Listener, public IPC::Listener,
public RenderWidgetDelegate, public RenderWidgetDelegate,
...@@ -302,11 +291,6 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient, ...@@ -302,11 +291,6 @@ class CONTENT_EXPORT RenderViewImpl : public blink::WebViewClient,
void ApplyPageVisibilityState(PageVisibilityState visibility_state, void ApplyPageVisibilityState(PageVisibilityState visibility_state,
bool initial_setting); bool initial_setting);
// Closes the main frame RenderWidget.
// TODO(crbug.com/419087): Move ownership of the RenderWidget to
// RenderFrameImpl.
void CloseMainFrameRenderWidget();
private: private:
// For unit tests. // For unit tests.
friend class DevToolsAgentTest; friend class DevToolsAgentTest;
......
...@@ -17,9 +17,8 @@ namespace content { ...@@ -17,9 +17,8 @@ namespace content {
// //
// RenderWidgetDelegate // RenderWidgetDelegate
// //
// An interface implemented by an object owning a RenderWidget. This is // An interface to provide View-level (and/or Page-level) functionality to
// intended to be temporary until the RenderViewImpl and RenderWidget classes // the main frame's RenderWidget.
// are disentangled; see https://crbug.com/583347 and https://crbug.com/478281.
class CONTENT_EXPORT RenderWidgetDelegate { class CONTENT_EXPORT RenderWidgetDelegate {
public: public:
virtual ~RenderWidgetDelegate() = default; virtual ~RenderWidgetDelegate() = default;
......
...@@ -55,20 +55,13 @@ bool TextInputClientObserver::OnMessageReceived(const IPC::Message& message) { ...@@ -55,20 +55,13 @@ bool TextInputClientObserver::OnMessageReceived(const IPC::Message& message) {
} }
bool TextInputClientObserver::Send(IPC::Message* message) { bool TextInputClientObserver::Send(IPC::Message* message) {
// This class is attached to the main frame RenderWidget, but sends and // This class is attached to the main frame RenderWidget, but its messages
// receives messages while the main frame is remote (and the RenderWidget is // are not received on RenderWidgetHostImpl, so there's no need to send
// destroyed). The messages are not received on RenderWidgetHostImpl, so // through RenderWidget or use its routing id.
// there's no need to send through RenderWidget or use its routing id. We
// avoid this problem then by sending directly through RenderThread instead of
// through RenderWidget::Send().
// TODO(crbug.com/669219): This class should not be used while the main frame
// is remote.
return RenderThread::Get()->Send(message); return RenderThread::Get()->Send(message);
} }
blink::WebFrameWidget* TextInputClientObserver::GetWebFrameWidget() const { blink::WebFrameWidget* TextInputClientObserver::GetWebFrameWidget() const {
if (!render_widget_)
return nullptr;
return static_cast<blink::WebFrameWidget*>(render_widget_->GetWebWidget()); return static_cast<blink::WebFrameWidget*>(render_widget_->GetWebWidget());
} }
......
...@@ -42,14 +42,7 @@ class TextInputClientObserver : public IPC::Listener, public IPC::Sender { ...@@ -42,14 +42,7 @@ class TextInputClientObserver : public IPC::Listener, public IPC::Sender {
bool Send(IPC::Message* message) override; bool Send(IPC::Message* message) override;
private: private:
// The WebFrameWidget corresponding to this TextInputClientObserver. While the // The WebFrameWidget corresponding to this TextInputClientObserver.
// main frame is remote, the value returned from this method for a main frame
// RenderWidget is null.
// TODO(crbug.com/669219): The browser shouldn't be sending IPCs that land
// in this class when the main frame is remote.
// TODO(crbug.com/419087): The lifetime of the WebFrameWidget should
// eventually be tied to the lifetime of the RenderWidget so this would never
// return null.
blink::WebFrameWidget* GetWebFrameWidget() const; blink::WebFrameWidget* GetWebFrameWidget() const;
blink::WebLocalFrame* GetFocusedFrame() const; blink::WebLocalFrame* GetFocusedFrame() const;
......
...@@ -1219,11 +1219,8 @@ void WebViewImpl::Close() { ...@@ -1219,11 +1219,8 @@ void WebViewImpl::Close() {
AsView().page->WillBeDestroyed(); AsView().page->WillBeDestroyed();
// The main frame being detached in WillBeDestroyed() will make use of this // The main frame being detached in WillBeDestroyed() will make use of this
// which happens in Page::WillBeDestroyed(). But since the RenderWidget lives
// |animation_host_| through its WebFrameWidget, before causing the // |animation_host_| through its WebFrameWidget, before causing the
// forever (https://crbug.com/419087), the WebWidget is not closed elsewhere.
// WebWidgetClient and the AnimationHost to be destroyed. So this is nulled // WebWidgetClient and the AnimationHost to be destroyed. So this is nulled
// So we close it here but try to simulate the same ordering by closing it
// out after detaching the main frame. // out after detaching the main frame.
animation_host_ = nullptr; animation_host_ = nullptr;
...@@ -2043,10 +2040,6 @@ void WebViewImpl::DidAttachLocalMainFrame() { ...@@ -2043,10 +2040,6 @@ void WebViewImpl::DidAttachLocalMainFrame() {
void WebViewImpl::DidDetachLocalMainFrame() { void WebViewImpl::DidDetachLocalMainFrame() {
// The WebWidgetClient that generated the |scoped_defer_main_frame_update_| // The WebWidgetClient that generated the |scoped_defer_main_frame_update_|
// for a local main frame is going away. // for a local main frame is going away.
// TODO(crbug.com/419087): For now, the WebWidgetClient (aka RenderWidget)
// is not destroyed, so this comment is not true, but it will be in the
// future. All references between |this| and the WebWidgetClient should be
// dropped regardless.
scoped_defer_main_frame_update_ = nullptr; scoped_defer_main_frame_update_ = nullptr;
} }
......
...@@ -648,6 +648,7 @@ content::LayerTreeView* LayerTreeViewFactory::Initialize( ...@@ -648,6 +648,7 @@ content::LayerTreeView* LayerTreeViewFactory::Initialize(
&fake_thread_scheduler_); &fake_thread_scheduler_);
layer_tree_view_->Initialize(settings, layer_tree_view_->Initialize(settings,
std::make_unique<cc::TestUkmRecorderFactory>()); std::make_unique<cc::TestUkmRecorderFactory>());
layer_tree_view_->SetVisible(true);
return layer_tree_view_.get(); return layer_tree_view_.get();
} }
......
...@@ -788,9 +788,7 @@ void ChromeClientImpl::AttachCompositorAnimationTimeline( ...@@ -788,9 +788,7 @@ void ChromeClientImpl::AttachCompositorAnimationTimeline(
DCHECK(Platform::Current()->IsThreadedAnimationEnabled()); DCHECK(Platform::Current()->IsThreadedAnimationEnabled());
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(local_frame); WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(local_frame);
WebFrameWidgetBase* widget = web_frame->LocalRootFrameWidget(); WebFrameWidgetBase* widget = web_frame->LocalRootFrameWidget();
// TODO(crbug.com/912193): This is called while a frame is attached so widget DCHECK(widget);
// is never null, right?
CHECK(widget);
widget->AnimationHost()->AddAnimationTimeline( widget->AnimationHost()->AddAnimationTimeline(
compositor_timeline->GetAnimationTimeline()); compositor_timeline->GetAnimationTimeline());
} }
...@@ -801,9 +799,7 @@ void ChromeClientImpl::DetachCompositorAnimationTimeline( ...@@ -801,9 +799,7 @@ void ChromeClientImpl::DetachCompositorAnimationTimeline(
DCHECK(Platform::Current()->IsThreadedAnimationEnabled()); DCHECK(Platform::Current()->IsThreadedAnimationEnabled());
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(local_frame); WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(local_frame);
WebFrameWidgetBase* widget = web_frame->LocalRootFrameWidget(); WebFrameWidgetBase* widget = web_frame->LocalRootFrameWidget();
// TODO(crbug.com/912193): This should not be called after Document::Shutdown, DCHECK(widget);
// so widget is never null, right?
CHECK(widget);
widget->AnimationHost()->RemoveAnimationTimeline( widget->AnimationHost()->RemoveAnimationTimeline(
compositor_timeline->GetAnimationTimeline()); compositor_timeline->GetAnimationTimeline());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment