I have an interception mechanism for new popups; in libcef/browser/chrome/views\chrome_child_window.cc there is something like
- Code: Select all
void OnWindowCreated(CefRefPtr<CefWindow> window) override {
DCHECK(!window_);
window_ = window;
// Bind the container private implementation. This needs to be done
// before window_->AddChildView, which triggers OnAfterCreated, and we need
// the pointer to be decoded and bound before that.
BindContainer();
// Add the browser view. It will now have an associated Widget.
window_->AddChildView(browser_view_);
ShowWindow();
}
(notice the BindContainer call, but this does nothing more than setting the widget HWND some binding properties).
In libcef/browser/native/browser_platform_delegate_native_aura.cc
- Code: Select all
void CefBrowserPlatformDelegateNativeAura::InstallRootWindowBoundsCallback() {
auto* host_view = GetHostView();
CHECK(host_view);
host_view->SetRootWindowBoundsCallback(base::BindRepeating(
[](base::WeakPtr<CefBrowserPlatformDelegateNativeAura> self) {
return self->RootWindowBoundsCallback();
},
weak_ptr_factory_.GetWeakPtr()));
}
I am hitting CHECK(host_view).
This is called from
- Code: Select all
void CefBrowserPlatformDelegateNativeAura::RenderViewReady() {
CefBrowserPlatformDelegateNative::RenderViewReady();
// The RWHV should now exist for Alloy style browsers.
InstallRootWindowBoundsCallback();
}
but looks like it is crashing (for me) with or without --use-alloy-style.
Now I don't exactly know the entire lifetime of the host_view (if skipping this CHECK, host_view is not nullptr after the initial CHECK).
What I wonder is other calls, such as SendKeyEvent, SendMouseClickEvent, SendMouseMoveEvent are checking if GetHostView() returns nullptr, and nullptr is a valid return value since GetHostView is
- Code: Select all
content::RenderWidgetHostViewAura*
CefBrowserPlatformDelegateNativeAura::GetHostView() const {
if (!web_contents_) {
return nullptr;
}
return static_cast<content::RenderWidgetHostViewAura*>(
web_contents_->GetRenderWidgetHostView());
}
otherwise I would imagine instead of if (web_contents_) would have been a CHECK(web_contents_).
As for myself, I am changing locally as
- Code: Select all
void CefBrowserPlatformDelegateNativeAura::InstallRootWindowBoundsCallback() {
auto* host_view = GetHostView();
- CHECK(host_view);
+ if (!host_view) {
+ return;
+ }
host_view->SetRootWindowBoundsCallback(base::BindRepeating(
[](base::WeakPtr<CefBrowserPlatformDelegateNativeAura> self) {
return self->RootWindowBoundsCallback();
},
weak_ptr_factory_.GetWeakPtr()));
}
But I would like to understand if what I'm saying makes sense.