ECMAScript icon indicating copy to clipboard operation
ECMAScript copied to clipboard

Two issues with Worker demo

Open vonagam opened this issue 4 years ago • 7 comments

  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?

vonagam avatar Mar 11 '20 07:03 vonagam

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

Geequlim avatar Apr 10 '20 14:04 Geequlim

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?

vonagam avatar Apr 10 '20 15:04 vonagam

@vonagam Does the latest version fixed this ?

Geequlim avatar Jun 29 '20 07:06 Geequlim

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

git clone --depth=1 --branch=3.2 [email protected]:godotengine/godot.git git clone [email protected]:Geequlim/ECMAScript.git (in godot/modules) python3 $(which scons) platform=osx --jobs=$(sysctl -n hw.logicalcpu) (in godot) git clone [email protected]: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.

vonagam avatar Jun 29 '20 08:06 vonagam

@vonagam Does alpha12 fixed this ?

Geequlim avatar Aug 02 '20 05:08 Geequlim

No.

vonagam avatar Aug 02 '20 10:08 vonagam

@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.

Geequlim avatar Aug 16 '20 18:08 Geequlim