Repository navigation
perf: trim GTK and FontConfig work off the linux startup path - #53070
Conversation
deepak1556
left a comment
There was a problem hiding this comment.
Upstream CL skips the GDK_GL probe for gtk 4 (which we do support as well ?), any reason to not align here ?
7231c66 to
27ae2e1
Compare
|
upstream can branch on the version because it runs after |
27ae2e1 to
5b4db80
Compare
|
Release Notes Persisted
|
|
I was unable to backport this PR to "42-x-y" cleanly; |
|
I have automatically backported this PR to "44-x-y", please check out #53107 |
|
I have automatically backported this PR to "43-x-y", please check out #53108 |
Description of Change
Linux app launch to
readydrops ~35 ms and launch to first contentful paint ~55 ms (release build, X11, medians of 25-30 interleaved cold launches per side), from two independent main-thread costs during toolkit initialization. Two commits:readygtk_init()(Row 2 was measured on a lower-variance base than row 1, hence the different absolute numbers;
new BrowserWindowand everything after first paint are unchanged in both.)1. GDK GL probe. When GTK initializes inside
ui::GetDefaultLinuxUi(), GDK probes the display for GLX/EGL support (gdk_x11_screen_init_gl-> epoxy ->glXQueryServerString), which dlopen()s the GL driver into the browser process on the main thread. Electron only uses GTK for theme colors (cairo) and native dialogs, none of which touchGdkGLContext, so the probe is pure cost: here it was 27 of the 68 ms between "JS modules loaded" andready, and the driver mappings also stay resident in the browser for the life of the app. GDK readsGDK_GLexactly once duringgtk_init(), soToolkitInitialized()setsGDK_GL=disablearound that call when the user has not set it and removes it again immediately after, before any app code can spawn children. The same change is proposed for Chromium'sGtkUi(https://crrev.com/c/8265951); this is the Electron-side form until that lands and covers Electron's own call site either way.2. FontConfig warm-up. content already tries to initialize FontConfig off the main thread (
gfx::InitializeFonts()fromBrowserMainRunnerImpl::Initialize()), but that task is posted afterBrowserMainLoopraises the ThreadPool execution fence, so it can never run before the toolkit's first font lookup doesFcInit+ config parsing on the main thread.ElectronMainDelegate::PreBrowserMain()runs after the pool is created and before it is started and fenced, so callinggfx::InitializeGlobalFontConfigAsync()there queues the work to start with the pool and overlap toolkit init; if it ever loses the race it degrades to today's behaviour, and the later content call is a no-op on theNoDestructorsingleton. Upstream review of the equivalent content change asked for exactly this placement in the embedder (https://crrev.com/c/8264864).Both are
BUILDFLAG(IS_LINUX)only; macOS and Windows are untouched.Checklist
npm testpassesRelease Notes
Notes: Improved application startup time on Linux by skipping GDK's OpenGL probe and loading FontConfig off the main thread during toolkit initialization.