In the cross platform game I support the mac code on, since a few months ago people are reporting odd stutters while using the mouse. I investigated and found that calling

for(;;)
{
  UnsignedWide time;
  Microseconds(&time);

NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];

  UnsignedWide time2;
  Microseconds(&time2);

unsigned long msecs = (*(unsigned long long*)&time2)-(*(unsigned long long*)&time);
  printf("%ld, %d / ", msecs, nnn++);

  if(!event)
  {
    printf("\n");
  }
  if(!event) break;

  ... process event
}

(note the debugging code isn't in the live game) takes (on my g5) around 0.5ms for no event, but when there is a mouse moved event it can take anywhere from 2 to 20 ms just for 1 call. Does anyone have any idea why this would be? Oddly enough its not 100% of the time and not for everyone but is fairly common. The result is that the frame where this call is made sticks. The game is backwards (I didn't write it) and each game loop calls the above code to obtain mouse and keyboard events to control the avatar in the game. However this exact code worked flawlessly for years until just a few months ago, which makes 0 sense. The problem occurs in both slow macs and fast macs with fps from 8 to 80.

Interesting enough if there are many events pending (like key repeats) the first (usually the mouse event) takes a long time, then the remaining don't take very long usually.

I tried both with and without mouse coalescing but it didn't help.

This is driving me nuts. If it wasn't such a pain in the butt I would use a regular main event loop and run the game on a timer, but it might still have this "slow" issue.

Any help is very appreciated!

- andrew
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to