I'm building RKMovies ( a tiny 4K player for old phones ) — 0.91 MB APK, hardware decode, no accounts, no tracking. The player UI runs on ArtPlayer v5, and I replaced its default controls with my own auto-hide layer. That layer flickered for weeks. Here's why.
ArtPlayer hides its controls on its own timer. Every timeupdate it checks controls.timer ; if the controls have been idle for a few seconds it hides them and hides the cursor.
I wanted different rules: never hide while the settings panel is open, while paused, or while the user is scrubbing, plus a minimum visible time of 1s. So I added my own hideTimer (3.5s) with those guards.
Two timers, two sources of truth. ArtPlayer's internal check and my setTimeout disagreed about when to hide, so the controls flickered: my layer showed them, the library's next timeupdate hid them, mine showed them again.
The fix wasn't a second timer fighting the first. It was a 1.5s immunity lock.…