0
votes

Here's my problem:

I have a Flash swf that uploads files from local machine and if they are images it resizes them if needed. This involves creating a JPGEncoded bytearray from a bitmapData object. After im finished with the bitmapData I dispose() of it.

I am noticing that flash will get stuck while resizing an image sometimes and have tracked this down to an "invalid bitmapData" error message. I tried last night before leaving work and it was throwing this message after 2 images!! This morning it all seemed to be fine so I decided to push it and tried uploading 20 images of 5616x3744 pixels and 5.32MB (the same images I tried previously).

I switched on performance monitor in windows and started the upload in the SWF running in mozilla + firebug for good measure. Things worked great for about 12 images then on the 13th (!!) it froze again. Ive attached a screenshot of the graph from performance mon.

alt text

Im guessing I need to do more tests like this to see where there are any problems. Can anyone shed some light on what Im seeing here that might cause problems - the yellow line looks suspicious!(?)

Large green spike corresponds to redrawing the bitmapData I think and the smaller green spike is drawing a thumbnail version from the same Bitmap object after the large version has been successfully loaded. What other counters should I use to monitor memory usage etc.

Any advice is appreciated. many thanks

1
Where is this error coming from? Are you catching it in code, or is it being displayed by the browser or by Flash or something? I don't think you need a performance monitor, I think you need to track down that error and find out what issues it under what circumstances, but we could use more info.fenomas
The error is only shown when I run this locally in Flash CS4. I am tracing out the Systemwide Flash Memory and noticing a jump from 87MB to 166MB while loading in an image of only 3.7MB . My onProgress handler for image_loader.loadBytes() also traces memory used at 87MB while loading is in progress. Then in my Complete handler memory is up at 166MB. At which point bitmap.width = 0 and bitmap.height = 0 which throws- ArgumentError: Error #2015: Invalid BitmapData. at flash.display::BitmapData() at uploader_fla::MainTimeline/uploadResizedImage() at uploader_fla::MainTimeline/_onImageLoaded()undefined
Correction the error only gets reported in Flash CS4 rather than on web, i need to add a try, catch.undefined
Would it be possible to see some code snippets? You're saying the error comes after the image has been resized, and during the process of uploading it, right? At first glance it sounds sort of like a race condition, have you tried not disposing the BMData and leaving it for the GC? But anyway seeing some code might help. Incidentally it's normal for heavy image stuff to eat a lot of memory, since the compressed JPG may be only a few MB, but internally it's stored raw and unpacked, eating up 32bits per pixel or whatever (possibly with extra space eaten by mipmaps, I'm not sure).fenomas

1 Answers

0
votes

You've got too many pixels, that's all. In Flash Player 10, the maximum number of pixels a bitmap can have si 16,777,215 (or 0xFFFFFF). Also, the maximum width or height is 8,191, as long as the total pixel count is under the maximum value. Your test bitmap has 21,026,304, which is way over the top.