copyPixels,, Tilemap load CPU&GPU to much in html5 target


I’d want to propose to discuss this bug report I’ve created today. I believe that problem is wider that just about Tilemap. Tilemap is just a simplest way to describe it.

I noticed that playing very simple MovieClip exported from swf asset loads CPU&GPU to much. I thought the key could be in some swf export procedures or something like that and I started to find a different approach to play the animation.

I rasterized MovieClip frame by frame and tried copyPixels approach on each ENTER_FRAME. Nothing has been changed. I tried to use Tileset with Tilemap and again nothing has been changed. CPU& GPU load were so high for such simple operations with bitmap of 200x50 with 1:1 scale.

So I’ve created the empty project. And tried to put an empty 1x1 Tilemap on the stage. The result was the same: CPU&GPU load was inadequately high.

What is that and is the any approach or workaround to solve it? Thank you for your cooperation.

Is this consistent behaviour when using different browsers?

Absolutely. Every time.

How does the performance compare if you remove the Tilemap, or you just add a single Bitmap? Does the performance still seem too high for you or is it more specific to Tilemap?

After removing Tilemap, CPU&GPU load drops to zero. After adding, rise again. To demonstrate this behavior I’ve created a sample project in the github bug report.

If I add/remove Bitmap nothing happens. CPU&GPU load stays still.

What version of OpenFL?


CPU&GPU load with Tilemap on the stage:

CPU&GPU load without Tilemap

OpenFL Versions
8.9.7 & 9.0.2

OpenFL Targets

Here this should help:


Thanks you. But I think this patch is such an ad-hoc thing. Moreover, using empty tilemaps is pointless.

Tilemap is not the only thing. I mentioned it here only for demonstration purpose. Please, see initial post. What I want to tell is pure window.requestAnimationFrame loads cpu&gpu relatively at least twice less. It points me to conclusion that a lot of work is done in openfl/lime routines on each frame. And some of that work seems unnecessary. What do you think about it?

1 Like

Which part seems unnecessary?

I didn’t do a research of that kind. And I’m not familiar with framework on that low level. But take a look at this screenshot:

Scripting, rendering, painting and system combined is costing 1.3 milliseconds per frame. This doesn’t seem alarming to me?

empty tilemap may be not that “descridable” for this kind of problems. It surely has structured cost just to prepare anything to render - even 1 pixel should be packed, sent on GPU, etc.

what happen with CPU load if you use your original tilemap instead of empty? will it stay at 4% or it will scale significantly according to tilemap “heaviness”?

If you read the initial post, you see that it’s not about tilemaps only. I thought that empty tilemap is an ideal way to show that enter_frame cycle takes to much even for nothing. In comparison, take a look at this javascript code and cpu&gpu load. It’s spends ~35% less of cpu time and ~55% less of gpu. BTW, it updates every pixel of all the scene on every frame: ctx.fillRect(0, 0, canvas.width, canvas.height);

<!DOCTYPE html>
<html lang="en">
<canvas id="myCanvas" width="984" height="630"/>

	let canvas = document.getElementById("myCanvas");
	let ctx = canvas.getContext("2d");
	let counter = 0;
	function onEnterFrame() {
		ctx.fillStyle = '#fff';
		ctx.fillRect(0, 0, canvas.width, canvas.height);
		ctx.fillStyle = '#000000';
		ctx.font = '20px sans-serif';
		ctx.fillText(counter++, 20, 20);


This result is very close in other browsers.

I don’t have heavy animations to compare. I noticed that heavy load behavior on my simple looped not scaled animation of 176 frames of 63x27px on 60fps. Answering your question, the load is rising a bit with my animation, no matter packed as movieclip or rasterized and tiled.

Although Joshua says that he has 1.3ms per frame I still believe that cpu load of 6.5% and gpu of 21% for that kind of operations is inadequate. BTW, if we count straightforward, 1.3ms is around 7.8% of cpu time with 60fps.

at ~6.3% actually for the Firefox processes, see screenshots in my post above.