Jump to content

Phaser multithread?


tips4design
 Share

Recommended Posts

Is there any way to run multithreaded Phaser while using CANVAS renderer? I was thinking that running the render and update loop on different threads won't be that hard, but I do not know if it will improve or decrease performance.

What do you think about this idea of using a different thread (web worker) for the render loop in CANVAS mode?

Link to comment
Share on other sites

Workers run in their own context with no access to the main context or window. The only way a Worker can communicate with the main context is via postMessage and the resulting onmessage event. I've never tested it, but I suspect the chances of that being a fast enough system to handle the transfer of any significant volume of texture data is highly unlikely.

 

Physics would be a better use for it, but as it runs out of thread (as you'd expect) the main thread would still have to wait for it to complete anyway before it could carry on, during which time it would be idle anyway. What Workers are better suited for is breaking up intensive tasks - for example AI or path finding, where lots of calculations are required and so you benefit from running multiple workers sharing the load. A physics system, if written in such a manner, could generate Workers itself to help split up the tasks it has to perform. I've yet to see one though. I'm guessing the lack of backward compatibility doesn't help here, as you'd need to carefully engineer your physics system to run both with and without Workers. Definitely possible, but quite a task.

Link to comment
Share on other sites

Phaser performance will always be inherently tied to browser performance. Gains made there will be passed on, and there are some significant gains being made in VM tech right now, which are probably more valuable than rendering improvements. It's a pretty exciting time to be honest. You should follow the Google VM / internals blogs for example to see what they're up to.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...