In rare bug mode, press any (keyboard) key to mess up cards (`useKeyDown` not unmounted)
tomchen opened this issue · comments
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 unexecuted removeEventListener
and keydown
listener is always there. I don't know why it's not properly unmounted.
arcomage-hd/src/utils/useKeyDown.ts
Lines 19 to 21 in 0df3872
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.