scorpion-26 / gBar

Blazingly fast status bar written with GTK
MIT License
478 stars 17 forks source link

Crash on systemctl suspend #19

Closed fenneltheloon closed 5 months ago

fenneltheloon commented 1 year ago

Describe the bug When running gBar on Hyprland either from terminal or from the hyprland config, running systemctl suspend crashes the bar. I think I'm just dumb and there's some way that already exists to keep it open on system sleep but I'm not seeing how to do that written anywhere. Help appreciated!

Steps to Reproduce

  1. Run gBar
  2. Run systemctl suspend and let the system fully sleep
  3. Wake the system back up to find no bar

Expected behavior gBar should remain open like other programs that are currently running (e.g. firefox)

Screenshots/Error logs

Failed opening config!
NVML not found, disabling Nvidia GPU
Wayland: Added workspace!
Workspace ID: 2
Wayland: Deactivate Workspace 2
Wayland: Added workspace!
Workspace ID: 1
Wayland: Activate Workspace 1
Wayland: Registering monitor HDMI-A-1 at ID 0
Wayland: Added group to monitor
Forcefully activate workspace 1
PulseAudio: Context is ready!
PulseAudio: Update info
Info: No CSS found in /home/captainbanaynays/.config
Info: No CSS found in /home/captainbanaynays/.local/share
Info: No CSS found in /usr/local/share
CSS found and loaded successfully!
SNI: Clearing old children
Invalid child!

(gBar:69880): Gtk-CRITICAL **: 01:54:56.911: gtk_widget_set_visible: assertion 'GTK_IS_WIDGET (widget)' failed

(gBar:69880): Gtk-CRITICAL **: 01:54:56.911: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed
sh: line 1: checkupdates: command not found
GetOutdatedPackages: Invalid command. Disabling package widget!
SNI: Registered Item :1.54 /org/ayatana/NotificationItem/steam
SNI: Creating Item :1.54 /org/ayatana/NotificationItem/steam
SNI: Menu object path: /org/ayatana/NotificationItem/steam/Menu
SNI: Clearing old children
Destroy widget

(gBar:69880): Gtk-CRITICAL **: 01:54:58.029: gtk_widget_destroy: assertion 'GTK_IS_WIDGET (widget)' failed
SNI: Add :1.54 to widget

(gBar:69880): Gtk-CRITICAL **: 01:55:33.276: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:33.376: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed
Wayland: Added workspace!
Wayland: Deactivate Workspace 4294967295
Wayland: Deactivate Workspace 4294967295
Workspace ID: 3
Wayland: Deactivate Workspace 1
Wayland: Deactivate Workspace 2
Wayland: Activate Workspace 3

(gBar:69880): Gtk-CRITICAL **: 01:55:33.540: gtk_widget_get_style_context: assertion 'GTK_IS_WIDGET (widget)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:33.540: gtk_style_context_remove_class: assertion 'GTK_IS_STYLE_CONTEXT (context)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:33.540: gtk_style_context_add_class: assertion 'GTK_IS_STYLE_CONTEXT (context)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:33.540: gtk_widget_get_style_context: assertion 'GTK_IS_WIDGET (widget)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:33.540: gtk_style_context_remove_class: assertion 'GTK_IS_STYLE_CONTEXT (context)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:33.540: gtk_style_context_add_class: assertion 'GTK_IS_STYLE_CONTEXT (context)' failed
PulseAudio: Update info

(gBar:69880): Gtk-CRITICAL **: 01:55:33.540: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed
Wayland: Registering monitor HDMI-A-1 at ID 1
Wayland: Added group to monitor

(gBar:69880): Gtk-CRITICAL **: 01:55:33.577: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:33.677: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:33.778: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:33.878: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:33.978: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:34.079: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:34.177: gtk_label_set_text: assertion 'GTK_IS_LABEL (label)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:34.177: gtk_widget_get_style_context: assertion 'GTK_IS_WIDGET (widget)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:34.177: gtk_style_context_remove_class: assertion 'GTK_IS_STYLE_CONTEXT (context)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:34.177: gtk_style_context_add_class: assertion 'GTK_IS_STYLE_CONTEXT (context)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:34.177: gtk_button_set_label: assertion 'GTK_IS_BUTTON (button)' failed

(gBar:69880): Gtk-CRITICAL **: 01:55:34.177: gtk_label_set_text: assertion 'GTK_IS_LABEL (label)' failed
Segmentation fault (core dumped)

Information about your system and gBar

scorpion-26 commented 1 year ago

