Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Unresponsive panel when Discord is open #456

Closed
elusian opened this issue Sep 17, 2023 · 22 comments · Fixed by #480
Closed

[Bug] Unresponsive panel when Discord is open #456

elusian opened this issue Sep 17, 2023 · 22 comments · Fixed by #480
Assignees
Labels
bug Something isn't working
Milestone

Comments

@elusian
Copy link

elusian commented Sep 17, 2023

Description

Since Budgie 10.8, Discord is having issues with the tray. Periodically, the icon shown in the tray switches to a generic one, and whenever that happens all panels and applets are unresponsive.

Snapshot_2023-09-17_15-58-39

The green icon on the left here is supposed to be Discord.

Whenever it happens, the system log also receives logs such as

Received property WindowId with type i does not match expected type u in the expected interface

and the CPU usage of budgie-panel rises to a full core.

Budgie version

10.8

Operating System

Solus 4 updated to 16/09/2023

Steps to reproduce the issue

1: Have the system tray applet in a panel
2: open Discord (flatpak version in my case)
3: wait for the icon to change (random chance), use another applet (e.g. try to switch window form the icon task list)

Actual result

Bugged Discord icon, all panel interactions while icon is wrong are ignored, high CPU usage from budgie-panel

Expected result

Discord keeps the correct icon, panels stay responsive and has normal CPU usage

Additional information

No response

@JoshStrobl
Copy link
Member

This is an issue with all Electron-based applications and not an actionable item on our party.

@JoshStrobl JoshStrobl closed this as not planned Won't fix, can't repro, duplicate, stale Sep 17, 2023
@elusian
Copy link
Author

elusian commented Sep 17, 2023

I suspected as much for the icon, but I hoped for a solution for the unresponsive panel

@JoshStrobl
Copy link
Member

Will re-open pending additional logs. If you could follow https://docs.buddiesofbudgie.org/developer/workflow/providing-backtraces it would be very helpful.

@JoshStrobl JoshStrobl reopened this Sep 17, 2023
@JoshStrobl JoshStrobl added the needs-more-info Needs More Info label Sep 17, 2023
@elusian
Copy link
Author

elusian commented Sep 17, 2023

I tried following the instructions for a while, but the problem is that it does not segfault, so I don't have a chance to request a backtrace in gdb.
I can try more later, otherwise let me know if you have other ideas

@serebit serebit added the bug Something isn't working label Sep 18, 2023
@elusian
Copy link
Author

elusian commented Sep 19, 2023

Just wanted to say that I did not forget about this, I'm just very busy this week. I will upload some logs as soon as possible.

@elusian
Copy link
Author

elusian commented Sep 28, 2023

So, as mentioned before gdb is not helpful, since nothing is crashing.

What I can provide is a flamegraph with

flame4

and without Discord open

flameGood

(These are interactive SVG, but just opening from GitHub does not seem to make them work. I had to download them and then reopen them in browser)

During the record in the first link, the panel was continuously unresponsive (for >5 min, I had to replace the panel, otherwise I could not close Discord).

I hope this helps, let me know if I can provide other information.

@serebit
Copy link
Member

serebit commented Sep 28, 2023

theme_subdir_load should not be running for that long...

@elusian
Copy link
Author

elusian commented Oct 2, 2023

I see this is still marked as "Needs more info", is it a leftover or do you actually need more info from me?

@serebit
Copy link
Member

serebit commented Oct 2, 2023

Found the function in GTK. It does what I assumed it does, which is traverse the icon theme paths that it's given. There are a few places in that function where it could be halting - several internal loops. Do the following:

  • Install gdb
  • Run gdb budgie-panel in the terminal
  • Enter run --replace
  • Launch Discord

Once the panel freezes, enter Ctrl-C into GDB so it halts the program, then enter backtrace and copy the results here. That should give us some idea where in that function GTK is spinning its wheels.

@elusian
Copy link
Author

elusian commented Oct 2, 2023

Ok, fair, I should have thought about Ctrl+C. I will have the results as soon as possible

@serebit serebit self-assigned this Oct 2, 2023
@elusian
Copy link
Author

elusian commented Oct 2, 2023

Here's the backtrace

#0  0x00007ffff7583f82 in theme_subdir_load
    (icon_theme=icon_theme@entry=0x55555564ae90 [GtkIconTheme], theme=theme@entry=0x55555a3b6690, theme_file=theme_file@entry=0x555559ef1d10, subdir=0x55555a36e480 "84x84/apps")
    at ../gtk/gtkicontheme.c:3370
