ShimShamSam Posted February 18, 2016 Share Posted February 18, 2016 I'm seeing a massive performance hit from BitmapData.clear(). I've also noticed it eats up memory. I looked at the source code and the bottleneck appears to be from setting the dirty flag to true. If I use BitmapData.context.clearRect() manually, everything works fine. What is the dirty flag doing? Why is it necessary to set it? Perhaps an argument could be added to skip setting it? Link to comment Share on other sites More sharing options...
Zeterain Posted February 18, 2016 Share Posted February 18, 2016 Which version of Phaser are you using? In 2.4.4, I see that clear calls BitmapData.update, which is documented as being very expensive. However, that was removed in 2.4.5. If you aren't using 2.4.5 or 2.4.6, try updating Phaser and see if you still get the performance hit. ShimShamSam and fillmoreb 2 Link to comment Share on other sites More sharing options...
Zeterain Posted February 18, 2016 Share Posted February 18, 2016 To answer your question about what the dirty flag does: BitmapData.dirty is checked in BitmapData.render, which "will push the texture up to the GPU if it's dirty." I didn't go further, but you can check it out if you are interested. I'll bet your performance issue is related to BitmapData.update though. ShimShamSam 1 Link to comment Share on other sites More sharing options...
ShimShamSam Posted February 19, 2016 Author Share Posted February 19, 2016 Ah, you're right about the version. Switching to 2.4.6 fixed it. Thanks! Zeterain 1 Link to comment Share on other sites More sharing options...
Recommended Posts