Offending GtkTickCallback
System information
GJS 1.68.1.
Bug information
"offending callback" critical errors are particularly annoying with GTK tick callbacks.
Steps to reproduce
Here is a basic example where the tick callback do nothing special. The error will occur after seven seconds.
imports.gi.versions['Gtk'] = '4.0';
const { Gdk, GLib, GObject, Gtk } = imports.gi;
var Container = GObject.registerClass({
}, class extends Gtk.Widget {
_init(params) {
super._init(params);
for (let i = 0; i < 500; i++)
new Gtk.Label({ label: "label" }).set_parent(this);
this.add_tick_callback(this._onTick.bind(this));
}
_logTime(usec) {
let time = Math.round(usec / GLib.USEC_PER_SEC);
if (!this._startTime)
this._startTime = time;
if (time != this._lastTime) {
this._lastTime = time;
log(time - this._startTime);
}
}
_onTick(widget_, frameClock) {
this._logTime(frameClock.get_frame_time());
this.queue_allocate();
return GLib.SOURCE_CONTINUE;
}
vfunc_size_allocate(allocation) {
[...this].forEach(child => {
let [{ width, height }] = child.get_preferred_size();
child.size_allocate(new Gdk.Rectangle({ x: 10, y: 10, width, height }), -1);
});
}
vfunc_unrealize() {
super.vfunc_unrealize();
[...this].forEach(child => child.unparent());
}
});
let application = new Gtk.Application();
application.connect('activate', () => {
new Gtk.Window({
application,
child: new Container(),
visible: true,
});
});
application.run([]);