#1  0x00007ffff75846a1 in insert_theme (icon_theme=icon_theme@entry=0x55555564ae90 [GtkIconTheme], theme_name=<optimized out>) at ../gtk/gtkicontheme.c:1239
#2  0x00007ffff7584726 in insert_theme (icon_theme=icon_theme@entry=0x55555564ae90 [GtkIconTheme], theme_name=<optimized out>) at ../gtk/gtkicontheme.c:1259
#3  0x00007ffff7584726 in insert_theme (icon_theme=icon_theme@entry=0x55555564ae90 [GtkIconTheme], theme_name=<optimized out>) at ../gtk/gtkicontheme.c:1259
#4  0x00007ffff7584c07 in load_themes (icon_theme=0x55555564ae90 [GtkIconTheme]) at ../gtk/gtkicontheme.c:1373
#5  ensure_valid_themes (icon_theme=icon_theme@entry=0x55555564ae90 [GtkIconTheme]) at ../gtk/gtkicontheme.c:1482
#6  0x00007ffff758577a in gtk_icon_theme_has_icon (icon_theme=icon_theme@entry=0x55555564ae90 [GtkIconTheme], icon_name=icon_name@entry=0x55555a37baf0 "status_icon_771") at ../gtk/gtkicontheme.c:2458
#7  0x00007fffc5ba7300 in tray_item_update_icon
    (fallback_icon_name=<optimized out>, icon_pixmaps_length1=<optimized out>, icon_pixmaps=<optimized out>, icon_name=<optimized out>, icon=<optimized out>, self=<optimized out>)
    at src/panel/applets/tray/libtrayapplet.so.p/TrayItem.c:3062
#8  tray_item_update_icon
    (self=0x5555592ecd00 [TrayItem], icon=0x5555592f0490 [GtkImage], icon_name=0x55555a37baf0 "status_icon_771", icon_pixmaps=<optimized out>, icon_pixmaps_length1=<optimized out>, fallback_icon_name=<optimized out>) at src/panel/applets/tray/libtrayapplet.so.p/TrayItem.c:2987
#9  0x00007fffc5ba8429 in tray_item_reset_icon (self=0x5555592ecd00 [TrayItem], status=0x0) at src/panel/applets/tray/libtrayapplet.so.p/TrayItem.c:2918
#13 0x00007ffff7d092dc in <emit signal 0x7fffc5bac854 "new-icon" or new-icon on instance 0x5555592ece90 [SnItemInterfaceProxy]>
    (instance=instance@entry=0x5555592ece90, detailed_signal=detailed_signal@entry=0x7fffc5bac854 "new-icon") at ../gobject/gsignal.c:3664
    #10 0x00007ffff7ceef70 in g_closure_invoke
    (closure=0x555555a356c0, return_value=return_value@entry=0x0, n_param_values=1, param_values=param_values@entry=0x7fffffffd9f0, invocation_hint=invocation_hint@entry=0x7fffffffd970)
    at ../gobject/gclosure.c:832
    #11 0x00007ffff7d02218 in signal_emit_unlocked_R
    (node=node@entry=0x55555864b1a0, detail=detail@entry=0, instance=instance@entry=0x5555592ece90, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7fffffffd9f0)
    at ../gobject/gsignal.c:3812
    #12 0x00007ffff7d08eea in g_signal_emit_valist (instance=instance@entry=0x5555592ece90, signal_id=signal_id@entry=709, detail=<optimized out>, var_args=var_args@entry=0x7fffffffdb88)
    at ../gobject/gsignal.c:3565
#14 0x00007fffc5ba64ca in _dbus_handle_sn_item_interface_new_icon (parameters=0x55555a0a5e10, self=0x5555592ece90) at src/panel/applets/tray/libtrayapplet.so.p/TrayItem.c:1933
#15 sn_item_interface_proxy_g_signal (proxy=0x5555592ece90 [SnItemInterfaceProxy], sender_name=<optimized out>, signal_name=0x7fffdc360070 "NewIcon", parameters=0x55555a0a5e10)
    at src/panel/applets/tray/libtrayapplet.so.p/TrayItem.c:2002
#19 0x00007ffff7d090c0 in <emit signal g-signal on instance 0x5555592ece90 [SnItemInterfaceProxy]> (instance=instance@entry=0x5555592ece90, signal_id=<optimized out>, detail=<optimized out>)
    at ../gobject/gsignal.c:3622
    #16 0x00007ffff7ceef70 in g_closure_invoke
    (closure=closure@entry=0x555555604440, return_value=return_value@entry=0x0, n_param_values=4, param_values=param_values@entry=0x7fffffffdf10, invocation_hint=invocation_hint@entry=0x7fffffffde90)
    at ../gobject/gclosure.c:832
    #17 0x00007ffff7d02347 in signal_emit_unlocked_R
    (node=node@entry=0x5555555d4f90, detail=detail@entry=0, instance=instance@entry=0x5555592ece90, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7fffffffdf10)
    at ../gobject/gsignal.c:3851
    #18 0x00007ffff7d08eea in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7fffffffe0e0) at ../gobject/gsignal.c:3565
