WayfireWM / wayfire

A modular and extensible wayland compositor
https://wayfire.org/
MIT License
2.37k stars 176 forks source link

Using a GTK application to open files in nautilus results in a nautilus crash. #1858

Closed xiaohuirong closed 1 year ago

xiaohuirong commented 1 year ago

Describe the bug After upgrading GTK to 4.12.0, using GTK applications to open files in nautilus causes nautilus to crash. I have tried both GNOME and Hyprland, and this issue did not occur in either of them. In the previous GTK 4.10.5, Wayfire functioned properly. This issue seems to be caused by this commit https://gitlab.gnome.org/GNOME/gtk/-/commit/68b8c5cd999ede0a562debc0378e90e05ae02155 in GTK.

To Reproduce Steps to reproduce the behavior:

  1. Open nautilus.
  2. Opening files with GTK applications, such as using eog to open images or gedit to open text files.
  3. Nautilus crashes, and the file doesn't open.

Expected behavior no crash.

Screenshots or stacktrace The crash log obtained using coredumpctl gdb nautilus is as follows:

#0  wl_proxy_get_version (proxy=0x0) at ../wayland-1.22.0/src/wayland-client.c:2248
2248            return proxy->version;                                                                                  
[Current thread is 1 (Thread 0x7f93e9bd3580 (LWP 49341))]
(gdb) bt
#0  wl_proxy_get_version (proxy=0x0) at ../wayland-1.22.0/src/wayland-client.c:2248
#1  0x00007f93ebfe1b0d in gtk_shell1_get_version (gtk_shell1=<optimized out>)
    at ./gdk/wayland/gtk-shell-client-protocol.h:133
#2  gdk_wayland_app_launch_context_get_startup_notify_id
    (context=<optimized out>, info=<optimized out>, files=<optimized out>)
    at ../gtk/gdk/wayland/gdkapplaunchcontext-wayland.c:96
#3  0x00007f93eb9be5d9 in g_desktop_app_info_launch_uris_with_spawn
    (info=info@entry=0x55756a6c7f90, session_bus=session_bus@entry=0x557565604c40, exec_line=0x55756a89b2b0 "eog %U", uris=uris@entry=0x55756a0c7d50 = {...}, launch_context=launch_context@entry=0x55756a6df500, spawn_flags=spawn_flags@entry=G_SPAWN_SEARCH_PATH, user_setup=0x0, user_setup_data=0x0, pid_callback=0x0, pid_callback_data=0x0, stdin_fd=-1, stdout_fd=-1, stderr_fd=-1, error=0x7ffd1872f028) at ../glib/gio/gdesktopappinfo.c:2959
#4  0x00007f93eb9bf1a7 in g_desktop_app_info_launch_uris_internal
    (error=0x7ffd1872f028, stderr_fd=-1, stdout_fd=-1, stdin_fd=-1, pid_callback_data=0x0, pid_callback=0x0, user_setup_data=0x0, user_setup=0x0, spawn_flags=G_SPAWN_SEARCH_PATH, launch_context=0x55756a6df500, uris=0x55756a0c7d50 = {...}, appinfo=0x55756a6c7f90) at ../glib/gio/gdesktopappinfo.c:3334
#5  g_desktop_app_info_launch_uris
    (error=0x7ffd1872f028, launch_context=0x55756a6df500, uris=0x55756a0c7d50 = {...}, appinfo=0x55756a6c7f90)
    at ../glib/gio/gdesktopappinfo.c:3358
#6  g_desktop_app_info_launch
    (appinfo=0x55756a6c7f90, files=<optimized out>, launch_context=0x55756a6df500, error=0x7ffd1872f028)
    at ../glib/gio/gdesktopappinfo.c:3545
#7  0x000055756371af48 in nautilus_launch_application_by_uri
    (application=0x55756a6c7f90, uris=0x557569c3aac0 = {...}, parent_window=<optimized out>)
    at ../nautilus/src/nautilus-program-choosing.c:204
#8  0x0000557563758ed4 in activate_files_internal (parameters=0x55756aa97f40)
    at ../nautilus/src/nautilus-mime-actions.c:1699
#9  0x000055756370e832 in file_list_file_ready_callback (file=<optimized out>, user_data=0x557569dcd680)
    at ../nautilus/src/nautilus-file.c:8901
#10 file_list_file_ready_callback (file=<optimized out>, user_data=0x557569dcd680)
    at ../nautilus/src/nautilus-file.c:8889
#11 0x000055756376ceab in call_ready_callbacks_at_idle (callback_data=0x557569d83f20)
    at ../nautilus/src/nautilus-directory-async.c:2010
