yue/yode

Yue window closes after some seconds

Closed this issue · 3 comments

I tried to use yue with yode to build an app but all windows close after some seconds.
The same happens with the examples but doesn't happen if I use node, only happens with yode. But with node i can't use setInterval or setTimeout.
There is no output. I tried to wrap an example code inside a try-catch and log any error to a file but there is no error.

I'm under Windows 10 64 bits using nodejs 12.16.1.

I can confirm I see this behavior under Linux using the most recent Yode 0.8.0. However, yode still is running, just the windows all vanish. Adding a "setInterval" to console log, will continue to console log after all the windows just vanish...

One minor data point -- the amount of memory drops dramatically, like the gui part of the system was quit out of, and everything de-allocated.

When using Node.js to run code, the whole program will block at the gui.MessageLoop.run() call, and the local variables defined in the main script will not be garbage collected.

When using Yode to run code, the execution of the main script will finish immediately, and the local variables will be garbage collected as usual.

So you might notice some windows disappearing after running for some time when using Yode, this is because the JavaScript objects of the windows got garbage collected.

const win = gui.Window.create({})
// win will be garbage collected after some time.

And this problem can be solved by keeping a global reference of the window.

global.win = gui.Window.create({})
global.win = win
// or
global.windowManager = new Set()
windowManager.add(win)

You are correct in my case. Globalizing the window reference allowed it to stay around. Thanks. I'll play some more with this.