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

Unable to rebind ECMAScript instance from godot object in threaded worker.js #108

Open
dangerousbeans opened this issue Aug 15, 2021 · 3 comments
Labels
investigation Needs some investigation

Comments

@dangerousbeans
Copy link

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:

// 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) })
  }
}
@dangerousbeans
Copy link
Author

Here's an example of the situation applied to the demos project; dangerousbeans/ECMAScriptDemos@6959fbf

@Geequlim
Copy link
Collaborator

Geequlim commented Aug 15, 2021 via email

@dangerousbeans
Copy link
Author

@Geequlim I can get the godot object fine, but the one returned from godot.adopt_value no longer has any ECMAscript bindings or js context

@nmerget nmerget added the investigation Needs some investigation label Sep 19, 2024
@nmerget nmerget added this to Kanban Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation Needs some investigation
Projects
Status: Backlog
Development

No branches or pull requests

3 participants