godotjs / javascript

Javascript binding for godotengine
https://godotjs.github.io/
MIT License
972 stars 84 forks source link

Two issues with Worker demo #12

Open vonagam opened 4 years ago

vonagam commented 4 years ago

1) fib.js default export is fib function and not a godot class, so every time the file is loaded i get an error message "modules/ECMAScript/ecmascript.cpp:92 - JavaScript Error". Is this how it is supposed to be right now (work in progress)? So for now to avoid this message on every save one should export some empty class inheriting godot.Object?

2) This one is less straightforward. When i press "Calculate in Worker" the playing scene just exits without any error ("Calculate in Main Thread" works fine). I tested different things and it seems like there is a stack overflow in worker thread on my machine when N is higher than 26. Even when fib is a simple function as (n) => n < 2 ? n : fib( n - 1 ). With 26 or lower worker is fine. Any clues what this might be caused by? What is the maximum N on your machine if you use the provided simple function?

Geequlim commented 4 years ago

There is a bug with stack overflow in QuickJS. You can disable stack checking for this.

vonagam commented 4 years ago

Haven't this ec69d883b014738bbc7e0a9acbd10349992e88b9 recent commit disabled stack checks for apple devices already (i am on mac)? (And strange thing for me is that this error appears only in worker thread, script has no problem running on main one.)

Are there any workarounds for errors about js files that do not export a godot class (like libraries)?

Maybe it is possible in the future to add an import setting for js files that says whenever or not they are godot scripts?

Geequlim commented 4 years ago

@vonagam Does the latest version fixed this ?

vonagam commented 4 years ago

On my machine - no. Steps i used to reproduce:

git clone --depth=1 --branch=3.2 git@github.com:godotengine/godot.git git clone git@github.com:Geequlim/ECMAScript.git (in godot/modules) python3 $(which scons) platform=osx --jobs=$(sysctl -n hw.logicalcpu) (in godot) git clone git@github.com:Geequlim/ECMAScriptDemos.git (in some temp folder) ./bin/godot.osx.tools.64 --verbose --path some/temp/ECMAScriptDemos/worker res://Control.tscn (in godot) I have macOS Mojave 10.14.6.

Last outputted line before a crash is Bus error: 10 when i click on "Calculate in Worker".

Notes:

I have checked if this issue is reproducible not so long ago and while there was no hard crash, when clicked to calculate in a worker nothing would happen, seemed like a silent crash, now it is back to hard one.

This line needed to be commented. I assume it got into version control by mistake.

JavaScript Error about fib.js not exporting a godot class is gone.

Geequlim commented 4 years ago

@vonagam Does alpha12 fixed this ?

vonagam commented 4 years ago

No.

Geequlim commented 4 years ago

@vonagam I can reproduce the issue when compiled in debug mode with llvm. In release mode with llvm or compiled with gcc in both debug and release mode won't happen.