I think I'm just dumb and there's some way that already exists to keep it open on system sleep but I'm not seeing how to do that written anywhere. Help appreciated!

Thanks for the bug report! gBar is crashing (see the last line in the log). This shouldn't happen and is definitely unintended behavior. Unfortunately I'm unable to reproduce this bug. I do have a suspicion though, that it relates to the workspace widget. Can you do the following to rule things out and to give me bit more context (Please let me know whether a particular step fixes things):

  1. Download data/config and put it inside the folder ~/.config/gBar (You probably want to do this anyway to configure gBar).

  2. Set UseHyprlandIPC to true inside ~/.config/gBar/config. You probably want to set this to true anyways, since it is less buggy

  3. If both of these things don't fix the issue, can you please give me a bit more context on the crash? You can please do the following:

    • Install gdb if you haven't already
    • Clone the repo locally (e.g. git clone https://github.com/scorpion-26/gBar)
    • cd gBar
    • build gBar meson setup build && ninja -C build
    • gdb build/gBar
    • Inside gdb, run run bar 0
    • Trigger the bug (systemctl suspend and wakeup again)
    • If gBar crashed, gdb should say something along the line of Program received signal SIGSEGV, Segmentation fault. If that's the case, run bt inside gdb and post the output here.
fenneltheloon commented 1 year ago

Taking the first steps as recommended did not fix the problem. A detail that might help: when gBar is running and the system is suspended, Hyprland will resume in the first available empty workspace (if 1 is occupied, it will open in 2, if 1 and 2 are occupied it will open 3, if 1 and 3 are occupied it will open 2).

Building manually, I got a compiler error complaining that stb was not installed, worth mentioning as a prerequisite for manually building. Here's the backtrace from gdb:

#0  0x00007ffff7943e96 in gtk_widget_queue_draw (widget=0x5555558c4d20) at ../gtk/gtk/gtkwidget.c:5700
#1  0x000055555556a511 in NetworkSensor::SetUp(double) ()
#2  0x00005555555831eb in Bar::DynCtx::UpdateNetwork(NetworkSensor&) ()
#3  0x0000555555587e32 in Widget::AddTimer<NetworkSensor>(std::function<TimerResult (NetworkSensor&)>&&, unsigned int, TimerDispatchBehaviour)::{lambda(void*)#1}::_FUN(void*) ()
#4  0x00007ffff720921e in g_timeout_dispatch
    (source=0x555555786020, callback=<optimized out>, user_data=<optimized out>)
    at ../glib/glib/gmain.c:5054
#5  0x00007ffff7208981 in g_main_dispatch (context=0x5555556127f0) at ../glib/glib/gmain.c:3460
#6  g_main_context_dispatch (context=0x5555556127f0) at ../glib/glib/gmain.c:4200
#7  0x00007ffff7265b39 in g_main_context_iterate.isra.0
    (context=0x5555556127f0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at ../glib/glib/gmain.c:4276
#8  0x00007ffff7207f3f in g_main_loop_run (loop=0x5555558cb8d0) at ../glib/glib/gmain.c:4479
#9  0x00007ffff77ecf6f in gtk_main () at ../gtk/gtk/gtkmain.c:1329
#10 0x000055555556704f in main ()

Thanks for the help!

scorpion-26 commented 1 year ago

Building manually, I got a compiler error complaining that stb was not installed, worth mentioning as a prerequisite for manually building.

My bad, I forget the --recursive (stb is installed as a submodule). It is in the manual instructions though.

Unfortunately the gdb backtrace hasn't revealed any clues to me. I've got some more troubleshooting ideas, though: You mentioned, that Hyprland switches workspaces weirdly. The only dispatchers that do the described behavior are "empty" and "r". gBar only uses 'e' and 'm'. So this is seriously strange. Anyways, I added a commit which will properly log all workspace changing events by gBar. Can you attach a log with this commit? And I saw, you had Steam in your tray open, can you add a log without having steam open, so I can rule that out too (The tray icons are relatively unstable, so that could be a possibility for the issue).

fenneltheloon commented 1 year ago

New log (ran w/ gdb again, made sure steam and discord were closed):

Set value for CPUThermalZone: /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon2/temp1_input
Set value for SuspendCommand: ~/.config/scripts/sys.sh suspend
Set value for LockCommand: ~/.config/scripts/sys.sh lock
Set value for ExitCommand: killall Hyprland
Set value for BatteryFolder: /sys/class/power_supply/BAT1
Set value for DefaultWorkspaceSymbol: 
Set value for WorkspaceScrollOnMonitor: true
Set value for WorkspaceScrollInvert: false
Set value for UseHyprlandIPC: true
Set value for CenterTime: true
Set value for TimeSpace: 300
Set value for DateTimeStyle: %a %D - %H:%M %Z
Set value for AudioInput: true
Set value for AudioRevealer: true
Set value for AudioScrollSpeed: 5
Set value for CheckPackagesCommand: p="$(checkupdates)"; e=$?; if [ $e -eq 127 ] ; then exit 127; fi; if [ $e -eq 2 ] ; then echo "0" && exit 0; fi; echo "$p" | wc -l
Set value for CheckUpdateInterval: 300
Set value for NetworkAdapter: eno1
Set value for NetworkWidget: true
Set value for EnableSNI: true
Set value for SNIIconSize: *, 25
Set value for SNIIconSize: OBS, 23
Set value for MinDownloadBytes: 0
Set value for MaxDownloadBytes: 10485760
Set value for MinUploadBytes: 0
Set value for MaxUploadBytes: 5242880
NVML not found, disabling Nvidia GPU
[New Thread 0x7ffff33ff6c0 (LWP 16709)]
[New Thread 0x7ffff2bfe6c0 (LWP 16710)]
[New Thread 0x7ffff23fd6c0 (LWP 16711)]
PulseAudio: Context is ready!
PulseAudio: Update info
[New Thread 0x7ffff1bfc6c0 (LWP 16712)]
[New Thread 0x7ffff13fb6c0 (LWP 16713)]
[New Thread 0x7fffd7fff6c0 (LWP 16714)]
Info: No CSS found in /home/captainbanaynays/.config
Info: No CSS found in /home/captainbanaynays/.local/share
Info: No CSS found in /usr/local/share
CSS found and loaded successfully!
SNI: Clearing old children
Invalid child!

(gBar:16706): Gtk-CRITICAL **: 18:43:50.398: gtk_widget_set_visible: assertion 'GTK_IS_WIDGET (widget)' failed
[New Thread 0x7fffd77fe6c0 (LWP 16715)]

(gBar:16706): Gtk-CRITICAL **: 18:43:50.398: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:43:50.398: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed
[Detaching after vfork from child process 16716]
sh: line 1: checkupdates: command not found
GetOutdatedPackages: Invalid command. Disabling package widget!
[Thread 0x7fffd77fe6c0 (LWP 16715) exited]
[New Thread 0x7fffd77fe6c0 (LWP 16718)]
[Thread 0x7fffd77fe6c0 (LWP 16718) exited]
[New Thread 0x7fffd77fe6c0 (LWP 16719)]
[New Thread 0x7fffd6ffd6c0 (LWP 16720)]
[Thread 0x7fffd77fe6c0 (LWP 16719) exited]
[Thread 0x7fffd6ffd6c0 (LWP 16720) exited]
[New Thread 0x7fffd6ffd6c0 (LWP 16721)]
[New Thread 0x7fffd77fe6c0 (LWP 16722)]
[Thread 0x7fffd6ffd6c0 (LWP 16721) exited]
[Thread 0x7fffd77fe6c0 (LWP 16722) exited]
[New Thread 0x7fffd77fe6c0 (LWP 16723)]
[New Thread 0x7fffd6ffd6c0 (LWP 16724)]
[Thread 0x7fffd77fe6c0 (LWP 16723) exited]
[Thread 0x7fffd6ffd6c0 (LWP 16724) exited]
[New Thread 0x7fffd6ffd6c0 (LWP 16725)]
[New Thread 0x7fffd77fe6c0 (LWP 16726)]
[Thread 0x7fffd6ffd6c0 (LWP 16725) exited]
[Thread 0x7fffd77fe6c0 (LWP 16726) exited]
[New Thread 0x7fffd77fe6c0 (LWP 16727)]
[New Thread 0x7fffd6ffd6c0 (LWP 16728)]
[Thread 0x7fffd77fe6c0 (LWP 16727) exited]
[Thread 0x7fffd6ffd6c0 (LWP 16728) exited]
[New Thread 0x7fffd6ffd6c0 (LWP 16729)]
[New Thread 0x7fffd77fe6c0 (LWP 16730)]
[Thread 0x7fffd6ffd6c0 (LWP 16729) exited]
[Thread 0x7fffd77fe6c0 (LWP 16730) exited]
[New Thread 0x7fffd77fe6c0 (LWP 16731)]
[New Thread 0x7fffd6ffd6c0 (LWP 16732)]
[Thread 0x7fffd77fe6c0 (LWP 16731) exited]
[Thread 0x7fffd6ffd6c0 (LWP 16732) exited]
[New Thread 0x7fffd6ffd6c0 (LWP 16733)]
[New Thread 0x7fffd77fe6c0 (LWP 16734)]
[Thread 0x7fffd6ffd6c0 (LWP 16733) exited]
[Thread 0x7fffd77fe6c0 (LWP 16734) exited]
[New Thread 0x7fffd77fe6c0 (LWP 16735)]
[New Thread 0x7fffd6ffd6c0 (LWP 16736)]
[Thread 0x7fffd77fe6c0 (LWP 16735) exited]
[Thread 0x7fffd6ffd6c0 (LWP 16736) exited]
[New Thread 0x7fffd6ffd6c0 (LWP 16737)]
[New Thread 0x7fffd77fe6c0 (LWP 16738)]
[Thread 0x7fffd6ffd6c0 (LWP 16737) exited]
[Thread 0x7fffd77fe6c0 (LWP 16738) exited]
[New Thread 0x7fffd77fe6c0 (LWP 16739)]
[New Thread 0x7fffd6ffd6c0 (LWP 16740)]
[Thread 0x7fffd77fe6c0 (LWP 16739) exited]
[Thread 0x7fffd6ffd6c0 (LWP 16740) exited]
[Thread 0x7ffff1bfc6c0 (LWP 16712) exited]
[Thread 0x7ffff13fb6c0 (LWP 16713) exited]

(gBar:16706): Gtk-CRITICAL **: 18:44:33.255: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.255: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.360: gtk_widget_get_style_context: assertion 'GTK_IS_WIDGET (widget)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.360: gtk_style_context_remove_class: assertion 'GTK_IS_STYLE_CONTEXT (context)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.360: gtk_style_context_add_class: assertion 'GTK_IS_STYLE_CONTEXT (context)' failed
PulseAudio: Update info

(gBar:16706): Gtk-CRITICAL **: 18:44:33.360: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.360: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.457: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.457: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.557: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.557: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.657: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.657: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.757: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.757: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.858: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.858: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed
PulseAudio: Update info

(gBar:16706): Gtk-CRITICAL **: 18:44:33.958: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:33.958: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:34.058: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:34.058: gtk_range_set_value: assertion 'GTK_IS_RANGE (range)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:34.156: gtk_widget_get_style_context: assertion 'GTK_IS_WIDGET (widget)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:34.156: gtk_style_context_remove_class: assertion 'GTK_IS_STYLE_CONTEXT (context)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:34.156: gtk_style_context_add_class: assertion 'GTK_IS_STYLE_CONTEXT (context)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:34.156: gtk_button_set_label: assertion 'GTK_IS_BUTTON (button)' failed

(gBar:16706): Gtk-CRITICAL **: 18:44:34.156: gtk_label_set_text: assertion 'GTK_IS_LABEL (label)' failed

Thread 1 "gBar" received signal SIGSEGV, Segmentation fault.
0x00007ffff7943e96 in gtk_widget_queue_draw (widget=0x5555558597b0) at ../gtk/gtk/gtkwidget.c:5700
5700      g_return_if_fail (GTK_IS_WIDGET (widget));

It also appears to do the exact same thing if the power to the monitor is turned off.

scorpion-26 commented 1 year ago

It also appears to do the exact same thing if the power to the monitor is turned off.

I think you found the culprit, because that explains everything (literally). I think it's because the system is turned on before the monitor is. Hyprland can behave a bit weirdly if a monitor is turned off and then on again (That explains the strange workspace switching) and gBar will crash, because the whole rendering context is invalid (there is no monitor to render to, so gtk freaks out a bit, causing the crash). If I do the same, I can reproduce the crash. Powering the monitor before the system should be a workaround for this bug(I've gotten used to that, which is why I probably didn't have this in mind :) ). I'll try to write a patch in the next few days, so gBar doesn't crash if there is no monitor powered on.

fenneltheloon commented 1 year ago

As you said, that does seem to work. I also just opened a QnA thread in the Hyprland repo because this is not the only app that acts funny due to this! Pretty much any display-dependent app (wallpaper managers, any bar / widget system etc. ) will crash, and the workspace switching thing I mentioned earlier seems to be independent of all that. Hopefully some clarity can be obtained there as it does make everything kind of a pain.

scorpion-26 commented 5 months ago

Fixed, see PR #31