Better handling of callbacks during GC
This fixes two issues that together have resulted in a couple of freezes reported against gnome-shell without proper stack traces while the logs are getting spammed with error messages. See gnome-shell#1868 (closed) for example. While this does not fix whatever the underlying issue of that was, it should prevent it from turning into a freeze.
I have never been able to reproduce any of these bugs myself and due to the lack of proper logs I couldn't find a reproducer that way either. So in an attempt to reproduce what I think is happening in these bugs I simply changed gjs->sweeping()
to TRUE
in GjsCallbackTrampoline::callback_closure
and then ran this script:
const GLib = imports.gi.GLib;
let mainLoop = new GLib.MainLoop(null, true)
GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
log('test');
return false;
});
mainLoop.run()
To test the logging issue it is important that everything gets logged to the journal so for this one additionally has to use systemd-run --user jhbuild run gjs /path/to/script.js
. Then check the log using journalctl -f
.