Commit 86fd8ed8 authored by Fergal Daly's avatar Fergal Daly Committed by Commit Bot

Add debugging to WebViewImpl so that we know why the main frame is null.

This is some ugly but temporary debugging to log extra information
when we find the the view has no main frame but the local root does.

Bug: 1139104
Change-Id: I791fc7572a4a5a5abf3c7c689c4029e1696bbd48
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2532535Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Fergal Daly <fergal@chromium.org>
Auto-Submit: Fergal Daly <fergal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828003}
parent 2ada21fc
......@@ -1947,6 +1947,18 @@ WebLocalFrameImpl* WebViewImpl::MainFrameImpl() const {
return WebLocalFrameImpl::FromFrame(DynamicTo<LocalFrame>(page->MainFrame()));
}
std::string WebViewImpl::GetNullFrameReasonForBug1139104() const {
Page* page = page_.Get();
if (!page)
return "WebViewImpl::page";
if (!page->MainFrame())
return "WebViewImpl::page->MainFrame";
LocalFrame* local_frame = DynamicTo<LocalFrame>(page->MainFrame());
if (!local_frame)
return "WebViewImpl::local_frame";
return WebLocalFrameImpl::GetNullFrameReasonForBug1139104(local_frame);
}
void WebViewImpl::DidAttachLocalMainFrame() {
DCHECK(MainFrameImpl());
......
......@@ -290,6 +290,9 @@ class CORE_EXPORT WebViewImpl final : public WebView,
// outside this class.
WebLocalFrameImpl* MainFrameImpl() const;
// TODO(https://crbug.com/1139104): Remove this.
std::string GetNullFrameReasonForBug1139104() const;
// Changes the zoom and scroll for zooming into an editable element
// with bounds |element_bounds_in_document| and caret bounds
// |caret_bounds_in_document|.
......
......@@ -7,6 +7,8 @@
#include <memory>
#include <utility>
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h"
#include "base/metrics/histogram_macros.h"
#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
......@@ -1411,14 +1413,19 @@ void WebFrameWidgetBase::BeginCommitCompositorFrame() {
void WebFrameWidgetBase::EndCommitCompositorFrame(
base::TimeTicks commit_start_time) {
DCHECK(commit_compositor_frame_start_time_.has_value());
CHECK(LocalRootImpl());
CHECK(LocalRootImpl()->GetFrame());
CHECK(LocalRootImpl()->GetFrame()->View());
if (ForMainFrame()) {
View()->Client()->DidCommitCompositorFrameForLocalMainFrame(
commit_start_time);
View()->UpdatePreferredSize();
if (!View()->MainFrameImpl()) {
// Trying to track down why the view's idea of the main frame varies
// from LocalRootImpl's.
// TODO(https://crbug.com/1139104): Remove this.
std::string reason = View()->GetNullFrameReasonForBug1139104();
DCHECK(false) << reason;
SCOPED_CRASH_KEY_STRING32(Crbug1139104, NullFrameReason, reason);
base::debug::DumpWithoutCrashing();
}
}
LocalRootImpl()
......
......@@ -2151,6 +2151,19 @@ WebLocalFrameImpl* WebLocalFrameImpl::FromFrame(LocalFrame* frame) {
return FromFrame(*frame);
}
std::string WebLocalFrameImpl::GetNullFrameReasonForBug1139104(
LocalFrame* frame) {
LocalFrameClient* client = frame->Client();
if (!client)
return "WebLocalFrameImpl::client";
if (!client->IsLocalFrameClientImpl())
return "WebLocalFrameImpl::client-not-local";
WebLocalFrame* web_frame = client->GetWebFrame();
if (!web_frame)
return "WebLocalFrameImpl::web_frame";
return "not-null";
}
WebLocalFrameImpl* WebLocalFrameImpl::FromFrame(LocalFrame& frame) {
LocalFrameClient* client = frame.Client();
if (!client || !client->IsLocalFrameClientImpl())
......
......@@ -408,6 +408,8 @@ class CORE_EXPORT WebLocalFrameImpl final
// So note that FromFrame may return nullptr even for non-null frames.
static WebLocalFrameImpl* FromFrame(LocalFrame*);
static WebLocalFrameImpl* FromFrame(LocalFrame&);
// TODO(https://crbug.com/1139104): Remove this.
static std::string GetNullFrameReasonForBug1139104(LocalFrame* frame);
WebViewImpl* ViewImpl() const;
......
......@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/frame/web_view_frame_widget.h"
#include "base/debug/crash_logging.h"
#include "build/build_config.h"
#include "third_party/blink/public/common/input/web_keyboard_event.h"
#include "third_party/blink/public/platform/platform.h"
......
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