Almost every run creates a new simulator instance

43 views
Skip to first unread message

Angelo Maci

unread,
Jun 25, 2020, 4:43:09 AM6/25/20
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: IDEA
Desktop OS Ubuntu 20.04
Simulator
Device: iPadMini, etc

Almost every run creates a new simulator instance. I have to close the previous one so to clear the windows on my system.
Notice that usually it's not blocking but I experienced an error with BrowserComponent that seems to lock some folder onto my system.
[JavaFX Application Thread] 0:0:2,889 - WebError: WebErrorEvent [source = javafx.scene.web.WebEngine@478a1ef9, eventType = USER_DATA_DIRECTORY_ALREADY_IN_USE, message = "User data directory [/home/pc/.cn1/.fxuserdata] is already in use", exception = javafx.scene.web.DirectoryLock$DirectoryAlreadyInUseException: /home/pc/.cn1/.fxuserdata]

Shai Almog

unread,
Jun 25, 2020, 10:42:32 PM6/25/20
to CodenameOne Discussions
This is intentional. Simulator loads instantly so you just close/open it unlike Android which takes forever.
You can also debug things side by side e.g. make a change run the simulator again and hold the simulators one next to another to compare behavior. You can also debug networking apps more conveniently this way.

This exception is related to JavaFX which is a bag of troubles and pain. We've started on the long process to dump that disaster: https://www.codenameone.com/blog/moving-away-from-fx.html

Angelo Maci

unread,
Jun 26, 2020, 4:12:13 AM6/26/20
to CodenameOne Discussions
Hello, I hope that in the future that can be made optional because those needs I am not encountering them as for now and just it keeps filling my system with instances.
Thanks, regards

Shai Almog

unread,
Jun 27, 2020, 1:14:47 AM6/27/20
to CodenameOne Discussions
Re-running within the same simulator skin won't provide any performance benefit as the simulator loads instantly. It also can't be done as those are separate processes (our simulator is self contained). It isn't hard to press the X to close the button on an existing simulator instance or the stop button in intellij.

Adding something like this would mean every simulator instance will have a lock file to detect a running simulator and would need to monitor it for a kill instruction by a new simulator instance... That's a lot of overhead for something that doesn't seem to provide too much benefit. Am I missing something?

Angelo Maci

unread,
Jun 28, 2020, 5:46:31 AM6/28/20
to CodenameOne Discussions
As far I understand, the simulator is not just as the Android emulator, so you do not deploy something into it, because it is the application itself, even in the apparent form of a device running another application.
Said that, it is a minor issue for sure, I have not any problem closing the instances manually.
In the long run you have to take into account that developers will end up having a lot of instances open on the system for sure, because of the normal tendency to forget and being busy and distracted. Very soon closing the instances is felt as a chore, not even mentioning when the instances have some conflicts, as said in my original post. Furthermore I use very often (even several times in a minute) the "hot corner" function that shows me all windows, and it is easily crammed by the simulators.
I think that the "Stop" function is triggerable from the plugin, calling it in the run/debug initial operations. It would depend on the "only one instance" option in the settings. It closes the opened simulator, I tried. "Stop All" closes all instances. With appropriate combination of settings a developer can decide to mantain some instances open, if needed, while the most recent is closed and re-run as the "active" one.
Regards

Shai Almog

unread,
Jun 28, 2020, 11:09:24 PM6/28/20
to CodenameOne Discussions
The stop feature in the IDE is a feature of the IDE not the plugin so it's outside of our control.
I think you might be missing a much cooler feature. If you're running in debug mode you can just make changes to your code and select "Apply Code Changes" or "Reload Changed Classes" (depends on IDE).
As long as you didn't make significant changes they apply instantly. The same is true for CSS/resources etc. which automatically update the current simulator.

I often keep an instance running and apply code changes into it during the debug cycle. That's even faster than stop/run again.
Reply all
Reply to author
Forward
0 new messages