Reputation: 2103
So I have been working on a game in HTML5 canvas and noticed that the games lags and performs much slower when hardware acceleration is turned on in Google Chrome then when it is turned off. You can try for yourself here
From doing some profiling I see that the problem lies in drawImage
.
More specifically drawing one canvas onto another. I do a lot of this.
Hardware Acceleration on.
Hardware Acceleration off.
Is there something fundamental I am missing with one canvas to another? Why would the difference be that profound?
Upvotes: 1
Views: 1922
Reputation: 10745
If I remember correctly, in-DOM canvases are loaded into GPU memory in Chrome, and off-DOM canvases may not be. So each drawImage from an off-screen canvas to an on-screen canvas results in loading the content of the canvas onto the GPU as a texture, followed by a copy of that memory on-GPU onto the on-screen canvas. The cost of sending a new texture through to the GPU can be quite high. Loading textures is high-throughput, but also high-latency, on most GPUs.
Someone from the Chrome team will have to chime in with a definitive answer, but that fits my experience with canvases in Chrome.
Upvotes: 1