#12 0x00007f93ec5b1a31 in g_main_dispatch (context=0x557565605490) at ../glib/glib/gmain.c:3460
#13 g_main_context_dispatch (context=0x557565605490) at ../glib/glib/gmain.c:4200
--Type <RET> for more, q to quit, c to continue without paging--c
#14 0x00007f93ec60ecc9 in g_main_context_iterate.isra.0
    (context=context@entry=0x557565605490, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at ../glib/glib/gmain.c:4276
#15 0x00007f93ec5af0e2 in g_main_context_iteration (context=context@entry=0x557565605490, may_block=may_block@entry=1)
    at ../glib/glib/gmain.c:4343
#16 0x00007f93eb9d5ed6 in g_application_run
    (application=application@entry=0x5575655efe20, argc=argc@entry=1, argv=argv@entry=0x7ffd1872f438)
    at ../glib/gio/gapplication.c:2573

Wayfire version wayfire-git-0.7.5.r702.g004fcea8 on ArchLinux

ammen99 commented 1 year ago

Hi, I am not sure which commit g004fcea8 is, are you using latest wayfire-git or the 0.7.5 release? There have been fixes on the master branch related to gtk-shell, so you might want to check that out if you haven't done it yet.

xiaohuirong commented 1 year ago

I'm using a version of Wayfire compiled from the latest commit 004fcea. g004fcea8 is 004fcea8 with a 'g' prefix added. The PKGBUILD file is from aur/wayfire-git.

# Maintainer: Solomon Choina <shlomochoina@gmail.com>
# Co-Maintainer: Frank Tao <frank.tao@uwaterloo.ca>
pkgname=wayfire-git
pkgver=0.7.5.r702.g004fcea8
pkgrel=1
pkgdesc="3D wayland compositor"
arch=('x86_64')
url="https://github.com/WayfireWM/wayfire"
license=('MIT')
depends=('cairo' 'pango' 'doctest' 'freetype2' 'glm' 'nlohmann-json'
         'libdrm' 'libevdev' 'libglvnd' 'libinput' 'libjpeg'
         'libpng' 'libxkbcommon' 'libxml2' 'pixman' 'polkit'
         'pkgconf' 'seatd' 'xcb-util-errors' 'xcb-util-renderutil'
         'xcb-util-wm' 'xorg-xwayland' 'wayland' 'wayland-protocols')
makedepends=('git' 'glslang' 'meson' 'ninja' 'cmake' 'vulkan-headers')
optdepends=('xorg-xeyes')
provides=("${pkgname%-git}" 'wlroots' 'wf-config' 'wlroots-git' 'wf-config-git' 'libwlroots.so')
conflicts=("$pkgname" 'wlroots-git' 'wlroots' 'wf-config-git' 'wf-config')
replaces=()
options=()

source=('git+https://github.com/WayfireWM/wayfire')
sha256sums=('SKIP')

pkgver() {
    cd "$srcdir/wayfire"
  tag=$(git tag -l | awk '/^[0-9.]+$/ {print $0} /^v{1}[0-9.]+$/ {print substr($0,2)}'|sort -n|tail -n1)
  printf "$tag.r%s.g%s" "$(git rev-list --count v${tag}..HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
    cd "$srcdir/wayfire/"
    arch-meson \
        --buildtype=release \
        -Dxwayland=auto \
        -Duse_system_wlroots=disabled \
        -Duse_system_wfconfig=disabled \
        -Db_lto=true \
        -Db_pie=true \
        build
    ninja -C build
    sed "/WF_SRC_DIR/d" -i build/config.h
}

package() {
    cd "$srcdir/wayfire"
    DESTDIR="$pkgdir/" ninja -C build install
    install -Dm644 wayfire.desktop $pkgdir/usr/share/wayland-sessions/wayfire.desktop
    cp wayfire.ini $pkgdir/usr/share
}
ammen99 commented 1 year ago

Actually, do you have the gtk-shell plugin enabled?

ammen99 commented 1 year ago

After reading the gtk commit, I believe this is actually a bug in gtk4. If the compositor does not support xdg-activation (Wayfire currently does not) and does not support gtk-shell (if the gtk-shell plugin is disabled), gtk will try to access the version of display->gtk_shell, which will be NULL.

It likely works on hyprland and gnome since they support xdg-activation / gtk-shell.

If this crash happens with the gtk-shell plugin disabled, then you should open a bug report against gtk.

xiaohuirong commented 1 year ago

I discovered that I hadn't enabled the gtk-shell plugin before. After enabling it, the crash issue no longer occurs. Thank you. I have already reported the corresponding issue to gtk. https://gitlab.gnome.org/GNOME/gtk/-/issues/6048