flathub / chat.rocket.RocketChat

https://flathub.org/apps/details/chat.rocket.RocketChat
3 stars 8 forks source link

Application silently closes a few seconds after startup #122

Open mss opened 9 months ago

mss commented 9 months ago

I reinstalled one of my notebooks and added a the Rocket Chat flatpak. The client (version 3.9.9 commit d0800cdeb4cb869af7d072b920de162937ed501d4720413c23159cff80a77830) shows an odd behaviour: It first seems to work fine and if I am quick enough I can even log in to our server. But after a few (20 or so?) seconds the main window just closes and disappears without any traces. This even happens if I leave it sitting at the login screen.

I have an older 3.9.8 client still installed on another notebook and it still works fine there. I rolled this one back to the commit on that other machine and it was still "crashing". Both systems are running KDE neon 5.27 (ie. a modified Ubuntu 22.04) both using a Wayland session but on different hardware and even though the config is similar there will be some differences somewhere. Purging ~/.var/app/chat.rocket.RocketChat on the new machine didn't help and I don't want to try this on the old one since the client still works there.

This is the output of the started application:

# kioclient exec /var/lib/flatpak/exports/share/applications/chat.rocket.RocketChat.desktop 
kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/file" not found
[2:1005/124546.553883:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
LaunchProcess: failed to execvp:
xdg-settings
[2:1005/124548.639356:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/124548.639432:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[bugsnag] Loaded!
[2:1005/124551.531963:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/124551.538637:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/124551.538765:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[bugsnag] 1 session(s) reported

The [bugsnag] 1 session(s) reported is not when the application closes, it will sit there for the mentioned bunch of seconds and one can still interact with the application. This sounds a bit like #112 due to the D-Bus errors. For testing I already gave the app the missing system and user bus permissions which made those messages go away but it still "crashes".

The running process tree looks like this (there is a zombie process hidden in the tree):

  10092 pts/1    S      0:00  \_ bwrap --args 40 rocketchat-desktop
  10102 pts/1    S      0:00  |   \_ bwrap --args 40 rocketchat-desktop
  10103 pts/1    Sl     0:04  |       \_ /app/Rocket.Chat/rocketchat-desktop --ozone-platform-hint=auto
  10106 pts/1    S      0:00  |       |   \_ cat
  10107 pts/1    S      0:00  |       |   \_ cat
  10112 pts/1    S      0:00  |       |   \_ /app/Rocket.Chat/rocketchat-desktop --type=zygote --no-zygote-sandbox
  10160 pts/1    Sl     0:01  |       |   |   \_ /app/Rocket.Chat/rocketchat-desktop --type=gpu-process --ozone-platform=wayland --enable-crash-reporter=cbff32b1-ef97-4587-bcab-75f81a86d12d,no_channel --user-data-dir=/home/me/.var/app/chat.rocket.RocketChat/config/Rocket.Chat --gpu-preferences=WAAAAAAAAAAgAAAYAAAAAAAAAAAAAAAAAABgAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAOAAAAAAAAAAAAAAAAAAAABAAAAABAAAACAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAACAAAAAAAAAAIAAAAAAAAAA== --shared-files --field-trial-handle=0,i,1443331300948539480,5047794668737025111,131072 --disable-features=HardwareMediaKeyHandling,MediaSessionService,SpareRendererForSitePerProcess
  10114 pts/1    Z      0:00  |       |   \_ [zypak-sandbox] <defunct>
  10167 pts/1    Sl     0:00  |       |   \_ /app/Rocket.Chat/rocketchat-desktop --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --enable-crash-reporter=cbff32b1-ef97-4587-bcab-75f81a86d12d,no_channel --user-data-dir=/home/me/.var/app/chat.rocket.RocketChat/config/Rocket.Chat --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,1443331300948539480,5047794668737025111,131072 --disable-features=HardwareMediaKeyHandling,MediaSessionService,SpareRendererForSitePerProcess
  10218 pts/1    Sl     0:02  |       |   \_ /app/Rocket.Chat/rocketchat-desktop --type=renderer --enable-crash-reporter=cbff32b1-ef97-4587-bcab-75f81a86d12d,no_channel --user-data-dir=/home/me/.var/app/chat.rocket.RocketChat/config/Rocket.Chat --app-path=/app/Rocket.Chat/resources/app.asar --no-sandbox --no-zygote --autoplay-policy=no-user-gesture-required --ozone-platform=wayland --lang=en-US --num-raster-threads=2 --enable-main-frame-before-activation --renderer-client-id=5 --time-ticks-at-unix-epoch=-1696494141782508 --launch-time-ticks=8608585300 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,1443331300948539480,5047794668737025111,131072 --disable-features=HardwareMediaKeyHandling,MediaSessionService,SpareRendererForSitePerProcess
  10236 pts/1    Sl     0:10  |       |   \_ /app/Rocket.Chat/rocketchat-desktop --type=renderer --enable-crash-reporter=cbff32b1-ef97-4587-bcab-75f81a86d12d,no_channel --user-data-dir=/home/me/.var/app/chat.rocket.RocketChat/config/Rocket.Chat --app-path=/app/Rocket.Chat/resources/app.asar --no-sandbox --no-zygote --disable-blink-features --autoplay-policy=no-user-gesture-required --ozone-platform=wayland --lang=en-US --num-raster-threads=2 --enable-main-frame-before-activation --renderer-client-id=7 --time-ticks-at-unix-epoch=-1696494141782508 --launch-time-ticks=8610333779 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,1443331300948539480,5047794668737025111,131072 --disable-features=HardwareMediaKeyHandling,MediaSessionService,SpareRendererForSitePerProcess
  10266 pts/1    Sl     0:00  |       |   \_ /app/Rocket.Chat/rocketchat-desktop --type=utility --utility-sub-type=audio.mojom.AudioService --lang=en-US --service-sandbox-type=none --enable-crash-reporter=cbff32b1-ef97-4587-bcab-75f81a86d12d,no_channel --user-data-dir=/home/me/.var/app/chat.rocket.RocketChat/config/Rocket.Chat --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,1443331300948539480,5047794668737025111,131072 --disable-features=HardwareMediaKeyHandling,MediaSessionService,SpareRendererForSitePerProcess
  10126 ?        S      0:00  |       \_ bwrap --args 41 /app/bin/zypak-helper child - /app/Rocket.Chat/rocketchat-desktop --type=zygote
  10127 ?        S      0:00  |           \_ /app/Rocket.Chat/rocketchat-desktop --type=zygote
andrevmatos commented 9 months ago

Hmm, this is a weird issue, never saw anything like that; could it be that it's for some reason minimizing to SysTray without noticing, maybe without systray visible? Can you try enabling the Tray Icon in the View menu, and checking if you can find the window? Is the flatpak command/process still running (in your shell, indicating only the window disappared) or did it quit as well? If it finishes, what's the return code (echo $?)?

mss commented 9 months ago

I also suspected the Tray Icon but that option is disabled and no tray icon hanging around.

I am not sure which flatpak process you mean. When I grep for flatpak I get these processes when the app isn't running (the first one is not relevant):

   8924 ?        Sl     0:13  |   \_ /usr/bin/systemsettings kcm_flatpak
   5887 ?        Ssl    0:00  \_ /usr/libexec/flatpak-session-helper
   5891 ?        Ss     0:00  \_ server --sh -n /run/user/1000/.flatpak-helper/pkcs11-flatpak-5887 --provider p11-kit-trust.so pkcs11:model=p11-kit-trust?write-protected=yes

and these processes when it is running:

   8924 ?        Sl     0:13  |   \_ /usr/bin/systemsettings kcm_flatpak
   5887 ?        Ssl    0:00  \_ /usr/libexec/flatpak-session-helper
   5891 ?        Ss     0:00  \_ server --sh -n /run/user/1000/.flatpak-helper/pkcs11-flatpak-5887 --provider p11-kit-trust.so pkcs11:model=p11-kit-trust?write-protected=yes
  11555 ?        Ssl    0:00  \_ /usr/libexec/flatpak-portal

I think the p11-kit one might be a leftover of the Chromium flatpak I used earlier.

Something else I noticed just now: The message [bugsnag] 1 session(s) reported doesn't appear right away but around 5 seconds after the previous line. And a few seconds later the window closes.

mss commented 9 months ago

Ah, now I know which flatpak process you mean. I ran flatpak run chat.rocket.RocketChat instead of the kioexec from the command line and the behaviour is the same. It stays around but I can't see any processes named flatpak, I guess it execs bwrap?

Anyway, the error code is now 137.

mss commented 9 months ago

I strace'd the app (without -f since that output is overwhelming) and the last few lines are below (I hit return before and after the 1 session(s) reported output):

signalfd4(-1, [CHLD], 8, SFD_CLOEXEC|SFD_NONBLOCK) = 3
poll([{fd=3, events=POLLIN}, {fd=4, events=POLLIN}], 2, -1[2:1005/133003.802554:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
LaunchProcess: failed to execvp:
xdg-settings
[2:1005/133005.465392:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/133005.465525:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[bugsnag] Loaded!
[2:1005/133007.805604:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/133007.805712:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/133007.805767:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory

[bugsnag] 1 session(s) reported

) = 1 ([{fd=3, revents=POLLIN}])
read(4, 0x7ffe1ddd7640, 8)              = -1 EAGAIN (Resource temporarily unavailable)
read(3, "\21\0\0\0\0\0\0\0\2\0\0\0J2\0\0\350\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 128) = 128
wait4(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGKILL}], WNOHANG, NULL) = 12874
exit_group(137)                         = ?
+++ exited with 137 +++
andrevmatos commented 9 months ago

Yes, flatpak spawns the bwrap one. Hmm, 137 usually means some kind of seg fault; may be an Electron issue, possibly caused by some bug on the many libraries that need to be bundled and interact correctly with the system. #121 has a report of something with libnotify. Unfortunately, I'm not too much into electron debugging in order to track this down, and couldn't reproduce here. Maybe this is worth an upstream issue at https://github.com/RocketChat/Rocket.Chat.Electron/issues ?

mss commented 9 months ago

Sure, I can do that. Will they look at flatpak related issues or tell me to go away?

andrevmatos commented 9 months ago

I think they want to help with flatpaks, as they're even considering adopting this as default/official distribution method afaik. Sorry to send you upstream, but I really don't know how to help in this case. Please, link back this issue, and we can close it when the upstream issue is sorted out. Thank you.

mss commented 9 months ago

No problem, will do.

BTW, I suspected Wayland to be the issue but found out how to enforce X11 and it behaves the same (just some added OpenGL related issues, I guess there are some missing permissions for that):

# flatpak run chat.rocket.RocketChat --ozone-platform-hint=x11
[2:1005/134218.315182:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
LaunchProcess: failed to execvp:
xdg-settings
[2:1005/134220.089143:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/134220.089275:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[bugsnag] Loaded!
[2:1005/134222.648920:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/134222.648986:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/134222.649031:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[43:1005/134222.823447:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
[43:1005/134225.071571:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 2 times!
[43:1005/134225.075295:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 3 times!
[bugsnag] 1 session(s) reported
andrevmatos commented 9 months ago

The system bus issue is common from apps running in flatpak, and is usually harmless (I also get them, and it doesn't affect the functionality).

mss commented 9 months ago

I wonder about that xdg-settings one though. Also just a scary message or does it try to resolve some config option and falls on its face if it can't?

andrevmatos commented 9 months ago

Seems also to be harmless. Here's my output:

$ flatpak --user run chat.rocket.RocketChat
[2:1005/092303.110955:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
LaunchProcess: failed to execvp:
xdg-settings
[2:1005/092303.930329:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/092303.930372:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[bugsnag] Loaded!
[2:1005/092305.092014:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/092305.092059:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:1005/092305.092093:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[bugsnag] 1 session(s) reported
geekgonecrazy commented 9 months ago

Symptoms sound exactly like what happens to me in #121 . Usually just get a notification coming in and it dies.

Try starting and putting your users status in all workspaces in busy. It probably won't happen. Or alternatively open it and trigger someone to DM you while not in busy and see if crashes right away. I bet its the same issue.

I have a lot of little logs like this in mine too but they don't seem to be critical and more related to electron. The actual crash to me seemed random until I happened to notice the timing was associated with notifications coming in.

bbhtt commented 9 months ago

This is likely a crash. Can you get the backtrace? Thanks.

One possible cause was fixed in the Electron baseapp, so the next rebuild of rocketchat would fix that one https://github.com/flathub/chat.rocket.RocketChat/issues/121#issuecomment-1751891556

andrevmatos commented 9 months ago

@geekgonecrazy can you please the most recent build, which should include the electron baseapp fix?

bbhtt commented 9 months ago

It's not published yet, wait 4-5 hours for it to get published. (Clicking publish to force it will overwhelm the servers)

andrevmatos commented 9 months ago

I understand, the link I posted include a flatpakref which could be used to install it directly for test, which is what I expected, but it's ok to wait for it to be published as well; thanks

mss commented 9 months ago

@bbhtt I installed the rebuilt app (0cadd7084e3c3f79c00aba19c8af5d224b6130a934e7d17f71c00792f8e8efd6) and it still "crashes". I also updated the version on that other machine (which runs exactly the same KDE Neon patch level) and that one still doesn't crash.

I'd go and install the debug symbols but I'd have to resize my partition and since apart from one time there isn't anything related to this app caught by coredumpd I doubt that this will shed any light on the issue. Or am I wrong?

TIME                           PID  UID  GID SIG     COREFILE EXE                               SIZE
Thu 2023-10-05 16:20:34 CEST 18662 1000 1000 SIGABRT missing  /app/bin/zypak-helper              n/a
Fri 2023-10-06 19:45:14 CEST 21046 1000 1000 SIGSEGV missing  /usr/lib/firefox/plugin-container  n/a
Fri 2023-10-06 19:45:46 CEST 21111 1000 1000 SIGSEGV missing  /usr/lib/firefox/plugin-container  n/a
Mon 2023-10-09 10:04:20 CEST  4030    0    0 SIGABRT present  /usr/libexec/packagekitd          1.8M
Tue 2023-10-10 18:48:18 CEST  1393    0    0 SIGABRT present  /usr/libexec/packagekitd          4.4M
bbhtt commented 9 months ago

Yea, there's no coredump there. Try running it under gdb inside the sandbox and try to reproduce it.

mss commented 9 months ago

Since there is no real crash and more than a hundred processes spawned I wouldn't know where to start debugging. But I ran the command as strace -e decode-pids=comm,pidns -e trace=process -rT -o rocketchat.log -f flatpak run chat.rocket.RocketChat (cf. rocketchat.log) and found something odd: Something (probably systemd?) is sending SIGKILL to all (most?) the processes. And a SIGKILL will result in a 137 and according to the bwrap manpage will it return the status code of the inner pid 2 which is pid 9278 in this case (yet another bwrap process) which finishes a wait4 right before the SIGKILL spree.

mss commented 9 months ago

BTW: This is not a general Flatpak or even Electron-in-Flatpak issue with my system: I also have the teams-for-linux flatpak installed and that one works fine. The ps tree looks very similar to the Rocket Chat one, including those zypak processes and the one zombie.

bbhtt commented 9 months ago

Something (probably systemd?) is sending SIGKILL to all (most?) the processes

Are you getting oom killed? Check the journalctl for systemd-oomd logs, journalctl -t systemd-oomd

A SIGKILL is also sent by xdg-desktop-portal when an app wants to run in background but it was denied by the user. Check flatpak permission-show chat.rocket.RocketChat to see if background permission was denied. You can permission-reset it or go in GNOME settings> allow to run in background.

To confirm it it is xdg-desktop-portal, edit the xdg-desktop.portal.service systemctl --user edit xdg-desktop.portal.service and add:

[Service]
Environment="G_MESSAGES_DEBUG=all"

then systemctl --user daemon-reload, systemctl --user restart xdg-desktop-portal.service and check the journal logs for something like Kill app <app name>

mss commented 9 months ago

It is definitely no OOM situation (there are around 20 GB free RAM when this happens). But I'll check (and compare to teams-for-linux) the permissions later on. And I found this way to trace all signals flying around, I will try that as well.

geekgonecrazy commented 9 months ago

image

i'm on latest and it still crashes.

bbhtt commented 9 months ago

Without anything to go by this is really hard to debug.

All I got so far that it's getting SIGKILL-ed by something. Please check https://github.com/flathub/chat.rocket.RocketChat/issues/122#issuecomment-1756608886 to see if it is xdg-desktop-portal, otherwise journalctl --follow might have some info on what's killing it.

Fwiw, I kept it open for a while on the sign in page and I don't see any crash.

flatpak run chat.rocket.RocketChat --ozone-platform-hint=x11

You don't need to do this, no idea if passing it twice works. The flatpak already passes auto which will choose x11 if you're on X11 session, wayland if on wayland session.

LaunchProcess: failed to execvp:
xdg-settings
[2:1005/124548.639356:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory

These are fine as well. Every electron app in a flatpak will have those warnings.

And I found this way to trace all signals flying around, I will try that as well.

Any luck here?