Applet throwing Gjs-CRITICAL errors in xsession-errors and I don't know what causes them

About programming and getting involved with Linux Mint development
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
JoeJoeTV
Level 2
Level 2
Posts: 57
Joined: Tue Mar 24, 2020 6:08 am
Location: Germany
Contact:

Applet throwing Gjs-CRITICAL errors in xsession-errors and I don't know what causes them

Post by JoeJoeTV »

Hi everyone,

I am currently working on writing an applet for cinnamon and I am having some issues whyile developing, where I don't know what cuases them or how I could find out.

Cinnamon throws this error(sometimes multiple instances of it) in xsession-errors and by the stack trace I found the offending function in popupMenu.js. But that is a js file from Cinnamon, so I don't know what code from my applet caused this or which St Widget in my applet caused this:

Code: Select all

(cinnamon:2646): Gjs-CRITICAL **: 19:49:34.075: Object St.BoxLayout (0x5580197fcfc0), has been already disposed — impossible to access it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs.
== Stack trace for context 0x558015dc8380 ==
#0   7ffe21ea43e0 b   /usr/share/cinnamon/js/ui/popupMenu.js:2096 (167c9073a560 @ 22)
#1   7ffe21ea44a0 b   /usr/share/cinnamon/js/ui/popupMenu.js:2122 (167c9073a420 @ 23)
#2   7ffe21ea4550 b   /usr/share/cinnamon/js/ui/popupMenu.js:2164 (167c9073a330 @ 37)
#3   7ffe21ea4600 b   /usr/share/cinnamon/js/ui/popupMenu.js:2988 (167c90739600 @ 22)
#4   558019f4e648 i   /usr/share/cinnamon/js/misc/fileUtils.js line 211 > Function:513 (996272ea330 @ 44)
#5   7ffe21ea5320 b   /usr/share/cinnamon/js/misc/fileUtils.js line 211 > Function:951 (996272b2e70 @ 427)
#6   558019f4e4d0 i   /usr/share/cinnamon/js/misc/fileUtils.js line 211 > Function:1080 (996272b2ce0 @ 57)
#7   7ffe21ea5fd0 b   self-hosted:850 (256a1d2af9c0 @ 423)
#8   7ffe21ea60c0 b   resource:///org/gnome/gjs/modules/core/_signals.js:114 (256a1d2d6ab0 @ 439)
#9   558019f4e418 i   /usr/share/cinnamon/js/misc/fileUtils.js line 211 > Function:340 (996272ea7e0 @ 250)
#10   7ffe21ea6d80 b   self-hosted:850 (256a1d2af9c0 @ 492)
#11   7ffe21ea6e80 b   resource:///org/gnome/gjs/modules/core/_signals.js:114 (256a1d2d6ab0 @ 439)
#12   7ffe21ea6f60 b   resource:///org/gnome/gjs/modules/core/overrides/Gio.js:152 (256a1d2d64c0 @ 39)

I am also getting the following error about a non existing signal, which shouldn't happen, since if the signal would not be created, it should throw an error, but it doesn't, so the signal has to exist:

Code: Select all

(cinnamon:2646): Gjs-CRITICAL **: 20:06:08.318: JS ERROR: Error: No signal connection 1 found
_disconnect@resource:///org/gnome/gjs/modules/core/_signals.js:58:11
destroy@/home/joejoetv/.local/share/cinnamon/applets/kdecapplet@joejoetv/js/modules.js:642:36
removeModule@/home/joejoetv/.local/share/cinnamon/applets/kdecapplet@joejoetv/applet.js:447:36
removeAllModules@/home/joejoetv/.local/share/cinnamon/applets/kdecapplet@joejoetv/applet.js:458:18
onModuleSettingsChanged@/home/joejoetv/.local/share/cinnamon/applets/kdecapplet@joejoetv/applet.js:1117:20
bind/<@resource:///org/gnome/gjs/modules/script/lang.js:71:25
_checkSettings@/usr/share/cinnamon/js/ui/settings.js:611:45
If anyone can give me some tipps on how to fix this or how to find out, what is causing this, I would really appreciate this, since I'm pulling my hair out on why it doesn't work.

Previously cinnamon sometimes "nearly crashed" or something, where the screen would go black and I'd have to hover over gui elements to make them visible again, after reloading the applet some times. I don't have the error messages from when it happened, since I've restarted my PC since then, but I think it could have something to do with destroying actors, but I'm not sure.

