Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do you know what the problem could be loading a multithreading library called effil? #27

Open
kunrii opened this issue Sep 6, 2022 · 3 comments

Comments

@kunrii
Copy link

kunrii commented Sep 6, 2022

I have a simple script in lua:

local Nodeee = {
extends = "Node",
}

effil = require("effil")

function foo(name)
print(name .. " another thread!")
end

thr = effil.thread(foo)("Thr")

thr:wait()

return Nodeee

Which produces the following error:

E 0:00:00.435 Error loading script metadata: Thr
stack traceback:
[string "res://Nodeee.lua"]:14: in main chunk
in script_load @ "res://Nodeee.lua"
<C++ Source> ?:-1

The effil.dll file is located inside the res:// folder. Do you mind taking a guess at what the problem could be?

Edit: wrong error

@gilzoide
Copy link
Owner

gilzoide commented Sep 7, 2022

Hmm, I've never used effil, but we can look at the error message to get some info.

  • Error loading script metadata: Thr the error is happening when running your script and Thr is the error message, which is weird, since it's the string you're passing to the created thread. If you change the text, does the error message change to the same thing?
  • [string "res://Nodeee.lua"]:14: in main chunk: the error occurs on the "main chunk" of the script, so it's outside of any functions when the error occurs. Error is in line 14, which exactly is line 14 there?

So, somehow it seems the string Thr is involved in the error, so the call to the thread must be happening. Maybe it is erroring right there, but maybe it's the wait, whichever line is 14 might be the culprit.

The effil.dll file is located inside the res:// folder.

If effil = require("effil") didn't error, your setup should be fine and the problem is probably somewhere else.

@gilzoide
Copy link
Owner

gilzoide commented Sep 7, 2022

As a side note, be careful when using effil with Godot related stuff.

Since effil creates a brand new Lua state per thread, these new states will probably not have defined global stuff like the GD table and types like Vector2, Array, etc. This could be dealt with by making a way to require Godot definitions, the functionality used to open the plugin's lua_State can be reused to open new states as well, but it is not possible right now.

Also, effil says here that:

Userdata and Lua threads (coroutines) are not supported.

All Godot objects are LuaJIT's C data, so I don't know how effil deals with them. Maybe it will be able to pass such data to threads, maybe it will not.

@kunrii
Copy link
Author

kunrii commented Sep 7, 2022

I think it's not effil, since I can run the same script with my version of luajit just fine. I tried both Godot 64 bit windows and 32 bit windows with both versions of the effil library and it fails to run with the same error, error "loading script metadata" on the call to the thread method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants