migeran / libgodot_project

58 stars 7 forks source link

Unable to re-instantiate a project #7

Open QuentinPerez opened 3 months ago

QuentinPerez commented 3 months ago

Hi there 👋

First of all, thank you for your work. I have been waiting for this feature for a long time! I am trying to integrate libgodot into an iOS project where I launch and stop several games, but when I instantiate, then deinstantiate, and then instantiate again, the app crashes. Do you have any idea why this happens? Is it supported?

thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x131b06788)
    frame #0: 0x00000001035eb0f4 GameStore`ObjectDB::add_instance(Object*) + 88
    frame #1: 0x00000001035ea70c GameStore`Object::Object() + 144
    frame #2: 0x000000010316ec30 GameStore`Time::Time() + 20
    frame #3: 0x000000010312049c GameStore`register_core_types() + 200
    frame #4: 0x0000000100f86104 GameStore`Main::setup(char const*, int, char**, bool) + 568
    frame #5: 0x0000000100f83c60 GameStore`libgodot_create_godot_instance + 88
kisg commented 3 months ago

This is currently a known limitation of Godot: it cannot be reinitialized after the first initialization / destroy sequence. I will add this to the description of the PR and the Doxygen docs to make this clear. An option to work around this is to not kill the whole Godot instance, but to load a new PCK, and initialize a new SceneTree with the contents of that PCK.

QuentinPerez commented 3 months ago

We succeeded in making it work by patching Godot and Godot-cpp. Unfortunately, it's hard to upstream.