Hello all, I’ve found that the new GtkJSBuilder that overrides Gtk.Builder in the development version of gjs seems to garbage collect the callbacks before it should do so.
A minimal test case that exemplifies the issue is the following user interface (compiled from blueprint):
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT EDIT!
This file was @generated by blueprint-compiler. Instead, edit the
corresponding .blp file and regenerate this file with blueprint-compiler.
-->
<interface>
<requires lib="gtk" version="4.0"/>
<object class="AdwApplicationWindow" id="root">
<property name="maximized">true</property>
<property name="content">
<object class="GtkButton">
<signal name="activate" handler="activate"/>
</object>
</property>
</object>
</interface>
and a simple implementation of the activate callback that logs a message Activated!.
If the button is activated shortly after construction (within 20 seconds approximately), it will log the desired message; however, it will no longer do so after that amount of time. I’m not really sure if it is related to my previous post regarding garbage collection (Gjs garbage collection) because in that case the critical time was about 10 seconds.
P.S.: Since the overriding GtkJSBuilder is noy yet in stable gjs, I’ve tested it by patching it in my test itself by copying and pasting the relevant code from the repository.