tips4design Posted August 22, 2015 Share Posted August 22, 2015 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 More sharing options...
rich Posted August 22, 2015 Share Posted August 22, 2015 Web Workers cannot access the DOM, so you can't use one to run rendering. Link to comment Share on other sites More sharing options...
tips4design Posted August 22, 2015 Author Share Posted August 22, 2015 Then what about the other way around? Run physics in a web worker and the render loop in the main thread? Or maybe be able to implement complex filters in a web worker and only pass back and forward the image data. Link to comment Share on other sites More sharing options...
rich Posted August 22, 2015 Share Posted August 22, 2015 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 More sharing options...
tips4design Posted August 22, 2015 Author Share Posted August 22, 2015 I will think some more if there is any way to improve the current Phaser performance by somehow integrating multi-threading.Thanks for your answers!PS: Can you take a look at this question?http://www.html5gamedevs.com/topic/16641-restart-tween/ Link to comment Share on other sites More sharing options...
rich Posted August 22, 2015 Share Posted August 22, 2015 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. tips4design 1 Link to comment Share on other sites More sharing options...
Recommended Posts