iphone watchdog timer

Member
Posts: 81
Joined: 2007.05
Post: #1
So, every 9th time I launch my app it gets a crash. Seems random. Sometimes more frequent than others. Other times hardly at all. And it never crashes when the usb cable is attached with the debugger. I thought it was a memory issue but thats not the case. The crash log has "0x8badf00d" as the exception -- ate bad food. Smile

Anyhow, after looking around I found it was the watchdog timer shooting the app because it takes too long to load. So, the question is how long is too long? It does not say in the tech note.

http://developer.apple.com/iphone/librar...n2151.html

I suppose I need to load in another thread or something.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #2
I don't recall seeing the specific time allowed for launch, but for quit the programming guide says you get five seconds or it'll terminate it. Why don't you do a little test to find out?
Quote this message in a reply
Member
Posts: 81
Joined: 2007.05
Post: #3
Its really odd. If I reboot the phone, it will always shoot the program on the first run. Its like it does one initial check on every program run. Most other times, it runs fine. I had tested for a day but I was on the usb cable .... found out later and late in the process.

Sort of reminds me when I've programmed psoc microcontrollers ... they have a hardware timer that goes off. Pretty fun stuff.

Anyhow, I just load into a separate thread and make sure I've got the context stuff set right. It works well now.

I have to get a progress bar in. Main issue is updating the progress bar in another thread. But looks like I just call performSelectorOnMainThread to get it to refresh properly. Seems like people use alert sheets but I just want the gui to work normally while loading then enable play.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #4
macnib Wrote:I have to get a progress bar in. Main issue is updating the progress bar in another thread. But looks like I just call performSelectorOnMainThread to get it to refresh properly.

You can do that or you can have a timer in the main thread check a progress float from the loader thread. Shouldn't be a problem either way. I prefer the progress bar over the alert sheet myself.
Quote this message in a reply
Member
Posts: 81
Joined: 2007.05
Post: #5
He he, I got the progress bar done. Works when being set from other threads. Was thinking about it this afternoon.

I override a UIProgressView instance and create a new class foobar that inherits all the UIProgressView stuff. In my xib, I set the class from UIProgressView to the new class foobar.

Now in class foobar, I have two functions. The first call just calls performSelectorOnMainThread on self with a selector that is the other function in my overridden class foobar. The other function receives the progress number and then calls setProgress on self -- it was called via performSelectorOnMainThread which runs it in the main thread. Can only update the progress view in the main thread!

Now I just make an output and connect that progressview to where ever I need it with my class.

Appears to work well. Really liking this cocoa stuff. Now, the player can type in their player name or look at the other parts of the program while everything is loading in. Love threads...
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #6
If you preform most of your loading after your app has successful launched you will be fine, plus its a much better user experience if you provide a progress bar. I have used this method a number of times in the past when apps would of taken 20-30 seconds to load.

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Timer and Touch Event concurrent issue claudie 7 4,095 Aug 9, 2009 06:05 PM
Last Post: claudie
  Timer Slows down in sleep mode chrism 13 5,595 Jun 14, 2009 05:36 PM
Last Post: longjumper
  UIScrollView pausing timer when scrolling duncster 1 2,932 Jan 14, 2009 01:00 PM
Last Post: duncster