From fe5b0dd668e1e90d96ce18926e261788e0e53129 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Sat, 27 Apr 2024 14:25:51 -0400 Subject: [PATCH] chrome: osr: Fix performance manager init (see #3681) --- .../alloy/browser_platform_delegate_alloy.cc | 11 +++++++++++ .../chrome/chrome_content_browser_client_cef.cc | 11 ++++++++--- libcef/browser/osr/web_contents_view_osr.cc | 2 -- libcef/browser/osr/web_contents_view_osr.h | 2 -- patch/patch.cfg | 6 ------ patch/patches/chrome_browser_osr.patch | 16 ---------------- 6 files changed, 19 insertions(+), 29 deletions(-) delete mode 100644 patch/patches/chrome_browser_osr.patch diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.cc b/libcef/browser/alloy/browser_platform_delegate_alloy.cc index 8a5d19d11..28d48eefc 100644 --- a/libcef/browser/alloy/browser_platform_delegate_alloy.cc +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.cc @@ -25,6 +25,7 @@ #include "components/find_in_page/find_tab_helper.h" #include "components/find_in_page/find_types.h" #include "components/javascript_dialogs/tab_modal_dialog_manager.h" +#include "components/performance_manager/embedder/performance_manager_registry.h" #include "components/permissions/permission_request_manager.h" #include "components/zoom/zoom_controller.h" #include "content/browser/renderer_host/render_widget_host_impl.h" @@ -427,6 +428,16 @@ void CefBrowserPlatformDelegateAlloy::AttachHelpers( web_contents, CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop( web_contents)); } else { + if (IsWindowless()) { + // Logic from ChromeContentBrowserClientCef::GetWebContentsViewDelegate + // which is not called for windowless browsers. Needs to be done before + // calling AttachTabHelpers. + if (auto* registry = + performance_manager::PerformanceManagerRegistry::GetInstance()) { + registry->MaybeCreatePageNodeForWebContents(web_contents); + } + } + // Adopt the WebContents now, so all observers are in place, as the network // requests for its initial navigation will start immediately TabHelpers::AttachTabHelpers(web_contents); diff --git a/libcef/browser/chrome/chrome_content_browser_client_cef.cc b/libcef/browser/chrome/chrome_content_browser_client_cef.cc index 80cdaf87b..4d35ee158 100644 --- a/libcef/browser/chrome/chrome_content_browser_client_cef.cc +++ b/libcef/browser/chrome/chrome_content_browser_client_cef.cc @@ -33,6 +33,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "components/performance_manager/embedder/performance_manager_registry.h" #include "content/public/browser/navigation_throttle.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" @@ -479,9 +480,13 @@ void ChromeContentBrowserClientCef::RegisterBrowserInterfaceBindersForFrame( std::unique_ptr ChromeContentBrowserClientCef::GetWebContentsViewDelegate( content::WebContents* web_contents) { - // This does more work than just creating the delegate, so we call it even - // though the result gets discarded. - ChromeContentBrowserClient::GetWebContentsViewDelegate(web_contents); + // From ChromeContentBrowserClient::GetWebContentsViewDelegate. Windowless + // browsers don't call this method and use + // CefBrowserPlatformDelegateAlloy::AttachHelpers instead. + if (auto* registry = + performance_manager::PerformanceManagerRegistry::GetInstance()) { + registry->MaybeCreatePageNodeForWebContents(web_contents); + } // Used to customize context menu behavior for Alloy style. Called during // WebContents::Create() so we don't yet have an associated BrowserHost. diff --git a/libcef/browser/osr/web_contents_view_osr.cc b/libcef/browser/osr/web_contents_view_osr.cc index 8a2db50f4..48612a50d 100644 --- a/libcef/browser/osr/web_contents_view_osr.cc +++ b/libcef/browser/osr/web_contents_view_osr.cc @@ -10,8 +10,6 @@ #include "libcef/browser/osr/touch_selection_controller_client_osr.h" #include "libcef/common/drag_data_impl.h" -#include "content/browser/browser_plugin/browser_plugin_embedder.h" -#include "content/browser/browser_plugin/browser_plugin_guest.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/render_widget_host.h" diff --git a/libcef/browser/osr/web_contents_view_osr.h b/libcef/browser/osr/web_contents_view_osr.h index 114c70b8f..7d97d1e45 100644 --- a/libcef/browser/osr/web_contents_view_osr.h +++ b/libcef/browser/osr/web_contents_view_osr.h @@ -11,9 +11,7 @@ #include "third_party/skia/include/core/SkColor.h" namespace content { -class BrowserPluginGuest; class WebContents; -class WebContentsViewDelegate; } // namespace content class AlloyBrowserHostImpl; diff --git a/patch/patch.cfg b/patch/patch.cfg index eaa234c0c..3cdd03226 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -303,12 +303,6 @@ patches = [ # https://github.com/chromiumembedded/cef/issues/2830 'name': 'chrome_browser_net_proxy', }, - { - # chrome: Fix assertion in FrameNodeImpl::SetIntersectsViewport when loading - # PDF viewer with Chrome runtime + Alloy style + windowless rendering. - # https://github.com/chromiumembedded/cef/issues/3681 - 'name': 'chrome_browser_osr', - }, { # Support override of CreatePermissionPrompt. # https://github.com/chromiumembedded/cef/issues/3352 diff --git a/patch/patches/chrome_browser_osr.patch b/patch/patches/chrome_browser_osr.patch deleted file mode 100644 index 491ac1059..000000000 --- a/patch/patches/chrome_browser_osr.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git components/performance_manager/graph/frame_node_impl.cc components/performance_manager/graph/frame_node_impl.cc -index c277c918b08ce..8ca8fd2670edd 100644 ---- components/performance_manager/graph/frame_node_impl.cc -+++ components/performance_manager/graph/frame_node_impl.cc -@@ -355,8 +355,9 @@ void FrameNodeImpl::SetIntersectsViewport(bool intersects_viewport) { - DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - // The intersection with the viewport of the outermost main frame or embedder - // is not tracked. -- DCHECK(parent_or_outer_document_or_embedder()); -- intersects_viewport_.SetAndMaybeNotify(this, intersects_viewport); -+ if (parent_or_outer_document_or_embedder()) { -+ intersects_viewport_.SetAndMaybeNotify(this, intersects_viewport); -+ } - } - - void FrameNodeImpl::SetInitialVisibility(Visibility visibility) {