[Webkit-unassigned] [Bug 271889] New: [GTK] Print dialog hang in _gtk_window_present(), webkit_print_operation_run_dialog() is unsafe and should be deprecated and replaced

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Mar 29 08:08:17 PDT 2024


https://bugs.webkit.org/show_bug.cgi?id=271889

            Bug ID: 271889
           Summary: [GTK] Print dialog hang in _gtk_window_present(),
                    webkit_print_operation_run_dialog() is unsafe and
                    should be deprecated and replaced
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebKitGTK
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: mcatanzaro at redhat.com
                CC: bugs-noreply at webkitgtk.org

Moving this from https://gitlab.gnome.org/GNOME/epiphany/-/issues/2308. Please review that Epiphany issue for a full description of the original problem, but it amounts to this hang when running the print dialog:

Thread 1 "epiphany" received signal SIGINT, Interrupt.
0x00007ffff6ca5919 in __futex_abstimed_wait_common64 (private=0, futex_word=0x5555555fe7d0, expected=0, op=393, abstime=0x0, cancel=true) at futex-internal.c:57
57      in futex-internal.c
#0  0x00007ffff6ca5919 in __futex_abstimed_wait_common64 (private=0, futex_word=0x5555555fe7d0, expected=0, op=393, abstime=0x0, cancel=true) at futex-internal.c:57
#1  __futex_abstimed_wait_common (futex_word=futex_word at entry=0x5555555fe7d0, expected=expected at entry=0, clockid=clockid at entry=0, abstime=abstime at entry=0x0, private=private at entry=0, cancel=cancel at entry=true) at futex-internal.c:87
#2  0x00007ffff6ca599f in __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word at entry=0x5555555fe7d0, expected=expected at entry=0, clockid=clockid at entry=0, abstime=abstime at entry=0x0, private=private at entry=0) at futex-internal.c:139
#3  0x00007ffff6ca82e9 in __pthread_cond_wait_common (cond=0x5555555fe7a8, mutex=0x0, clockid=0, abstime=0x0) at pthread_cond_wait.c:503
#4  ___pthread_cond_wait (cond=cond at entry=0x5555555fe7a8, mutex=mutex at entry=0x5555555fe778) at pthread_cond_wait.c:618
#5  0x00007ffff1f8009b in read_events (display=0x5555555fe660) at ../src/wayland-client.c:1683
#6  wl_display_read_events (display=display at entry=0x5555555fe660) at ../src/wayland-client.c:1753
#7  0x00007ffff1f81539 in wl_display_dispatch_queue (queue=<optimized out>, display=<optimized out>) at ../src/wayland-client.c:1992
#8  wl_display_dispatch_queue (display=0x5555555fe660, queue=queue at entry=0x55555b981680) at ../src/wayland-client.c:1960
#9  0x00007ffff71f61ff in gdk_wayland_display_dispatch_queue (display=0x555555608fc0, event_queue=0x55555b981680) at ../gdk/wayland/gdkdisplay-wayland.c:2827
#10 gdk_wayland_toplevel_focus (toplevel=0x55555a97b5d0, timestamp=<optimized out>) at ../gdk/wayland/gdktoplevel-wayland.c:2240
#11 0x00007ffff7078249 in _gtk_window_present (window=0x55555b9cf290, timestamp=0) at ../gtk/gtkwindow.c:5269
#12 0x00007ffff7f6ab03 in unresponsive_process_timeout_cb (user_data=0x5555562c4320) at ../embed/ephy-web-view.c:801
#13 unresponsive_process_timeout_cb (user_data=user_data at entry=0x5555562c4320) at ../embed/ephy-web-view.c:779
#14 0x00007ffff7d0b7e9 in g_timeout_dispatch (source=0x55555b696f70, callback=0x7ffff7f6aa00 <unresponsive_process_timeout_cb>, user_data=0x5555562c4320) at ../glib/gmain.c:4989
#15 0x00007ffff7d0568c in g_main_dispatch (context=0x5555555c9490) at ../glib/gmain.c:3344
#16 g_main_context_dispatch_unlocked (context=0x5555555c9490) at ../glib/gmain.c:4152
#17 0x00007ffff7d66788 in g_main_context_iterate_unlocked.isra.0 (context=0x5555555c9490, block=block at entry=1, dispatch=dispatch at entry=1, self=<optimized out>) at ../glib/gmain.c:4217
#18 0x00007ffff7d0b647 in g_main_loop_run (loop=0x55555b2d5c60) at ../glib/gmain.c:4419
#19 0x00007ffff2845b9a in webkitPrintOperationRunDialogForFrame(_WebKitPrintOperation*, _GtkWindow*, WebKit::WebFrameProxy*) () from /lib64/libwebkitgtk-6.0.so.4
#20 0x00007ffff282c2cd in webkitWebViewPrintFrame(_WebKitWebView*, WebKit::WebFrameProxy*) () from /lib64/libwebkitgtk-6.0.so.4
#21 0x00007ffff28194aa in UIClient::printFrame(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, WebCore::FloatSize const&, WTF::CompletionHandler<void ()>&&) () from /lib64/libwebkitgtk-6.0.so.4
#22 0x00007ffff2714544 in Quit

So _gtk_window_present() hangs when displaying Epiphany's unresponsive web process dialog (in response to a separate bug, the web process hang). I'm not reporting a GTK bug for this because WebKit is using a nested main loop, which is inherently dangerous. Unfortunately Source/WebCore/platform/gtk/GtkVersioning.h has implementations of gtk_dialog_run() and gtk_native_dialog_run(), which are unsafe. Both of these need to be removed. Instead of running dialogs via nested main loops, we should present the dialogs and then listen to callbacks to indicate when the dialogs have a response, following the instructions "Stop using blocking dialog functions" [1]. The guidelines are there for a reason; see [2] for another recent example of a WebKit bug caused by use of a nested main loop.

Unfortunately it's impossible to follow the above advice because webkit_print_operation_run_dialog() is public API and cannot be implemented without a nested main loop. Oops; we should have removed this in the GTK 4 API version, but we missed it. This needs to be deprecated and replaced with a newer API that doesn't immediately return a result.

[1] https://docs.gtk.org/gtk4/migrating-3to4.html#stop-using-blocking-dialog-functions
[2] https://bugs.webkit.org/show_bug.cgi?id=238748#c1

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240329/9f34045f/attachment.htm>


More information about the webkit-unassigned mailing list