GTK4 Compilation with Visual Studio 2022 Causes System Unresponsiveness in Debug Mode

I compiled GTK4 (any version from 4.6) with Meson and Visual Studio 2022 using the following configuration command:

meson . _build --prefix=C:\GTK\release --libdir=lib -Dcpp_std=c++17 -Dvulkan=disabled -Dintrospection=disabled -Dmedia-gstreamer=disabled -Dpixman:tests=disabled -Dglib:tests=false -Dx11-backend=false -Dbuild-tests=false -Dbuild-demos=true -Dbuild-examples=true -Dx11-backend=false -Dwayland-backend=false --buildtype=release -Dc_std=c11

When I start Visual Studio in Debug mode, GTK4 makes the entire system very busy and unresponsive. This happens regardless of whether GTK is compiled in release mode (as shown in the command above) or debug mode.

Does anyone have any suggestions on how to compile GTK4 for Visual Studio 2022 on Windows to enable normal debug sessions without causing the system to become unresponsive?

Any idea? Anyone? I tried debugging my apps with release version of gtk. Same issue.

Hi @Kemo_G_Kemic,

This is a known issue: GTK installs a low-level keyboard hook to implement custom AeroSnap on Windows. If you can compile GTK yourself, the functionality can be disabled with a simple patch:

diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 93a3bb6e0a..679c126c46 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -405,6 +405,7 @@ low_level_keyboard_proc (int    code,
 static void
 set_up_low_level_keyboard_hook (void)
 {
+#if 0
   HHOOK hook_handle;
 
   if (keyboard_hook != NULL)
@@ -418,6 +419,7 @@ set_up_low_level_keyboard_hook (void)
     keyboard_hook = hook_handle;
   else
     WIN32_API_FAILED ("SetWindowsHookEx");
+#endif
 
   aerosnap_message = RegisterWindowMessage (L"GDK_WIN32_AEROSNAP_MESSAGE");
 }

Anyway this is legacy code and possibly the hook will be removed in a future relase

See gdk-win32: low level hook slows down keyboard during block/sleep of main thread, e.g. during interactive debugging (#2015) · Issues · GNOME / gtk · GitLab

1 Like

Excellent! Thank you very much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.