#20 0x00007ffff7e56abf in on_signal_received
    (connection=<optimized out>, sender_name=0x7fffdc061f30 ":1.386", object_path=<optimized out>, interface_name=<optimized out>, signal_name=0x7fffdc05f490 "NewIcon", parameters=0x55555a0a5e10, user_data=0x5555592edda0) at ../gio/gdbusproxy.c:890
#21 0x00007ffff7e43f24 in emit_signal_instance_in_idle_cb (data=0x7fffdc343720) at ../gio/gdbusconnection.c:3802
#22 0x00007ffff7bed1c0 in g_main_dispatch (context=0x5555555e5bb0) at ../glib/gmain.c:3460
#23 g_main_context_dispatch (context=context@entry=0x5555555e5bb0) at ../glib/gmain.c:4200
#24 0x00007ffff7bed5b9 in g_main_context_iterate (context=0x5555555e5bb0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4276
#25 0x00007ffff7bed87f in g_main_loop_run (loop=loop@entry=0x55555572c580) at ../glib/gmain.c:4479
#26 0x00007ffff75b37c7 in gtk_main () at ../gtk/gtkmain.c:1329
#27 0x0000555555566202 in _vala_main (args_length1=<optimized out>, args=<optimized out>) at src/panel/budgie-panel.p/main.c:133
#28 main (argc=<optimized out>, argv=<optimized out>) at src/panel/budgie-panel.p/main.c:144

I tried a few times, and I noticed that the number of calls to insert_theme at ../gtk/gtkicontheme.c:1259 varies between 3 and 4

@serebit serebit removed the needs-more-info Needs More Info label Oct 3, 2023
@serebit
Copy link
Member

serebit commented Oct 3, 2023

Is it consistently locking at ../gtk/gtkicontheme.c:3370?

@elusian
Copy link
Author

elusian commented Oct 3, 2023

In the few tries I did, yes

@serebit
Copy link
Member

serebit commented Oct 3, 2023

That's... odd. It seems like GTK is getting stuck in this loop:

for (d = icon_theme->priv->dir_mtimes; d; d = d->next)
    {
      dir_mtime = (IconThemeDirMtime *)d->data;

      if (!dir_mtime->exists) // locking here
        continue; /* directory doesn't exist */
      
      // ...
    }

If it truly is stuck in an infinite loop, then the only reason this could happen is that the linked list being iterated over is circular, but that almost seems too simple...

@elusian
Copy link
Author

elusian commented Oct 3, 2023

It cannot be infinite, it does exit, it's just arbitrarily slow to do so.
It can get stuck for a few instants, for a few minutes or even for more than I cared to wait (>20min, then I replaced the panel).

@serebit
Copy link
Member

serebit commented Oct 3, 2023

Hm... Let's see if this helps. Clone this repo, and build it according to the Solus instructions on the docs site.

Then, change this line:

var icon_theme = Gtk.IconTheme.get_default();

To var icon_theme = new Gtk.IconTheme();.

Then install and log out and back in.

@elusian
Copy link
Author

elusian commented Oct 3, 2023

Ok, I can try, but likely on Thursday, I cannot risk breaking stuff before tomorrow.

@elusian
Copy link
Author

elusian commented Oct 7, 2023

So, on one hand the panel looks responsive, on the other hand now the icon for Discord (and Skype too, so I suspect it may be all Electron applications) is always the generic one.

This also means that unless I'm constantly interacting with the panel I may not notice the issue if it disappears fast enough...

@serebit serebit added this to the 10.8.2 milestone Oct 8, 2023
@serebit
Copy link
Member

serebit commented Oct 8, 2023

Try the branch 456-bug-unresponsive-panel-when-discord-is-open. I believe I've fixed the oversight in the algorithm that caused this, but I haven't been able to reproduce the problem myself, so I'll need you to test.

@elusian
Copy link
Author

elusian commented Oct 10, 2023

I tried a few times these evenings, it seems to work. I did not notice issues with the panel, and even the icon stays correct.

@serebit
Copy link
Member

serebit commented Oct 10, 2023

Excellent. I'll open a MR with the change.

@elusian
Copy link
Author

elusian commented Oct 10, 2023

Thank you!

@serebit serebit linked a pull request Oct 15, 2023 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants