Input performance with multi touch

Member
Posts: 93
Joined: 2008.11
Post: #1
Hello guys,

background:
I'm running a though loop on the main thread (SINGLE threaded application).
I push the incoming events (like input) using the "while( CFRunLoopRunInMode ... )" construction.
I get all the events working fine. The drawing and the updating is working pretty fast.. somewhere near the 50-60fps. I DON'T limit anything (not scheduling the update/draw to be like 60fps strictly. So in fact it could go up to anything).

the problem:
When I use a single touch it works very fast. No timing issues. But if I do 2 or more fingers it starts to deliver the events with some delay. That delay sometimes is so big that my timing is totally screwed. My game is VERY timing critical and sensitive. I really need to get this fixed.

the question:
How would you explain this behavior? Which steps could I best try to get rid of this? Do I need to limit the FPS strictly to ~60fps maximum (so that the system gets more time to handle the events)? Will the system actually get more time to handle the events if I limit the draw/update invocations?
Would it be better to have the draw/update in a separate thread and the input handling on the main thread?

Thanks in advance!
Alex
Quote this message in a reply
Member
Posts: 93
Joined: 2008.11
Post: #2
Ok, to me it looks like it is in the OS/Hardware.
When I touch the screen with one finger I get the event delivered very fast and the delta between the touch.timestamp and current timestamp is about 0.01-0.02 which is fine for me.
However when I do more than one finger the delta is sometimes more than 1.0 which is of course not acceptable at all.
Most of the time with 3+ fingers the delta is 0.7--1.3 seconds.

I'm yet to test it on a 2nd generation iPhone/iTouch. Still couldn't find one around. If someone has one to test I will be glad to cooperate remotely.

HTH,
Alex
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #3
Have you tried doing this the appropriate way, like having UIApplicationMain's run loop handle events, and received the same results?
Quote this message in a reply
Member
Posts: 93
Joined: 2008.11
Post: #4
Hi lognjumper,

Good input. I tried that now and I can approve that GLSprite still works good and the input no matter how much touches I do is delivered with the same small delta! However I think that if I will add the update/drawing stuff from my game it will get slow again. I will definitely try to do so. I guess the best approach will be doing the update/drawing loop in a separate thread.. at least I will try to do so.
Quote this message in a reply
Member
Posts: 93
Joined: 2008.11
Post: #5
Besides, I have noticed that the FPS is never going higher than 60! And as I told ya already I'm NOT limiting it in any way. When I used to have a separate thread for rendering my FPS sometimes was above the 60. The question is - who limits it to 60 FPS? I guess it's the "while( CFRunLoopRunInMode ... )" construction which uses some kind of timing inside? Could that be true? If so I probably would be better off using a separate thread for my stuff and don't mess with the "while( CFRunLoopRunInMode ... )" thing manually, right?
Quote this message in a reply
Member
Posts: 93
Joined: 2008.11
Post: #6
Ok. Now I kind of have the performance of the input fixed. The thread way didn't help at all. It actually makes things worse - the input works very fast but the graphics are very jumpy when you do your input.
The best compromise in my game was tuning the "seconds" parameter of the CFRunLoopRunInMode routine. Originally I had it set to 0 which means that one run will handle only one source. So if I change this to 0.02 (the best choice in my case) I'm getting the multi touch handled in one single time without a delay! However the graphics are a bit slower.. but that's probably the only possible compromise here on an old iPhone with old 2.0.2 firmware. I guess this code will work much faster on 3G and especially on iTouch 2nd gen.

However, is there any info available covering the differences between 1st gen and 2nd gen iPhone/iTouch models qua hardware?
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #7
You aren't going to see big differences in the different hardwares, and you are limited to 60 FPS because that is the refresh rate of the screen.

Unless you are doing an absolutely insane amount of drawing, chances are, you are just doing something in a way that isn't intended. The general rule of thumb with Cocoa or Cocoa Touch, is if something is difficult, you are probably doing it the wrong way. Smile

You'll have to post some more specifics and possibly some code.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Enable Multi-Touch? MrPenguin9 4 3,819 Mar 14, 2010 12:55 PM
Last Post: MrPenguin9
  Multi-touch failing Sumaleth 1 2,630 Feb 24, 2010 08:49 PM
Last Post: Sumaleth
  Multi touch individual fingers jjslay 3 3,297 Jun 18, 2009 10:01 AM
Last Post: jjslay
  Multi touch response time captainfreedom 12 7,278 May 9, 2009 12:35 PM
Last Post: Frank C.
  Multi Touch wonza 7 5,536 Mar 21, 2009 03:06 AM
Last Post: wonza