godotjs / godotjs/javascript

Two issues with Worker demo

Open
#12 7 comments 0 reactions 0 assignees View on GitHub
bug investigation
Dominant language
C++
Stars
1.1k
Forks
80
PR merge metrics
No merged PRs in 30d

Description

1) `fib.js` [default export](https://github.com/Geequlim/ECMAScriptDemos/blob/ca86889abfcd5518ed49b8f3eacf9fc4cefd91d4/worker/fib.js#L1) 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`](https://github.com/Geequlim/ECMAScriptDemos/blob/ca86889abfcd5518ed49b8f3eacf9fc4cefd91d4/worker/Control.js#L3) 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?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing both reports in the worker demo, then read worker/fib.js and worker/Control.js, especially the default export and the N value used by the worker calculation. Done means the repeated JavaScript error and the worker-triggered scene exit are explained and corrected, with the Calculate in Main Thread and Calculate in Worker paths still behaving as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.