Help! App won't run on my device

Discussion in 'Public Game Developers Forum' started by wastedyuthe, Mar 13, 2009.

  1. #1 wastedyuthe, Mar 13, 2009
    Last edited: Mar 13, 2009
    I have used the Development Provisioning Assistant to go through the setup needed to get my app running on my device. It went through settings up the App ID, Keychain access etc etc, and in the end in Organizer I have a provisioning profile listed on my Touch with that same profile listed underneath and the Touch listed under Included Devices.

    It all went so swimmingly, until the assistant told me to select the device at the top instead of the simulator and click Build. The app has gone onto my device fine. But when it runs automatically it stays on the splash screen I created instead of going to the main menu. When I quit it, and just try tapping the game icon on the home screen, the splash screen comes up for a couple of seconds, then it returns to the Home screen again!

    What's going on? When I run my app in the simulator it works perfectly.
    Is there anything I can check?

    One thing I have noticed is at the bottom left of the Xcode window, it says "GDB: Running" while the app loads, then it says "GDB: Interrupted" at the point I assume it crashes. What is this?

    [UPDATE]
    I ran the console and it showed this at the point where "GDB: Interrupted" shows...

    2009-03-13 10:03:08.746 FoJ[230:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
    2009-03-13 10:03:08.790 FoJ[230:20b] Stack: (
    808221155,
    806100816,
    808035743,
    808035647,
    812215263,
    812214747,
    16755,
    816623612,
    818122640,
    818130772,
    816625560,
    816626608,
    816627024,
    9203,
    816115500,
    816152052,
    812205481,
    807837071,
    807834407,
    827752032,
    816118388,
    816157144,
    8381,
    8244
    )
    terminate called after throwing an instance of 'NSException'
    (gdb)


    I don't understand why I am having this issue (or even WHERE the issue is) when it runs perfectly fine in the simulator.
     
  2. sam the lion

    sam the lion Well-Known Member

    Jan 12, 2009
    1,456
    0
    36
    Italy
    gdb should be the debugger.

    take into account that I have no experience with the iphone SDK, but could that be that it doesn't find some file?
     
  3. #3 wastedyuthe, Mar 13, 2009
    Last edited: Mar 13, 2009
    I have looked at my code more, and recognized the command "InitFileURLWithPath" bit as part of my sound effects and music code. I am using the AVFoundation Framework, and use this to set up my button click sound effect as well as other similar ones for music and other sound effects.
    This works perfectly in the simulator, but just to test (after backing up the project) I removed all instances of audio code from my project, so it is entirely audio free- AND IT PLAYS! Another issue I have is some of the sprites aren't displaying in the actual game itself, yet they do so in the simulator.
    Someone please help before I just move my whole project to the trash and forget the whole thing.
     
  4. sam the lion

    sam the lion Well-Known Member

    Jan 12, 2009
    1,456
    0
    36
    Italy
    again, nothing iphone-oriented but just general programming thoughts - it seems it's not able to access to some resources (audio, sprites) on the device, I don't know if it's related to absolute-relative paths issues or something like that, but I don't think it will be hard to solve. I'm sure you'll shortly receive more professional help that will solve the thing :)
     
  5. InsertWittyName

    InsertWittyName Well-Known Member

    Nov 26, 2008
    202
    1
    0
    First port of call is to 'Clean All' and then build again.

    If you still have problems it looks like your resource files aren't being copied across, check the copy phases etc. and make sure everything you require is.
     
  6. #6 wastedyuthe, Mar 13, 2009
    Last edited: Mar 13, 2009
    I think you are right about the resource files. But first, how do I 'clean all' and what does that do exactly? This is my very first app and am still learning.

    Thanks.

    [EDIT] Ahh- found the Clean All button in the Customize Toolbar option for Xcode. Trying it.

    [UPDATE] The Clean All option has forced it to install all the resources again and I have all my sprites displayed as they should be, which is a great improvement. Now I just need to revert back to the version of my project with the audio and try and get that to work. Also, even without the audio, I can play my game but it crashes after 10-20 seconds play- but that's a hurdle I will tackle AFTER sorting out the audio if I can. Thanks for your help so far.

    [UPDATE TWO] Done it! Well, I've at least got the audio working. I checked the audio players and found a discrepancy in the file name reference. It is now playing audio perfectly (although a little low volume, but I can fix that). Now I need to fix one last thing- the crashing while the game plays. When I have that fixed, I will definitely need to work on making the game faster. It is quite slow on the Touch compared to lightning fast on the simulator. But first things first- fixing the crash.
     
  7. With the games only problem now of crashing during gameplay, can someone please tell me what the console means when it says "Program exited with status value:101."?
    This is, of course, what it says when the game crashes. There is no other information it gives me now, as to why it is crashing, so this is a tough one to figure out.
     
  8. Schenk Studios

    Schenk Studios Well-Known Member

    The crash that you are getting is indeed due to a missing file. I ran into a similar problem a few months ago, and the solution for me was to check my capitalization. The simulator doesn't care if something is capitalized or not, but the iDevice does.
     
  9. Thanks Andrew. I had that issue with one or two of my sprites I know, and I had the same issue with one of the sound effects (the button click), which is why I had both of those issues and have now solved them. I will look into the sprites used in the game to make sure they are all correctly named and make sure the reference to them is also exactly the same- case sensitive. I will report back later (on my way home from work in a minute).
     
  10. Shroomies

    Shroomies Member

    Jan 16, 2009
    22
    0
    0


    If you get a stack trace like this, you can translate the numbers into lines of code by typing the following in the Console:

    info symbol 16755

    where 16755 is the first relatively small number in the list. Other useful Console commands are "bt" to print out the stack trace and "po varName" where varName is the name of a variable. po is very useful for seeing the contents of a NSDictionary.
     
  11. Ah, I see. Thanks for the tip. It's a pity I've sorted out this particular error already, and don't get any error now when the game crashes during gameplay. I just get "Program exited with status value:101." in the console- any idea what that is?

    Your tip will no doubt help in the future if I get the same thing again.
     
  12. InsertWittyName

    InsertWittyName Well-Known Member

    Nov 26, 2008
    202
    1
    0
    That 101 value means that your app was killed because it was using too much memory.

    Things to do would be to run it through Leaks, Object Alloc etc. and see what's going on.
     
  13. #13 wastedyuthe, Mar 13, 2009
    Last edited: Mar 13, 2009
    Blimey! Running out of memory with such a small game? I have ran the app in the simulator with Object Alloc recording and you can see the results in the attached picture. I just had a few goes before quitting it (it doesn't crash in the simulator remember). Is 75Mb bad?

    [UPDATE]
    I have Googled the error message, and on a forum on a site called iPhoneDevSDK, someone mentions having the same error message. Here are some quotes from that thread which does concern me, as I am using the same command....

    "The problem turned out to be using [UIImage imageNamed:] This is evidently somewhat buggy and when I replaced it with loading the file directly the problem went away."

    "I am using the [UIImage imageNamed:] and having the 101 issue as well... can you post how to you loaded the image file directly?"

    I use this to display most of my images. If this is causing the issue, what else can I use?
     

    Attached Files:

  14. lazypeon

    lazypeon Well-Known Member
    Patreon Bronze

    #14 lazypeon, Mar 14, 2009
    Last edited: Mar 14, 2009
    I read that error not as a missing file, but that somehow nil was being passed in as the path. Are you sure the path is right?

    EDIT: BTW, don't rely on the RAM usage when running in simulator. It's not the same as on iPhone (as far as I know). My game used '20mb' in the simulator but 3mb on the iPhone. I don't think you get anyone near 75mb on the iPhone anyway.
     
  15. InsertWittyName

    InsertWittyName Well-Known Member

    Nov 26, 2008
    202
    1
    0
    75mb is very bad, more than twice than what you'd expect to be able to allocate on the device.

    What are you loading anyway to use that much memory?
     
  16. Well, two thoughts:

    First, you may want to consider compressing or resizing your images to make them smaller. How big are the files you are dealing with?

    Secondly, do you need to have all of them on the screen at the same time? You might need to "deallocate" them if you are finished using them. In Objective-C, you can do this with the release command, as in:

    [image_variable_name release];

    If you are sure that you don't need an image, you can take it out of memory that way. If you need it again, just create it again like you did before. But if you try to access the image file after you have deallocated it, you will get an error, so be careful when you do it in your program.
     
  17. #17 wastedyuthe, Mar 14, 2009
    Last edited: Mar 14, 2009
    My actual game screen constantly displays 2 large images, both of them animating every 2-8 frames depending on what speed I want them to do so. I also have a scrolling background split up into layers, which are twice the length of the screen and they just go left to right then right to left. There are a few smaller images on screen do display score etc. But I think the main concern is the animation. I can cut out the scrolling background and still have the game crash when ever I try and do something with my character.
    This is the command I am using to animate an image-

    NSString* jName = [NSString stringWithFormat:mad:"jed_sprite%i.png", jSpriteDisplay];
    jed.image = [UIImage imageNamed:jName];


    I have read up a little more, and found this quote from another forum:

    "I just didn't take into account that initially the images get read in slower on the device. So by the time the images were read in, the animation had already ended. (I wanted a repeatCount of 1. If I set repeatCount to, let's say 5, it'll show 3 repetitions the first time I tell it to start animating. But on subsequent runs, it'll correctly show all 5 repetitions.) Correct me if I'm wrong, but my guess is that the animation starts, and starts counting the number of repetitions, even if the images haven't actually gotten loaded in yet, and therefore won't show as many repetitions as you expect."

    So with the "UIImage Imagenamed" command it is loading a png into memory everytime and perhaps that is also slowing my app down and not animating fast enough to begin with. Is there a way to load them all in via a string perhaps in the ViewDidLoad therefore speeding up the process when I do need them displayed? And as I said, people have mentioned "UIImage Imagenamed" not being very memory resourceful, so perhaps I could use another way.

    I don't really want to make the images smaller, but perhaps that might be a last resort. I would like to see if I can try a different method of displaying them first to see if that helps.
    Any ideas?
     
  18. InsertWittyName

    InsertWittyName Well-Known Member

    Nov 26, 2008
    202
    1
    0
    My initial thought is that you should be using OpenGL for any serious game.

    My second thought is that you need to load all the images before you do the animation.

    Just load them into an array initially, then iterate through them for the animation when you're drawing.
     
  19. #19 wastedyuthe, Mar 14, 2009
    Last edited: Mar 14, 2009

    Yeah, I'm just getting used to Objective C, let alone OpenGL. So that will have to wait.

    Regarding loading them into an array first, that sounds a good idea. Something like what this guy does in this YouTube vid:

    [hqyoutube]WzDpJCjc-tg[/hqyoutube]

    However, it's hard to see what he has typed. Could you write a quick example as to how I would add the sequential PNG's to an array? There are over 40 for the players character, so there should be a way to do so by adding a value to a string to make the filename like I have above, right?

    [UPDATE] I have made quite an improvement in the performance and the frequency of crashing simply by editing my images to a smaller size. The size of the PNG's took up a lot of space so I could have enough room to animate my objects. Now animation is more or less finished, I have returned to them to make the empty space in the PNG's as small as possible. This has really helped speed up the game and although it still does crash if I try and do too much, it is no-where near as frequent. So far so good. The next job for me to do is to remove a few of the PNG's as they are more or less repetitions of other animation frames, so I can just use the same PNG for both instead of 2 different ones. I am sure this will benefit memory greatly too, although I will have to amend the code to compensate. Setting up an array will be the obvious choice.



    [UPDATE 2] Good news!!!

    I removed a fair few of the PNG's as some of them were replications of other frames, and instead used an array to let it know which PNG to use for which frame. This, coupled with the reduced size of my PNG's (removing the spare space that wasn't used by the character) results in not only a faster game, but also one that (so far- fingers crossed!) does NOT crash!!! I can't believe it!
    I think I still need to look into memory management a bit more though. I assume it is best to release the images when returning to the career screen, then load them again when returning to the game screen.
    I am just chuffed I actually have it in a playable state at the moment though. PHEWW!!!
     

Share This Page