wesnoth / jessene

A lua module for the Godot engine written in GDNative.
MIT License
14 stars 4 forks source link

Loading Module Causes Game to Freeze #5

Closed ghost closed 5 years ago

ghost commented 5 years ago

I've tried loading the module like the ReadMe says and even tried it this way too.

    var lua : Node
    if not get_tree().get_root().has_node("LuaNode"):
        lua = Node.new()
        logger.error("About to Load Lua Module!!!")
        lua.set_script(load("res://Modules/Lua.gdns")) # Also with preload
        lua.set_name("LuaNode")
        get_tree().get_root().add_child(lua)
    else:
        lua = get_tree().get_root().get_node("LuaNode")

    logger.error("About to Load Lua Script!!!")
    lua.load("res://Scripts/Lua/test_lua.lua")

    return lua.execute("get_class")

The game freezes on load("res://Modules/Lua.gdns"). Apple's Activity Monitor says that the library is stuck on gdnative_init(gdnative_init_options).

This is the detailed file of what Activity Monitor returned. Sample of Godot.txt

I've compiled using lua-5.3.5.tar and my own custom version of Godot 3.2-dev. I am using commit cd6a55bdff5496f4244b28e8f44ccf70a641d10e.

All of my actions occurred on a Mac OSX Mojave 10.14.6 (18G95).

The only weird thing I found is when I open up libLuaScript.dylib in a hex editor, it has references to my compile environment path, so that may have something to do with the freeze.

These are the compiled libraries (minus libgodot which is large and I have no idea what it does or if I need it. It is referenced in libLuaScript.dylib though). Compiled_Libraries.zip

ghost commented 5 years ago

Apparently the freeze is so powerful, it sometimes does it when the project is loaded.

I have to rename Lua.gdns to Lua.gdns.disabled so the editor doesn't freeze.

zozer commented 5 years ago

I have tested and successfully run the module on the regular godot alpha 3.2 alpha 2. However I only have a windows machine. I will comment further when I can do testing on a mac machine. One thing that I will ask you to check is to make sure that the lua dynamic library (liblua.a) is in the same place as libLuaScript.dylib (this particular step often trips me)

ghost commented 5 years ago

Thanks! I may have generated bindings for x86_64 while having the library itself 64 bit.

I will rebuild everything from scratch tomorrow and make sure all the flags are set properly.

ghost commented 5 years ago

Nevermind, I decided to create a sample module to test Godot with and I get the same issues.

So, something is seriously wrong with my copy of Godot. I'll have to see if I can't figure out why Godot freezes on me when loading a GDNative module.

ghost commented 5 years ago

I merged the latest commit of Godot with my copy of Godot and modules load without freezing now.

Now all I need to do is figure out why none of the Lua module's methods seem to be registered with Godot. The module loads properly, it's just Godot doesn't know about its methods such as load or execute.

This is the error I got Invalid call. Nonexistent function 'load' in base 'Node'..

Edit: The test module I made works perfectly fine now, so I think the method is just not registering. I recompiled everything from scratch and explicitly set all the flags for compiling this time.