Sprite Animation Crash On iPhone 6 (Works fine in simulator)

Hello,

I am one step away from finishing my game and the only thing holding me up are some sprite animations.

I have entered the width and height of each frame in the sprite sheet correctly and it seems to run perfectly in the Corona Simulator.  

However, when running the build on my iPhone 6, I get an error regarding incorrect (w,h) on the second row of frames.  

Would anyone be able to take a look at my code and help pinpoint the issue?
 

Thanks for your help. I’ve included the code below.

-Mark

[lua]

–This is outside of my scene:Create()

local sheetOptions = 

{

width = 720,

height = 1280,

numFrames = 40

}

–This is inside my scene:Create()

local sheet_gameOver = graphics.newImageSheet(“gameOverAnimationSprite_1.png”, sheetOptions, display.contentWidth, display.contentHeight)

local sheet_gameOver2 = graphics.newImageSheet(“gameOverAnimationSprite_2.png”, sheetOptions, display.contentWidth, display.contentHeight)

local sequences_gameOver = {

{

name = “normalRun”,

start = 1,

count = 40,

time = 2000,

loopCount = 1,

loopDirection = “forward”

}

}

splashSprite = display.newSprite(sheet_gameOver, sequences_gameOver)

splashSprite.x = display.contentWidth/2

splashSprite.y = display.contentHeight/2

splashSprite:scale(0.5,.5)

splashSprite:play()

local function spriteListener(event)

if(event.phase == “ended”) then

display.remove(splashSprite)

splashSprite2 = display.newSprite(sheet_gameOver2, sequences_gameOver)

splashSprite2.x = display.contentWidth/2

splashSprite2.y = display.contentHeight/2

splashSprite2:scale(0.5,.5)

splashSprite2:play()

end

end

splashSprite:addEventListener(“sprite”, spriteListener)

[/lua]

Check the case of your .lua and .png resources.  

Case does NOT matter for SIMULATOR.

Case DOES matter for DEVICES.

Thank you for the quick reply!

If you are referring to the “gameOverAnimationSprite_1”

I am sure I have typed it correctly

Any other issues you can think of regarding the resolution of the sprite sheet or my choice to scale to .5?.

Hmmm.  Nope my first thought was case-sensitivity issues.  They usually present like this.

I know you’re sure it’s right, but you can easily check by adding my module to your project and loading it at the top of main.lua.  It will catch case and other naming issues in the simulator.

http://github.com/roaminggamer/RGCaseErrorDetect

re: Scaling… nope that should be fine.  Also I gave the code a a quick look and didn’t see any issues.  You’re sure the width and height you specified match the source image?

I’ll give it a shot when I get home and let you know.
Thanks for the advice.

I’m sure I have the dimensions correct, I’ve even double checked with my graphic designer.

However, the error I’m receiving does have to do with (w,h) on the iPhone so that’s what is confusing. It actually reaches the 11th frame (it says) and then crashes. Have the dimensions ever needed to be modified for an iPhone6?

I’ll try to get a screen of the actual error as well.

@roaminggamer

I’ve included your RGCaseErrorDetect.lua in my projects folder and used the code,

[lua]local ced = require “RGCaseErrorDetect”

ced.promoteToError()[/lua]

at the top of my main.lua and any other file in question.

Is this all I need to do or am I missing something?

I’m currently not receiving any errors from it.

Mark

@all,

I don’t see anything wrong with what Mark has posted (orignal post ++).  Does anyone else have any insights?

Also, if someone feels like being a second set of eyes, you should offer now.  I’m not sure if Mark is looking for that, but if you’re willing to look at his project, please say so.

@Mark,

Tip:  You only need to do that once (at the top of main.lua), but doing it multiple times won’t have a negative side-effect.

If you’re doing that, and not seeing any error dialogs in the simulator when you run the game and run it past the problem area, then I’m pretty sure your naming is right (as you said all along).  

If you are still crashing, you may need to get the entire app source to someone and enlist their help debugging it.  I offer this service, but I want you to understand I’m not giving you a partial answer here to encourage you to spend money.  

