Closed tomchen closed 2 years ago
I understand now. If "Preferences" window is somehow still there when EndScreen
appears, and user clicks "Apply & New Game" button before endScreenExitableDelay
, then the keydown
listener won't be removed and will always be there.
Very rare "bug mode" which is very hard to reproduce. Maybe violently press F? or AudioVolume? key to enter the "mode".
In this "bug mode", user can press any key, letter, number, F?, etc. to re-deal cards which appear in a very messy order and usually outside the screen. And dev console shows warnings:
?? executed during the lock ??. the game will try to fix that.
When the bug occurs, starting a new game of course won't get rid of the bug, user must reload the page to have a normal game back.
In the "bug mode", if user start a new game and only uses mouse and not keyboard, then everything appears to be good.
Although I don't know exactly when the bug could appear, it's likely due to
useKeyDown
that is not properly unmounted in EndScreen which results in unexecutedremoveEventListener
andkeydown
listener is always there. I don't know why it's not properly unmounted.https://github.com/arcomage/arcomage-hd/blob/0df38726efe99ba7313b4c3b28ed7c872f76fefb/src/utils/useKeyDown.ts#L19-L21