Another question would be: What actors, popupMenuItems, popupMenus, etc. do I have to destroy with the method and which don't I?

Cinnamon 5.6.7

Thasnks for any help in advance
Last edited by LockBot on Tue Jul 18, 2023 10:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Image
mtwebster
Level 1
Level 1
Posts: 43
Joined: Sun Jun 17, 2012 1:29 pm

Re: Applet throwing Gjs-CRITICAL errors in xsession-errors and I don't know what causes them

Post by mtwebster »

Unfortunately your code doesn't appear to match what's in the cinnamon-spices-applets repos so I can be specific, but...

Code: Select all

Error: No signal connection 1 found
This means you probably connected to some object:

Code: Select all

this.signal_id = this.object.connect("something-changed", () => this.handle_id())
When you're done with that object (especially if it's going to continue to be alive), you need to disconnect later:

Code: Select all

if (this.signal_id > 0) {
    this.object.disconnect(this.signal_id)
    this.signal_id = 0
}
When you disconnect you *always* want to zero-out the signal id variable. Sometimes cleanup functions can run more than once, and you want to guard against trying to disconnect a second time by checking if this.signal_id is 0 or not.

Which sort of goes back to your first warning - you probably tried to access an actor (an St.BoxLayout) after destroy was called on it. When working with actors and containers, if you destroy a container actor (like a BoxLayout or Cinnamon.GenericContainer), it will automatically trigger the actors it contains to be destroyed also (unless you've got a variable 'reference' specifically for one of the children). So a common mistake is destroying the container, then later trying to destroy one of its children.

Another potential cause is similar to the signal one - if you call this.specialActor.destroy() in some sort of cleanup method, it's often a good idea to then set this.specialActor to null, and check for that when you destroy it.

Code: Select all

if (this.specialActor != null) {
    this.specialActor.destroy();
    this.specialActor = null;
}
Getting into the habit of doing this kind of stuff can help prevent those annoying warnings. This same pattern holds for timers (id = Mainloop.idle_add/timeout_add).
JoeJoeTV
Level 2
Level 2
Posts: 57
Joined: Tue Mar 24, 2020 6:08 am
Location: Germany
Contact:

Re: Applet throwing Gjs-CRITICAL errors in xsession-errors and I don't know what causes them

Post by JoeJoeTV »

Hi,

Thanks for the reply, I actually should have fixed it now, since I haven't seen these errors again. I still don't really know why the signals got removed twice and now not anymore, but I suspect for the second error, that it had something to do with the menu.removeAll() method, that also destroyed the actors of the menu items, while they were still referenced by objects in my code, like you said. I now destroy the menu items including actors first, which automatically removes them from the menus, as they connect the "destroy" signal, which fixed it as far as I can see.

The tip with zeroing out signals, etc. after disconnecting them is really useful, thanks!

Also, the code doesn't match the code in the cinnamon-spices-applets repo, as I was completely rewriting the applet and hadn't pushed the code to the main repo. I have finished the rewrite and made a pull request(https://github.com/linuxmint/cinnamon-s ... /pull/4656). You can see the new code there, or in the branch on my fork(https://github.com/JoeJoeTV/cinnamon-sp ... et-rewrite).

The only other Gjs-CRITICAL error I also encountered while developing the rewrite was this:

Code: Select all


(cinnamon:2578): Gjs-CRITICAL **: 21:15:04.645: Attempting to run a JS callback during garbage collection. This is most likely caused by destroying a Clutter actor or GTK widget with ::destroy signal connected, or using the destroy(), dispose(), or remove() vfuncs. Because it would crash the application, it has been blocked.

(cinnamon:2578): Gjs-CRITICAL **: 21:15:04.645: The offending callback was paint(), a vfunc.
== Stack trace for context 0x56050d3ad380 ==
From what I tested, this error gets spammed in .xsession-errors, when outputting many things to the log and the looking glass application(Melange) is open, so I think these callback errors don't stem from my code. I logged a lot of stuff for debugging and when this error occurs, different parts of the cinnamon UI go black for a short while. If I debug only a few things at the same time, it doesn't happen. Maybe I should make a bug report about this.

Anyway, thanks for the help!

I'll mark this as solved, so other people having issues with this may find it and get some use out of it.
Image
Locked

Return to “Programming & Development”