Prevent GTK from initializing Vulkan. This improves startup time

This commit is contained in:
Isaac Mills
2024-11-26 11:10:00 -07:00
parent 4c2d462000
commit 39fbd7db4b
2 changed files with 7 additions and 1 deletions

View File

@ -99,9 +99,11 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
c.gtk_get_micro_version(), c.gtk_get_micro_version(),
}); });
// Disabling Vulkan can improve startup times by hundreds of
// milliseconds on some systems
if (version.atLeast(4, 16, 0)) { if (version.atLeast(4, 16, 0)) {
// From gtk 4.16, GDK_DEBUG is split into GDK_DEBUG and GDK_DISABLE // From gtk 4.16, GDK_DEBUG is split into GDK_DEBUG and GDK_DISABLE
_ = internal_os.setenv("GDK_DISABLE", "gles-api"); _ = internal_os.setenv("GDK_DISABLE", "gles-api,vulkan");
_ = internal_os.setenv("GDK_DEBUG", "opengl"); _ = internal_os.setenv("GDK_DEBUG", "opengl");
} else if (version.atLeast(4, 14, 0)) { } else if (version.atLeast(4, 14, 0)) {
// We need to export GDK_DEBUG to run on Wayland after GTK 4.14. // We need to export GDK_DEBUG to run on Wayland after GTK 4.14.
@ -110,7 +112,10 @@ pub fn init(core_app: *CoreApp, opts: Options) !App {
// reassess... // reassess...
// //
// Upstream issue: https://gitlab.gnome.org/GNOME/gtk/-/issues/6589 // Upstream issue: https://gitlab.gnome.org/GNOME/gtk/-/issues/6589
_ = internal_os.setenv("GDK_DISABLE", "vulkan");
_ = internal_os.setenv("GDK_DEBUG", "opengl,gl-disable-gles"); _ = internal_os.setenv("GDK_DEBUG", "opengl,gl-disable-gles");
} else {
_ = internal_os.setenv("GDK_DISABLE", "vulkan");
} }
if (version.atLeast(4, 14, 0)) { if (version.atLeast(4, 14, 0)) {

View File

@ -843,6 +843,7 @@ const Subprocess = struct {
// Don't leak these environment variables to child processes. // Don't leak these environment variables to child processes.
if (comptime build_config.app_runtime == .gtk) { if (comptime build_config.app_runtime == .gtk) {
env.remove("GDK_DEBUG"); env.remove("GDK_DEBUG");
env.remove("GDK_DISABLE");
env.remove("GSK_RENDERER"); env.remove("GSK_RENDERER");
} }