moai/moai-dev — pull request #682 by Kaali (2013-04-15 16:09:21+00:00)
Title: Fix input lag with the iOS host

iOS host has severe input lag if the frame rate dips below the target and accelerometer is enabled. This can result in a lag of seconds.

This pull request does a bit of an ambitious change, and puts the renderer on its own thread so that the input can get through unblocked. A semaphore blocks the update loop so it won't run if the renderer is drawing.

Another input source, that was previously blocked, is the MOAIKeyboardIOS which can send events to Lua regardless of the semaphore, and can result in a crash if the Lua code changes renderable stuff, such as text. The other commit in this pull request queues input from the keyboard, and pushes them to the listeners at the proper place to prevent crashes.

There probably are other places which might crash the renderer with out of sync changes; which makes this change a bit dangerous, but I still feel it is a necessary one as the input lag can be really severe.