If I saw the issue here, I’d definitely tell you.  I’m just not seeing it and my intuition tells me the only way to root cause this is with access to the project.

Having said that, I’m not perfect, others may see the issue.  So, if you’re not in a hurry you can wait and see if anyone else sees something I missed.

Sorry I couldn’t help more here.

m4…

can you post the exact error message… maybe a screen shot of the error msg.  Is the msg showing on your iPhone screen, or on your console output … that is if you have your iPhone attached to the computer when testing. The console output likely will show more information regarding the error, then maybe just msg that shows on the device screen.

what iOS are you using on iphone6 … I’m just taking a shot in the dark, if you are using the newest iOS 9, maybe iOS9 does’t like ‘_’ in filenames… I  doubt that is the problem, but if it works on the simulator, and not on the device, and the ‘case’ is matched correctly …   stranger things have happened when a new os for a device comes out.  without the exact error msg, that is allI could think of with the little bit of info provided.   It seems to me easy to test by renaming the sprite sheet something very simple ‘sheet.png’ and renaming it the same in your code and run it again… just to test.

curious …if you are getting ‘no’ error msgs in the simulator when you run it on the simulator, are you getting any ‘warning’ msgs then? If so, what are they.

Hope this helps in some way.

Bob

Here is a screen of my error on the iPhone6

The sheets resolution is 7200x5120

10 frames wide and 4 frames tall
There is 0 pixels between each frame so I am using the dimensions of 720x1280 for the sequence table.

Anything wrong with those numbers in regards to my error?

I will try renaming the files.
I am currently on iOS 8.

Also, my config.lua file looks like this.

Would these settings be screwing up the way the images are read?

[lua] 

content =

{

width = 320,

height = 480, 

scale = “zoomEven”,

fps = 30,

}

[/lua]

m4…

I think the limit on newer devices for a texture size is 4096x4096 (I don’t keep up on that stuff, so I am not sure, but I am pretty sure)… but in any case, I never have a sprite sheet or image(at least yet) that is bigger then 1024 x 1024 … but i might have one that is 2048x2048(that is the biggest I would ever go) …   So that size of 7200 x whatever is too big.  Can’t see a need for something that big made of 40 frames. In any case, that adds up to a lot of texture memory.

See if you can work with those frames in smaller sizes, and be able to make that large image sheet much much smaller. 

But, the error you are getting, may not be directly due to the size of the image.    Just not likely you are going to be able (nor should you) use an image that size.

Check your ‘options’ table you coded for the image sheet.  What do you have for the ‘sheetContentWidth’ and ‘sheetContentHeight’.  According to this error message,  they are set at  4096, 2912 … and if your ‘width’ and ‘height’ fields in the ‘options’ table 720, 1280  then the frame chunks are too large to equal out to 40 frames in that smaller space of  4096, 2912.  That is normally the cause of that particular error message.  It is easy to happen, if you typo a number wrong, or change one of those 4 fields and they all do not coordinate together.

As to why that never error when on the simulator, I can only guess, you changed just one of those dimensions by accident or otherwise  before you went from simulator to device. 

To test:

make a copy of that super large image sheet (just to keep a backup of your original art, in case something happens)…  scale down the copy width to 2048 or 4096 at the most.  See that the height scales down proportionally, so your frames do not distort or stretch.  

After the scaling, you may have to adjust the height by 1 pixel or so, to make sure the height is evenly divisible by 4… as you have 4 rows.  Use this new scaled down image sheet in your code.

Redo your code for the image sheet, changing the 5 important fields in the ‘options’ table.   width, height, frames, sheetContentWidth, sheetContentHeight …  I think it will work.  Just for fun then, double that image size(scale it to 4096 x 4096) and double all those 5 fields except the ‘frames’  they stay at 40 since that is what you set.   See how works when the image is at 4096.

It should work as long as you keep those 5 fields in co-ordination.   

If you have more errors, please post your line of code where you create your ‘options table’, and your ‘newImageSheet’.

I hope this helps.

Bob

m4…

I did notice you did not put in the ‘sheetContentWidth’ and ‘sheetContentHeight’ in options table; which is acceptable as those fields are optional, according to corona documentation. I always put them in my options table. 

