From 52a97946591711c4ac49dd7100e323654aec9b71 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 9 Aug 2023 16:40:55 -0400 Subject: [PATCH] win: Add delayloads to libcef.dll and exe targets Delay-load as many DLLs as possible for sandbox and startup perf improvements. --- BUILD.gn | 16 ++++++++++++ cmake/cef_variables.cmake.in | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/BUILD.gn b/BUILD.gn index e018c4c2d..766cb4ac8 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1674,6 +1674,10 @@ if (is_mac) { # ResourceBundle. See crbug.com/147663. "//ui/resources:ui_unscaled_resources_grd", ] + + # Delay-load as many DLLs as possible for sandbox and startup perf + # improvements. + configs += [ "//build/config/win:delayloads" ] } if (is_linux && !is_debug && !use_partition_alloc_as_malloc) { @@ -2176,6 +2180,10 @@ if (is_mac) { configs -= [ "//build/config/win:console" ] configs += [ "//build/config/win:windowed" ] + # Delay-load as many DLLs as possible for sandbox and startup perf + # improvements. + configs += [ "//build/config/win:delayloads" ] + defines += [ "CEF_USE_ATL", ] @@ -2264,6 +2272,10 @@ if (is_mac) { configs -= [ "//build/config/win:console" ] configs += [ "//build/config/win:windowed" ] + # Delay-load as many DLLs as possible for sandbox and startup perf + # improvements. + configs += [ "//build/config/win:delayloads" ] + deps += [ ":cef_sandbox", "//build/win:default_exe_manifest", @@ -2331,6 +2343,10 @@ if (is_mac) { sources += gypi_paths2.shared_sources_win + gypi_paths2.ceftests_sources_win + # Delay-load as many DLLs as possible for sandbox and startup perf + # improvements. + configs += [ "//build/config/win:delayloads" ] + deps += [ ":cef_sandbox", "//build/win:default_exe_manifest", diff --git a/cmake/cef_variables.cmake.in b/cmake/cef_variables.cmake.in index f3f64ea3a..e8c0ada1e 100644 --- a/cmake/cef_variables.cmake.in +++ b/cmake/cef_variables.cmake.in @@ -436,6 +436,56 @@ if(OS_WINDOWS) list(APPEND CEF_EXE_LINKER_FLAGS /MANIFEST:NO # No default manifest (see ADD_WINDOWS_MANIFEST macro usage) /LARGEADDRESSAWARE # Allow 32-bit processes to access 3GB of RAM + + # Delayload most libraries as the dlls are simply not required at startup (or + # at all, depending on the process type). Some dlls open handles when they are + # loaded, and we may not want them to be loaded in renderers or other sandboxed + # processes. Conversely, some dlls must be loaded before sandbox lockdown. In + # unsandboxed processes they will load when first needed. The linker will + # automatically ignore anything which is not linked to the binary at all (it is + # harmless to have an unmatched /delayload). This list should be kept in sync + # with Chromium's "delayloads" target from the //build/config/win/BUILD.gn file. + /DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll + /DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll + /DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll + /DELAYLOAD:advapi32.dll + /DELAYLOAD:comctl32.dll + /DELAYLOAD:comdlg32.dll + /DELAYLOAD:credui.dll + /DELAYLOAD:cryptui.dll + /DELAYLOAD:d3d11.dll + /DELAYLOAD:d3d9.dll + /DELAYLOAD:dwmapi.dll + /DELAYLOAD:dxgi.dll + /DELAYLOAD:dxva2.dll + /DELAYLOAD:esent.dll + /DELAYLOAD:gdi32.dll + /DELAYLOAD:hid.dll + /DELAYLOAD:imagehlp.dll + /DELAYLOAD:imm32.dll + /DELAYLOAD:msi.dll + /DELAYLOAD:netapi32.dll + /DELAYLOAD:ncrypt.dll + /DELAYLOAD:ole32.dll + /DELAYLOAD:oleacc.dll + /DELAYLOAD:propsys.dll + /DELAYLOAD:psapi.dll + /DELAYLOAD:rpcrt4.dll + /DELAYLOAD:rstrtmgr.dll + /DELAYLOAD:setupapi.dll + /DELAYLOAD:shell32.dll + /DELAYLOAD:shlwapi.dll + /DELAYLOAD:uiautomationcore.dll + /DELAYLOAD:urlmon.dll + /DELAYLOAD:user32.dll + /DELAYLOAD:usp10.dll + /DELAYLOAD:uxtheme.dll + /DELAYLOAD:wer.dll + /DELAYLOAD:wevtapi.dll + /DELAYLOAD:wininet.dll + /DELAYLOAD:winusb.dll + /DELAYLOAD:wsock32.dll + /DELAYLOAD:wtsapi32.dll ) list(APPEND CEF_COMPILER_DEFINES WIN32 _WIN32 _WINDOWS # Windows platform