Skip to content

Fix video staying paused after tapping the overlay on mobile#120

Merged
modem7 merged 2 commits into
masterfrom
fix/mobile-tap-unmute
Jul 7, 2026
Merged

Fix video staying paused after tapping the overlay on mobile#120
modem7 merged 2 commits into
masterfrom
fix/mobile-tap-unmute

Conversation

@modem7

@modem7 modem7 commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Video would autoplay muted and show the decoy overlay correctly on mobile, but tapping it left the video paused forever instead of unmuting/playing.
  • Root cause: the reveal listener was attached to touchstart/pointerdown in addition to click/keydown. Those fire the instant a finger touches the screen, before the browser knows whether it's a tap or the start of a scroll/drag - WebKit doesn't treat that as a strong enough gesture to permit unmuted playback, so play() was silently rejected (swallowed by .catch()), and the real click that follows a completed tap never got a chance to retry since {once: true} + the manual removeEventListener calls had already torn every listener down.
  • Fix: drop to click + keydown only. click already fires for both a genuine mouse click and, on touch devices, the synthetic click a browser dispatches after a completed tap - same mechanism that already made desktop work correctly.

Test plan

  • Test image CI (click-based test-autoplay.js for both error/loading overlays, plus test-mobile-fit.js) - unaffected by this change since it already only exercises click, not touch.
  • Manual check on a real phone that tapping the overlay now unmutes and plays.

modem7 added 2 commits July 7, 2026 18:31
touchstart/pointerdown fire the instant a finger touches the screen,
before the browser knows it's a tap rather than the start of a
scroll/drag. WebKit doesn't treat that as a strong enough gesture to
permit unmuted playback, so play() was silently rejected there, and
the click that follows never got a retry since {once: true} plus the
manual removeEventListener calls had already torn every listener down.
Drop to click + keydown only - click already fires for a completed tap
on touch devices, same as a real mouse click on desktop.
Firefox is the most divergent of the mainstream browsers on autoplay
gesture policy enforcement, so it's worth checking independently of
Chromium rather than assuming one implies the other. Parameterize
test-autoplay.js to take a browser engine and run both overlay checks
under each.
@modem7 modem7 merged commit 4491b9d into master Jul 7, 2026
3 checks passed
@modem7 modem7 deleted the fix/mobile-tap-unmute branch July 7, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant