iphone - Actual frequency of device motion updates lower than expected, but scales up with setting -


i porting app wrote using accelerometer ios 3, incorporate new ios 4 motion capabilities.

while capturing motion, application little else - no graphics updates example.

i'm doing following set motion updates, replacement previous use of accelerometer. realize rebuild own polling using nstimer or something, , may pursue yet.

[motionmanager setdevicemotionupdateinterval:updateinterval];
cmdevicemotionhandler motionhandler = ^(cmdevicemotion *motion, nserror *error) {
[self processmotion:motion witherror:error];
};

[motionmanager startdevicemotionupdatestoqueue:[nsoperationqueue currentqueue] withhandler:motionhandler];

this works, update interval doesn't behave expected. i've stripped out execution code in processmotion method, except saving off timestamps in order see real motion update rate is. i've tested enough prove myself it's repeatable, strange result 1/40. table below shows i'm seeing:

 updateinterval  actual events per second 1.0/20.0        13 1.0/30.0        27 1.0/40.0        27 1.0/50.0        34 1.0/60.0        40 1.0/70.0        57 1.0/90.0        60 1.0/100.0      74 

some notes:
1. i'm sure update interval being set properly, , have checked after setting confirm.

2. i'm sure i'm tracking every call of processmotion, there aren't calls being made nil cmdevicemotion or other strangeness

3. i'm not doing significant processing block things, waiting on motion events , recording them. worked fine delegate accelerometer

4. motion data good, infrequently updated :)

5. using ios 4.2 on ipod touch 4th gen

6. i've searched best can, haven't seen explanation, though have seen reports of people seeing 50hz update frequency when requesting 60hz, related.

the next thing i'll try setting dedicated queue processing instead of using current queue, did want see if known behavior. understand if update rate bottlenecked somehow, not sure why still scale shown if case.

again, suppose rebuild use nstimer , own polling, i'd understand why i'm seeing this, in case i'm fundamentally misunderstanding core motion framework.

okay, here's possible solution:

number of concurrent operations on nsoperationqueue determined os. means can few or 1 operation @ time.

you can explicitly set number of operations reasonable number, e.g.

[operationqueue setmaxconcurrentoperationcount:5]; 

enjoy.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -