corona
corona copied to clipboard
Simulator performance fix: treat repeated keys as handled
In the simulator, holding the up and down keys will slow things down dramatically in Windows. For instance, throw a few emitters out and do so and they'll draw to a crawl.
This seems to concern this issue.
I don't know why only those keys seem to be affected. It did look like they might get hashed deep in their name lookup maps, but that's just a wild guess.
Anyhow, when repeating keys are detected, Solar is just backing out and trying some fallback logic. I don't know if this is necessarily expensive, but it's probably a pretty noisy event.
Since nothing else is going to handle it, it seems enough to mark this as handled and avoid those costs. (The speed increases substantially.) The Android skin / backspace logic seems to be fine, since that assumes a key up anyhow. (Incidentally, the repeat logic there is probably overkill, what with the key-is-up-and-was-up case.)
I can confirm, after integrating these changes, the simulator no longer experiences FPS drop when holding up or down keys. This PR would resolve https://github.com/coronalabs/corona/issues/358.
Any timeline for getting a review for this to resolve issue #358, @Shchvova & @scottrules44?
@Shchvova I just checked out the pull, and fixes #358 in my testing. Can you look at this or merge this request?