I can guess, since you did not enter the ‘sheetContentWidth’ corona defaults it to the max of 4096… and again, since your frame ‘width and height’ values are too large for that 4096 amount you get that error it could only make 11 of the 40 frames.

Good luck.

Bob

7200x5120 is too big.  

For best compatibility (Android and iOS), limit sheets to 2048x2048.  

If you are only targeting iOS, 4096x4096 should be your max.  

8192x8192 is the limit on the high-end devices (and your PC/Mac most likely), but that is way too big for old devices.

Thank you both for your replies. I will test this out very soon and get back to you.
I appreciate the help!

Check the case of your .lua and .png resources.  

Case does NOT matter for SIMULATOR.

Case DOES matter for DEVICES.

Thank you for the quick reply!

If you are referring to the “gameOverAnimationSprite_1”

I am sure I have typed it correctly

Any other issues you can think of regarding the resolution of the sprite sheet or my choice to scale to .5?.

Hmmm.  Nope my first thought was case-sensitivity issues.  They usually present like this.

I know you’re sure it’s right, but you can easily check by adding my module to your project and loading it at the top of main.lua.  It will catch case and other naming issues in the simulator.

http://github.com/roaminggamer/RGCaseErrorDetect

re: Scaling… nope that should be fine.  Also I gave the code a a quick look and didn’t see any issues.  You’re sure the width and height you specified match the source image?

I’ll give it a shot when I get home and let you know.
Thanks for the advice.

I’m sure I have the dimensions correct, I’ve even double checked with my graphic designer.

However, the error I’m receiving does have to do with (w,h) on the iPhone so that’s what is confusing. It actually reaches the 11th frame (it says) and then crashes. Have the dimensions ever needed to be modified for an iPhone6?

I’ll try to get a screen of the actual error as well.

@roaminggamer

I’ve included your RGCaseErrorDetect.lua in my projects folder and used the code,

[lua]local ced = require “RGCaseErrorDetect”

ced.promoteToError()[/lua]

at the top of my main.lua and any other file in question.

Is this all I need to do or am I missing something?

I’m currently not receiving any errors from it.

Mark

@all,

I don’t see anything wrong with what Mark has posted (orignal post ++).  Does anyone else have any insights?

Also, if someone feels like being a second set of eyes, you should offer now.  I’m not sure if Mark is looking for that, but if you’re willing to look at his project, please say so.

@Mark,

Tip:  You only need to do that once (at the top of main.lua), but doing it multiple times won’t have a negative side-effect.

If you’re doing that, and not seeing any error dialogs in the simulator when you run the game and run it past the problem area, then I’m pretty sure your naming is right (as you said all along).  

If you are still crashing, you may need to get the entire app source to someone and enlist their help debugging it.  I offer this service, but I want you to understand I’m not giving you a partial answer here to encourage you to spend money.  

If I saw the issue here, I’d definitely tell you.  I’m just not seeing it and my intuition tells me the only way to root cause this is with access to the project.

Having said that, I’m not perfect, others may see the issue.  So, if you’re not in a hurry you can wait and see if anyone else sees something I missed.

Sorry I couldn’t help more here.

m4…

can you post the exact error message… maybe a screen shot of the error msg.  Is the msg showing on your iPhone screen, or on your console output … that is if you have your iPhone attached to the computer when testing. The console output likely will show more information regarding the error, then maybe just msg that shows on the device screen.

what iOS are you using on iphone6 … I’m just taking a shot in the dark, if you are using the newest iOS 9, maybe iOS9 does’t like ‘_’ in filenames… I  doubt that is the problem, but if it works on the simulator, and not on the device, and the ‘case’ is matched correctly …   stranger things have happened when a new os for a device comes out.  without the exact error msg, that is allI could think of with the little bit of info provided.   It seems to me easy to test by renaming the sprite sheet something very simple ‘sheet.png’ and renaming it the same in your code and run it again… just to test.

curious …if you are getting ‘no’ error msgs in the simulator when you run it on the simulator, are you getting any ‘warning’ msgs then? If so, what are they.

Hope this helps in some way.

Bob