New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub Msg is lost when a subscription triggers twice rapidly #609

Closed
dancras opened this Issue May 17, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@dancras

dancras commented May 17, 2016

I have written a module to keep track of the state of the keyboard arrow keys using the Keyboard.ups and Keyboard.downs subscriptions. The problem is when two "keyup" events occur rapidly, the second Msg does not make it to the update function.

The function mapping the subscription data (keyCode) to a Msg is run for both occurrences, but somewhere between this and the update function the second "keyup" event's Msg is lost.

I've tagged my project at a point where the issue is easy to reproduce with some debug logging. Holding down the left and right arrow key, then quickly releasing both will result in the one of the arrow keys getting stuck in the down state due to the lost Msg.

Main.elm:835 lstate: KeyDown
Main.elm:835 update: LeftKeyChange KeyDown
Main.elm:835 rstate: KeyDown
Main.elm:835 update: RightKeyChange KeyDown
-- repeated events from holding right key removed
Main.elm:835 rstate: KeyUp
Main.elm:835 lstate: KeyUp
Main.elm:835 update: RightKeyChange KeyUp

https://github.com/dancras/eggdude-elm/tree/debug-skipped-messages
https://github.com/dancras/eggdude-elm/blob/debug-skipped-messages/src/ArrowKeys.elm

I'm using OS X Chrome Version 50.0.2661.94 (64-bit)

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz May 19, 2016

Member

Thanks for the example and fix! Should be fixed by elm-lang@cce1dc5 and coming out soon.

Member

evancz commented May 19, 2016

Thanks for the example and fix! Should be fixed by elm-lang@cce1dc5 and coming out soon.

@evancz evancz closed this May 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment