Animation causing actual device to crash, while simulator runs fine.
Hi,
Im trying to run this animation code in my menu. It runs smoothly in the simulator, but crashes on an actual device with this note (Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")).
Heres my code, am I using too much memory?
Code:
.h
IBOutlet UIImageView *bakgrunn;
.m
bakgrunn.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"snow1.png"],
[UIImage imageNamed:@"snow2.png"],
[UIImage imageNamed:@"snow3.png"],
[UIImage imageNamed:@"snow4.png"],
[UIImage imageNamed:@"snow5.png"],
[UIImage imageNamed:@"snow6.png"],
[UIImage imageNamed:@"snow7.png"],
[UIImage imageNamed:@"snow8.png"],
[UIImage imageNamed:@"snow9.png"],
[UIImage imageNamed:@"snow10.png"],
[UIImage imageNamed:@"snow11.png"],
[UIImage imageNamed:@"snow12.png"],
[UIImage imageNamed:@"snow13.png"],
[UIImage imageNamed:@"snow14.png"],
[UIImage imageNamed:@"snow15.png"],
[UIImage imageNamed:@"snow16.png"],
[UIImage imageNamed:@"snow17.png"],
[UIImage imageNamed:@"snow18.png"],
//THIS PART IS FILLED WITH THE REST, BUT I DONT WANT TO POST SO MUCH CODE
[UIImage imageNamed:@"snow86.png"],
[UIImage imageNamed:@"snow87.png"],
[UIImage imageNamed:@"snow88.png"],
[UIImage imageNamed:@"snow89.png"],
[UIImage imageNamed:@"snow90.png"],
[UIImage imageNamed:@"snow91.png"], nil];
// all frames will execute in 1.75 seconds
bakgrunn.animationDuration = 4;
// repeat the annimation forever
bakgrunn.animationRepeatCount = 0;
// start animating
[bakgrunn startAnimating];
[self.view addSubview:bakgrunn];
[self.view sendSubviewToBack:bakgrunn];
[bakgrunn release];
Without knowing the exact error, I am going ahead an saying you are running out of memory. I am guessing yoru animation will run if you animate correctly with 10 frames rather than the 90+ you have... either way, you will need to optimize you image frames and decrease the number of images... I have been able to get about 30 images (256 x 256 px opaqu PNGs at 16 colors) to cycle in about 5 seconds on a 3G iPhone, but it that is pushing the limit, but that's another story.
Simulator vs iPhone is not perfect, as the simulator does not "run out" of memory like the iPhone, and the CPU is faster. There are other differences, but these differences seem the most relevant in your case.
You can verify that you are out of memory by trapping logs in - -(void)didReceiveMemoryWarning in your view controller class...
Here is how to check the crash log on your device, to state the nature of the crash if the console did not :
1) in XCode, Windows -> Organizer
2) select your device from the left hand pane
3) Select the Device Logs tab on the right hand pane
4) Find you app in the list, and the title will "Low Memory" or "Crash" or something like that...
That is a problem yes. I have really big resolution and many images. I will find a way to live without the animation.
Thank you.
I ran into this same issue on my last iPad app. I found that if I reduced the size of the frames in the middle by half that it helped tremendously. I had full screen iPad animation going, but I only used full resolution on the first and last frames... everything in the middle was half res, but you don't notice as much because it's only on screen for a split second. Just be sure to set your UIImageView to fill the space associated for it.
Also, as mentioned above, cut down on the number of frames in your animation. That will go a long way as well.