Fix video staying paused after tapping the overlay on mobile#120
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
touchstart/pointerdownin addition toclick/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, soplay()was silently rejected (swallowed by.catch()), and the realclickthat follows a completed tap never got a chance to retry since{once: true}+ the manualremoveEventListenercalls had already torn every listener down.click+keydownonly.clickalready 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 imageCI (click-basedtest-autoplay.jsfor botherror/loadingoverlays, plustest-mobile-fit.js) - unaffected by this change since it already only exercisesclick, not touch.