Hi,
I am trying to fix my “famous” problem with copyPixels on HTML5 target: with BIG spritesheets (I am using a derivation of spritesheet library), when parsing the atlas to extract all the Bitmaps by copyPixels my browser blows up and my monitors turn off, as if the graphics card crashed.
I am trying to find an explanation and a way to avoid this, and doing a few experiments. I am studying Lime/Image.copyPixels: it first of all converts both the source and target images from CANVAS to DATA (source is the atlas, target is the image to extract), and then it copies the interested rectangle from the atlas to the target.
The convertion phase has no problems, so evidently the crash is caused by the copy phase, maybe memory can’t catchup with the extraction of so many images all at once, I will try to set a delay to test this hypothesis.
In the meanwhile I have a question about the source atlas convertion: it obviously needs to be converted to DATA only once, so I added a check in the ImageCanvasUtils.convertToData function:
public static function convertToData (image:Image, clear:Bool = false):Void {
if (image.type != DATA) // <---- this one
{
[...]
image.type = DATA;
}
}
…so the source will be converted to DATA only the first time copyPixels is called.
If I put a tracking trace inside the “if” brackets I notice that it will be executed (in my app) about 500 times, against the xthousands times without the “if” check: I can’t define how many times the trace is executed, as the browser hangs, this happens when it can’t catchup with the many trace() calls.
The result is identical, so I am wondering if this check is preventing the convertToData function from doing something useful I can’t notice.
This does not prevent my app from crashing with giant atlases, but if it can introduce a small optimization I will be happy
I don’t understand what’s happening inside the original convertToData function (maybe it already avoids multiple convertions of the same image to DATA), so I am asking if you can please have a look at it and tell me if my modification is useful.
Thanks
Now I am doing some tests on the copy phase…