GTK 4 UI process crash after web process crash
After switching to GTK 4, we now have a UI process crash that occurs when a web process crashes. This crash occurred after I hit https://bugs.webkit.org/show_bug.cgi?id=246460:
gdb) bt
#0 g_logv
(log_domain=0x7ffb40ab9409 "Gtk", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=<optimized out>)
at ../glib/gmessages.c:1424
#1 0x00007ffb41054623 in g_log
(log_domain=log_domain@entry=0x7ffb40ab9409 "Gtk", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffb410b20c3 "%s: assertion '%s' failed") at ../glib/gmessages.c:1462
#2 0x00007ffb41054fad in g_return_if_fail_warning
(log_domain=log_domain@entry=0x7ffb40ab9409 "Gtk", pretty_function=pretty_function@entry=0x7ffb40b0eb00 <__func__.125> "gtk_widget_get_parent", expression=expression@entry=0x7ffb40aca224 "GTK_IS_WIDGET (widget)")
at ../glib/gmessages.c:2950
#3 0x00007ffb408cbe1a in gtk_widget_get_parent (widget=<optimized out>) at ../gtk/gtkwidget.c:6112
#4 gtk_widget_get_parent (widget=<optimized out>) at ../gtk/gtkwidget.c:6108
#5 0x00007ffb412bab20 in () at /app/lib/epiphany/libephymain.so
#9 0x00007ffb411652e3 in <emit signal ??? on instance 0x55daf0cbf8e0 [EphyWebView]>
(instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../gobject/gsignal.c:3606
#6 0x00007ffb411494d2 in g_closure_invoke
(closure=0x55daf0cc3010, return_value=return_value@entry=0x0, n_param_values=2, param_values=param_values@entry=0x7ffca86fa320, invocation_hint=invocation_hint@entry=0x7ffca86fa2a0) at ../gobject/gclosure.c:832
#7 0x00007ffb4115e1a8 in signal_emit_unlocked_R
(node=node@entry=0x55daef180c00, detail=detail@entry=0, instance=instance@entry=0x55daf0cbf8e0, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7ffca86fa320) at ../gobject/gsignal.c:3796
#8 0x00007ffb41165115 in g_signal_emit_valist
(instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7ffca86fa4c0) at ../gobject/gsignal.c:3549
#10 0x00007ffb3cb38041 in webkitWebViewWebProcessTerminated(_WebKitWebView*, WebKitWebProcessTerminationReason)
(webView=0x55daf0cbf8e0 [EphyWebView], reason=WEBKIT_WEB_PROCESS_CRASHED)
at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp:4723
#11 0x00007ffb3cb0e4f3 in NavigationClient::processDidTerminate(WebKit::WebPageProxy&, WebKit::ProcessTerminationReason) (this=<optimized out>, reason=<optimized out>)
at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/Source/WebKit/UIProcess/API/glib/WebKitNavigationClient.cpp:113
#12 0x00007ffb3ca9115d in WebKit::WebPageProxy::dispatchProcessDidTerminate(WebKit::ProcessTerminationReason)
(this=0x7ffade048400, reason=WebKit::ProcessTerminationReason::Crash)
at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/Source/WebKit/UIProcess/WebPageProxy.cpp:8138
#13 0x00007ffb3ca917c7 in WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch(WebKit::ProcessTerminationReason) (this=<optimized out>, reason=<optimized out>)
at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/Source/WebKit/UIProcess/WebProcessProxy.cpp:929
#14 0x00007ffb3c96d7ce in operator() (__closure=0x7ffa12450188)
at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/Source/WebKit/Platform/IPC/Connection.cpp:944
#15 WTF::Detail::CallableWrapper<IPC::Connection::connectionDidClose()::<lambda()>, void>::call(void)
(this=0x7ffa12450180) at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/_builddir/WTF/Headers/wtf/Function.h:53
#16 0x00007ffb3badf0e5 in WTF::Function<void ()>::operator()() const (this=<synthetic pointer>)
at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/Source/WTF/wtf/Function.h:79
#17 WTF::RunLoop::performWork() (this=0x7ffb2e0100e0)
at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/Source/WTF/wtf/RunLoop.cpp:133
#18 0x00007ffb3bb3f38d in operator() (userData=<optimized out>, __closure=0x0)
at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/Source/WTF/wtf/glib/RunLoopGLib.cpp:80
#19 _FUN(gpointer) () at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/Source/WTF/wtf/glib/RunLoopGLib.cpp:82
#20 0x00007ffb3bb3fd4d in operator()
(__closure=0x0, userData=0x7ffb2e0100e0, callback=0x7ffb3bb3f380 <_FUN(gpointer)>, source=0x55daee124000)
at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/Source/WTF/wtf/glib/RunLoopGLib.cpp:53
#21 _FUN(GSource*, GSourceFunc, gpointer) ()
at /usr/lib/debug/source/sdk/webkit2gtk-5.0.bst/Source/WTF/wtf/glib/RunLoopGLib.cpp:56
#22 0x00007ffb4104c661 in g_main_dispatch (context=<optimized out>) at ../glib/gmain.c:3444
#23 g_main_context_dispatch (context=<optimized out>) at ../glib/gmain.c:4162
#24 0x00007ffb4104cbb8 in g_main_context_iterate (context=context@entry=0x55daee0f5b40, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4238
#25 0x00007ffb4104cc53 in g_main_context_iteration (context=context@entry=0x55daee0f5b40, may_block=may_block@entry=1) at ../glib/gmain.c:4303
#26 0x00007ffb40ef2bad in g_application_run (application=0x55daee1221f0 [EphyShell], argc=<optimized out>, argv=<optimized out>) at ../gio/gapplication.c:2571
#27 0x000055daece810c0 in main ()
Notice we are missing debuginfo for that critical Epiphany frame. This is Epiphany Tech Preview, so our debuginfo should always be updated if org.gnome.Epiphany.Devel.Debug extension is installed. This is a longstanding GNOME infrastructure bug. :/ Without working debuginfo, it's tough to know where exactly the crash occurs. But we know it's happening when emitting some signal of EphyWebView. At least we have a finite number of cases to consider:
$ git grep gtk_widget_get_parent
embed/ephy-embed-utils.h:#define EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW(view) (EPHY_EMBED (gtk_widget_get_parent (gtk_widget_get_parent ((GTK_WIDGET (view))))))
embed/ephy-embed.c: if (gtk_widget_get_parent (GTK_WIDGET (container)) == NULL)
embed/ephy-embed.c: if (gtk_widget_get_parent (GTK_WIDGET (container)) == embed->overlay) {
src/bookmarks/ephy-add-bookmark-popover.c: parent = gtk_widget_get_parent (GTK_WIDGET (self));
src/bookmarks/ephy-add-bookmark-popover.c: parent = gtk_widget_get_parent (GTK_WIDGET (self));
src/bookmarks/ephy-bookmark-properties.c: box = gtk_widget_get_parent (GTK_WIDGET (button));
src/bookmarks/ephy-bookmark-properties.c: flow_box_child = gtk_widget_get_parent (box);
src/ephy-action-bar-start.c: GtkWidget *parent = gtk_widget_get_parent (action_bar_start->history_menu);
src/ephy-fullscreen-box.c: parent = gtk_widget_get_parent (parent);
src/ephy-window.c: parent = gtk_widget_get_parent (GTK_WIDGET (info_bar));
src/webextension/api/tabs.c: GtkWidget *page = gtk_widget_get_parent (gtk_widget_get_parent (GTK_WIDGET (web_view)));
src/webextension/ephy-web-extension-manager.c: GtkWidget *parent = gtk_widget_get_parent (action);
$ git grep EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW
embed/ephy-embed-utils.h:#define EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW(view) (EPHY_EMBED (gtk_widget_get_parent (gtk_widget_get_parent ((GTK_WIDGET (view))))))
embed/ephy-web-view.c: ephy_embed_add_top_widget (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
embed/ephy-web-view.c: ephy_embed_add_top_widget (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
embed/ephy-web-view.c: if (!ephy_embed_has_load_pending (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view))) {
embed/ephy-web-view.c: ephy_embed_add_top_widget (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
embed/ephy-web-view.c: ephy_embed_add_top_widget (EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
embed/ephy-web-view.c: embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view);
embed/ephy-web-view.c: EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view));
embed/ephy-web-view.c: EphyEmbed *embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view);
src/ephy-window.c: EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
src/ephy-window.c: g_idle_add (delayed_remove_child, EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view));
src/ephy-window.c: data->modified_embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view);