Alternative to NSTimer

Member
Posts: 24
Joined: 2009.02
Post: #70
DoG Wrote:First of all, NSTimer doesn't misfire, so please stop spreading nonsense.

Yes, it does. If your code has not completed by the next time the timer is scheduled to fire, it misfires.

From Apples documentation for NSTimer:

Quote:A repeating timer reschedules itself based on the scheduled firing time, not the actual firing time. For example, if a timer is scheduled to fire at a particular time and every 5 seconds after that, the scheduled firing time will always fall on the original 5 second time intervals, even if the actual firing time gets delayed. If the firing time is delayed so far that it passes one or more of the scheduled firing times, the timer is fired only once for that time period; the timer is then rescheduled, after firing, for the next scheduled firing time in the future.

In other words, a timer can misfire. A misfire is simply skipping a fire.

I've seen this happen a lot on the iPhone, especially when doing some rapid prototyping. Before optimising the drawing code, if it takes close to 16.6 ms (which is the period for 60fps), the timer regularly fires with 33.3 ms intervals (double 16ms, as one fire has been skipped).

This is why mainly people oversample (trigger the timer at a much higher rate than required for 60fps), perhaps without realising it.
Quote this message in a reply
Post Reply 


Messages In This Thread
Alternative to NSTimer - demonpants - Mar 18, 2009, 02:51 PM
Alternative to NSTimer - longjumper - Mar 18, 2009, 04:15 PM
Alternative to NSTimer - demonpants - Mar 18, 2009, 11:48 PM
Alternative to NSTimer - Frank C. - Mar 19, 2009, 01:28 AM
Alternative to NSTimer - godexsoft - Mar 19, 2009, 02:15 AM
Alternative to NSTimer - riruilo - Mar 20, 2009, 02:56 AM
Alternative to NSTimer - demonpants - Mar 20, 2009, 11:29 AM
Alternative to NSTimer - JustinFic - Mar 20, 2009, 12:01 PM
Alternative to NSTimer - demonpants - Mar 20, 2009, 02:07 PM
Alternative to NSTimer - godexsoft - Mar 23, 2009, 09:04 AM
Alternative to NSTimer - godexsoft - Mar 23, 2009, 09:07 AM
Alternative to NSTimer - GregoryM - Mar 24, 2009, 01:15 AM
Alternative to NSTimer - demonpants - Mar 25, 2009, 05:07 PM
Alternative to NSTimer - godexsoft - Mar 26, 2009, 02:25 AM
Alternative to NSTimer - demonpants - Mar 26, 2009, 10:08 AM
Alternative to NSTimer - Ammonium - Apr 6, 2009, 12:44 PM
Alternative to NSTimer - demonpants - Apr 8, 2009, 02:43 PM
Alternative to NSTimer - mterlecki - May 12, 2009, 09:26 AM
Alternative to NSTimer - longjumper - May 12, 2009, 06:08 PM
Alternative to NSTimer - mister_t - May 13, 2009, 12:49 PM
Alternative to NSTimer - green_ghost - May 13, 2009, 11:12 PM
Alternative to NSTimer - bmantzey - May 15, 2009, 09:25 AM
Alternative to NSTimer - warmi - May 15, 2009, 10:49 AM
Alternative to NSTimer - warmi - May 15, 2009, 10:53 AM
Alternative to NSTimer - green_ghost - May 15, 2009, 07:45 PM
Alternative to NSTimer - ShiftZ - May 16, 2009, 02:24 AM
Alternative to NSTimer - mpatric - May 18, 2009, 09:49 AM
Alternative to NSTimer - ShiftZ - May 18, 2009, 11:55 AM
Alternative to NSTimer - warmi - May 18, 2009, 12:03 PM
Alternative to NSTimer - DoG - May 18, 2009, 02:56 PM
Alternative to NSTimer - warmi - May 18, 2009, 07:46 PM
Alternative to NSTimer - mpatric - May 19, 2009, 02:27 AM
Alternative to NSTimer - DoG - May 19, 2009, 04:07 PM
Alternative to NSTimer - warmi - May 19, 2009, 08:38 PM
Alternative to NSTimer - DoG - May 20, 2009, 02:08 AM
Alternative to NSTimer - ShiftZ - May 20, 2009, 04:48 AM
Alternative to NSTimer - iamflimflam1 - May 20, 2009, 07:33 AM
Alternative to NSTimer - DoG - May 20, 2009, 07:42 AM
Alternative to NSTimer - ShiftZ - May 20, 2009, 08:35 AM
Alternative to NSTimer - warmi - May 20, 2009, 09:08 AM
Alternative to NSTimer - mpatric - May 20, 2009, 11:23 AM
Alternative to NSTimer - mpatric - May 20, 2009, 11:26 AM
Alternative to NSTimer - mpatric - May 20, 2009, 11:31 AM
Alternative to NSTimer - ShiftZ - May 20, 2009, 12:12 PM
Alternative to NSTimer - DoG - May 20, 2009, 02:44 PM
Alternative to NSTimer - warmi - May 20, 2009, 08:17 PM
Alternative to NSTimer - arekkusu - May 20, 2009, 09:05 PM
Alternative to NSTimer - AnotherJake - May 20, 2009, 09:43 PM
Alternative to NSTimer - warmi - May 20, 2009, 10:27 PM
Alternative to NSTimer - maximile - May 21, 2009, 05:46 AM
Alternative to NSTimer - arekkusu - May 21, 2009, 05:47 AM
Alternative to NSTimer - warmi - May 21, 2009, 07:32 AM
Alternative to NSTimer - AnotherJake - May 21, 2009, 07:35 AM
Alternative to NSTimer - arekkusu - May 21, 2009, 09:24 AM
Alternative to NSTimer - warmi - May 21, 2009, 09:43 AM
Alternative to NSTimer - arekkusu - May 21, 2009, 09:58 AM
Alternative to NSTimer - warmi - May 21, 2009, 10:19 AM
Alternative to NSTimer - DoG - May 22, 2009, 01:39 AM
Alternative to NSTimer - warmi - May 22, 2009, 09:14 AM
Alternative to NSTimer - demonpants - Jun 8, 2009, 02:41 PM
Alternative to NSTimer - reklis - Jul 12, 2009, 01:36 PM
Alternative to NSTimer - maximile - Jul 13, 2009, 06:50 AM
Alternative to NSTimer - mpatric - Jul 13, 2009, 07:10 AM
Alternative to NSTimer - Frank C. - Jul 13, 2009, 11:33 AM
Alternative to NSTimer - longjumper - Jul 13, 2009, 11:44 AM
Alternative to NSTimer - mpatric - Jul 13, 2009, 12:06 PM
Alternative to NSTimer - warmi - Jul 14, 2009, 12:18 AM
Alternative to NSTimer - DoG - Jul 14, 2009, 12:43 AM
Alternative to NSTimer - warmi - Jul 14, 2009, 08:12 AM
Alternative to NSTimer - mpatric - Jul 14, 2009 08:12 AM
Alternative to NSTimer - AnotherJake - Jul 14, 2009, 08:35 AM
Alternative to NSTimer - warmi - Jul 14, 2009, 09:09 AM
Alternative to NSTimer - longjumper - Jul 14, 2009, 09:18 AM
Alternative to NSTimer - warmi - Jul 14, 2009, 09:38 AM
Alternative to NSTimer - AnotherJake - Jul 14, 2009, 09:45 AM
Alternative to NSTimer - AnotherJake - Jul 14, 2009, 09:47 AM
Alternative to NSTimer - DoG - Jul 14, 2009, 01:21 PM
Alternative to NSTimer - reklis - Jan 8, 2010, 08:34 PM
Alternative to NSTimer - riruilo - Jan 11, 2010, 01:52 PM
Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  NSTimer fine, CADisplayLink having some issues monteboyd 5 7,654 Aug 31, 2010 07:05 PM
Last Post: Skorche
  NSTimer hiccups/choppy/jerky jeonghyunhan 2 2,450 Sep 24, 2009 07:35 PM
Last Post: jeonghyunhan
  Using an NSTimer to progressively draw a view StevenD 4 3,742 May 14, 2009 07:57 AM
Last Post: StevenD
  OpenGL render loop - NSTimer vs rendering thread smallstepforman 27 20,745 Feb 2, 2009 10:22 AM
Last Post: ThemsAllTook
  Alternative Input/Control Ideas chrisco 8 3,901 Aug 6, 2008 03:21 PM
Last Post: bruss14