arcomage / arcomage-hd

Web-based, free and open source, remastered 3D clone of 3DO/NWC's 2000 card game Arcomage. 13 languages. Desktop or mobile Android iOS. Online or offline PWA. Against AI or Multiplayer (w/o server). 🧝👾🃏 (ts+react+redux+rxjs, CSS-based anim, WebRTC)

Home Page:https://arcomage.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

return () => {
window.removeEventListener('keydown', handleKeyDown)
}

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.