Serendib
08-28-2022, 10:36 PM
This was driving me NUTS for so long. I recently have a problem where I would sometimes be mouse turning while running and the game would lag with a frame skip, sometimes very slight, sometimes up to a half a second. I had no idea what was causing this.
Then I realized that I got a new mouse, and I remembered an ancient bug I once found when writing my own game engine:
The mouse polling rate was set too high.
As soon as I turned down my mouse polling rate from 1000 to 125, all my issues disappeared. Here is how to do it in the Razer Synapse settings menu:
https://i.imgur.com/itdaUjf.png
The reason for this happening is kind of technical, but here it is: Inside the main event processing game loop for some games (and it turns out, titanium) there's code like this:
Event e;
while (nextEvent(e))
{
// do things with the event
}
The high polling rate of the mouse (if moved at the correct speed) causes this queue to fill up faster than it can be processed on the same frame. Meaning you manage to move your mouse at the unlucky speed it could actually cause this to loop forever while your mouse is still moving.
Anyways - that's the fix. If you notice your game skipping frames while you mouse turn, try turning down your mouse poll rate.
Then I realized that I got a new mouse, and I remembered an ancient bug I once found when writing my own game engine:
The mouse polling rate was set too high.
As soon as I turned down my mouse polling rate from 1000 to 125, all my issues disappeared. Here is how to do it in the Razer Synapse settings menu:
https://i.imgur.com/itdaUjf.png
The reason for this happening is kind of technical, but here it is: Inside the main event processing game loop for some games (and it turns out, titanium) there's code like this:
Event e;
while (nextEvent(e))
{
// do things with the event
}
The high polling rate of the mouse (if moved at the correct speed) causes this queue to fill up faster than it can be processed on the same frame. Meaning you manage to move your mouse at the unlucky speed it could actually cause this to loop forever while your mouse is still moving.
Anyways - that's the fix. If you notice your game skipping frames while you mouse turn, try turning down your mouse poll rate.