Reporting some progress on this. It seems I was dealing with multiple issues, one of which being the overhead of several thousand calls to packRGBA and putPixel (the pixel and image helper functions). When I remove these helpers and simply declare my pixel data as arrays of raw hex, the PB interface behaves much better. I am now able to easily preview/run/save an animation as large as 9 frames of a 23x23 bitmap, so 4761 pixels. Because I am now storing my RGBA data as 16-bit pairs, that’s 9522 pixel array elements. So while this is not as efficient of a way to pack pixel data into arrays, the PB UI handles it far better than it handled thousands of calls to the helper functions doing the packing/unpacking.
With this method, I am now hitting a different limit, one which may actually be the array memory limitation I have seen discussed in other posts. When I try to add in a 10th frame to my animation, I now get a very specific “Array index out of bounds” error that highlights row #6 in of pixel data of the 10th frame…which would be somewhere in the neigborhood 9750 pixel array elements. If you count the elements of the 3D array structure as well (frames, rows) it’s more like 9990. Fortunately the UI is not freezing up or acting poorly in any way when I encounter this limit, it’s simply refusing to run the pattern with the 10th frame added in, and correctly resumes running the pattern after I remove the offending extra frame’s arrays. That’s a vast improvement over where I was getting stuck with the previous method using helper functions after adding only 4 frames.
I suppose my questions now are:
-
Am I analyzing this correctly, and have I now reached the true practical limitations of the PB for animating bitmap data in arrays?
-
Is the limit I am now hitting solely based on the number of array elements, or something else?
-
Is there a way to more effectively pack my pixel data into arrays that would allow me more data with the same number of array elements? (One that doesn’t require a helper function like packRGBA, as that apparently won’t scale well with thousands of calls crashing the UI.)
Here is my new code that runs 9 frames at 23x23 very well…
https://pastebin.com/aqb5Na8b