Unable to rebind ECMAScript instance from godot object in threaded worker.js
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 80
- PR merge metrics
- No merged PRs in 30d
Description
My main thread is sending out a ECMAscript class as a message to a worker thread using `godot.abandon_value` & `godot.adopt_value`, but I only get the godot object and cannot call any of the js methods on the class:
```javascript
// parcel.tsx
export default class Parcel extends godot.Spatial {
test_function(){
console.log("stuff I wana run here"))
}
}
// worker.js
onmessage = function(e) {
let parcel = godot.adopt_value(e.parcel)
console.log(parcel) // [Spatial:2362]
console.log(parcel.test_function()) // undefined
console.log(parcel.call("test_function")) // error
}
// grid.tsx
export default class Grid extends godot.Spatial {
featureLoadThread
_ready(){
let p = new Parcel()
this.featureLoadThread = new Worker('res://src/worker.js')
this.featureLoadThread.onmessage = this._onmessage.bind(this);
this.featureLoadThread.postMessage({ type:"featureLoad", parcel: godot.abandon_value(p) })
}
}
```
Contributor guide
Research direction
Start with parcel.tsx, grid.tsx, and worker.js, focusing on godot.abandon_value, godot.adopt_value, and the worker's onmessage handler. Reproduce the [Spatial] result and determine the expected behavior for test_function and call; done should be a confirmed fix or a clearly documented limitation, though the issue does not specify which.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100