moai/moai-dev — Issue #169: Touches linger between sessions (copied from moai-beta)
Author: jlytledistinctdev
Created: 2012-03-06 23:43:43+00:00
State: open

Under the right conditions, touches linger after the app is backgrounded on iOS, and then are delivered to Lua via the callbacks with many of the values as nil immediately upon resuming. I'll attach some test code that demonstrates this case. To reproduce, just add the follow code to the anim-basic sample, by putting a print statement in it for each of its parameters like so:

MOAIInputMgr.device.touch:setCallback (
function ( eventType, index, x, y, tapCount )
print ( eventType, index, x, y, tapCount )
end
)

You then run on a device, then drag your finger around constantly. While dragging, hit the home key. Then, watch the console output and reopen the app on the device. Sometimes you'll see a new print out (or multiple) that have nil values for many of the parameters. That's your repro case. I'd suggest that the queue of touch events be cleared out as this bug can cause some pretty serious issues in the right conditions.

Here's an example of what you'll see in your console if you reproduce the error. Note the final line, which indicates the error:

1 0 247 545 1
1 0 252 557 1
1 0 256 561 1
1 0 256 562 1
1 0 261 563 1
1 0 267 563 1
1 0 276 561 1
1 0 294 552 1
1 0 304 550 1
1 0 309 549 1
1 0 311 549 1
1 0 311 537 1
1 0 301 510 1
1 0 284 487 1
1 0 271 476 1
1 0 260 471 1
1 0 251 467 1
1 0 242 461 1
1 0 230 457 1
1 0 216 449 1
1 0 199 441 1
3 nil nil nil nil