Sprite causes device build to crash

We're currently working on an app that needs several sprites. They work pretty well in Corona and Xcode simulators, as well as in iPad. However, if we use the following lines of code, the app crashes in iPad but not on the simulators. We checked the filenames and they're correct. What's wrong?

Is there a limit to the number of sprites to be used in an app? Is there a size or file limit for every sprite?

Thanks.

-Mhae

1
2
3
local data = require ("sun_sREVISED_F").getSpriteSheetData()
local sheet = sprite.newSpriteSheetFromData("sun_sREVISED_F.png", data)
local sunsummonSprite = sprite.newSpriteSet (sheet, 1, 45);

How big are your sprite sheets? Are they larger than 1024 x 1024 ?

Hi Peach, sorry for the late reply. I've been out on vacation. Some of my sprite sheets are more than 1024x1024, but they work good. The two sprites which are causing the crash are more than 1024x1024.

if ur sprite size is bigger than 1024x1024 then iphone 3gs will crash if its longer then 2048x2048 than ipad and iphone4 will crash

is this ur problem?

@hgvyas123:

We're using iPad. One of the sprites that causes the crash is 2046 × 1588, while the other is 2048 × 2048. I checked all the sizes of our sprite sheets just to be sure, and one that works perfectly well is 2048 × 2048.

cool this sprite 2046 × 1588 is the problem divide it in two parts and ur problem solved

[edit]

oops its under 2048x2048 lol

was that right png file i mean some standard like 32 bit

and can u see any memory warning or some error?

@hgvyas123:

What do you mean split it into two? Let's say the 2046 × 1588 sprite sheet has 20 frames, then I'll divide them into 10 frames each, and after that use the sprite.add? Did I get it right?

How about the other sprite sheet which is 2048 × 2048? Do you have an idea?

BTW, thanks for the suggestion. I really appreciate it.

[edit]

No, I don't receive any error (which really drives me craaaaazy!). I don't receive any error in both xcode and corona simulators, and also in the device terminal.

i had just edited above my post

No, I don't receive any error (which really drives me craaaaazy!). I don't receive any error in both xcode and corona simulators, and also in the device terminal.

Yes, it's 32bit and .png file.

it also drives me crazy no error no memory warning (may be need to chk) image is perfect now what to do??

would you mine to do little test just download any image from internet of approx same size and see that was working or not?

:)

I tried that too. I used a different sprite sheet instead of those two 'malfunctioning' sheets, and it worked pretty well.

ohh you mean that id you put any other image instead of that 2046x1588 than i am 99% sure that image is wrong (1% reserved for safety :) )

and if you had used the same image for both sprites use two different images for that corona is not loading one image two times even we say to load so may be if crash is due to low memory you cant got that in this way

are you able to load that image only no any other thing??

@hgvyas123:

I'll try loading those two sprites and nothing else. Thanks.

IF they load, what do you think is wrong? IF NOT, what will be the possible workarounds for this?

This thing is driving me reaaaally insane. :(

if they load then it may be memory related crashing

if not then image is the issue

cant say exactly just my guess

Thanks hgvyas123. I really appreciate your replies.

I'll try it when I have the device.

Any other idea?

nup no more idea see what happens in device

Run a test to see how your memory is going, here's some copy and paste code to use;

1
2
3
4
5
6
7
8
9
10
local function monitorMem(event)
     collectgarbage("collect")
     
   print( "\nMemUsage: " .. (collectgarbage("count")/1000) .. " MB")
   print("Texture Usage " .. system.getInfo( "textureMemoryUsed" ) / 1000000)
       
   return true
end
 
Runtime:addEventListener("enterFrame", monitorMem)

@hgvyas123: we tried to play the 2048x2048 sprite sheet alone, and it worked out well. Then we reduced the number of frames, and used it on the game. It played well, but the quality of the animation suffered because the frames were limited. We haven't tried reducing the other sheet though.

@peach: Thanks for the codes. We ran it into some tests and MemUsage returns between 0.265 to 0.275 MB, while Texture Usage is 69 to 70. I'm pretty new with this, so I'm not quite sure if the results are okay or not. How much is the ideal memory usage and texture usage?

That's high. This thread has a few thoughts on how much is too much in terms of texture usage;
http://developer.anscamobile.com/forum/2010/11/28/texture-memory-how-much-too-much

Thanks a lot peach! Now I understand :)

views:1563 update:2011/10/4 8:06:35
corona forums © 2003-2011