2020-12-05 13:56 阅读 0

WASM multithreading?

Is it possible to run webworkers in egui?


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • weixin_39953673 weixin_39953673 2020-12-05 13:56


    You don't really run anything "in egui" - Egui is a library you call into. The online Egui demo is done with egui_web, which is a pretty simple library that just hooks up to some callbacks for input and paint events using js-sys and wasm-bindgen.

    If you want to spawn a web worker I think you can do so from either JS or in Rust with js-sys / wasm-bindgen. If you want to call Egui code from that worker, that should be no problem.

    I hope that helps!

    点赞 评论 复制链接分享
  • weixin_39804329 weixin_39804329 2020-12-05 13:56

    ... but if i want webworker to render some parts on canvas? ideally i should transfer that canvas to worker.

    点赞 评论 复制链接分享
  • weixin_39953673 weixin_39953673 2020-12-05 13:56

    egui_web paints to a canvas using WebGL. So are you asking if you can call WebGL functions from a web worker? I don't know the answer to that, but a quick googling seems to suggest that it should be no problem. Try it 🤷 :)

    I don't know much web stuff, so I don't think I can be of much more help here (except maybe to guide you are in the egui_web code base). My guess is that you know much more than me :) egui_web would maybe need some refactoring or cleanup to make it easier to run in a web worker, but I have no idea.

    点赞 评论 复制链接分享
  • weixin_39804329 weixin_39804329 2020-12-05 13:56

    my idea is to delegate part of canvas to dedicated webworkers with specific work, but i dont know is it possible or not so far

    点赞 评论 复制链接分享