Bug 175748 - Autoplay Muted Videos Don't Play When Outside Viewport
Summary: Autoplay Muted Videos Don't Play When Outside Viewport
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Other
Hardware: iPhone / iPad iOS 11
: P2 Normal
Assignee: Jer Noble
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-08-18 17:45 PDT by Neil Daniels
Modified: 2017-08-22 09:13 PDT (History)
6 users (show)

See Also:


Attachments
Webarchive of mentioned test case. (354.91 KB, application/x-webarchive)
2017-08-18 17:45 PDT, Neil Daniels
no flags Details
Patch (6.13 KB, patch)
2017-08-21 12:09 PDT, Jer Noble
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-elcapitan (1.20 MB, application/zip)
2017-08-21 13:05 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews106 for mac-elcapitan-wk2 (1.38 MB, application/zip)
2017-08-21 13:33 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews113 for mac-elcapitan (2.15 MB, application/zip)
2017-08-21 13:40 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews125 for ios-simulator-wk2 (10.63 MB, application/zip)
2017-08-21 13:56 PDT, Build Bot
no flags Details
Patch (8.88 KB, patch)
2017-08-21 16:57 PDT, Jer Noble
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Daniels 2017-08-18 17:45:38 PDT
Created attachment 318565 [details]
Webarchive of mentioned test case.

I have various <video autoplay loop muted playsinline> on a single page, on iOS 11 (15A5354b, iPhone and iPad) only the videos that are within the viewport automatically play.

A test case exists at this page: https://www.fomopop.com/html5-video-test/ (a webarchive is attached as well, for posterity). If you view on an iPhone running iOS 10.x, all 5 of the videos will play. On an iPhone running iOS 11 (15A5354b), only the first 2 videos will play.

This might be related to https://bugs.webkit.org/show_bug.cgi?id=170610 , but I'm not sure if that's in a public iOS build yet.
Comment 1 Jer Noble 2017-08-18 17:49:25 PDT
It's actually more likely related to <https://bugs.webkit.org/show_bug.cgi?id=168268>, as it seems to only happen with <video><source /></video> elements, and not <video src=""></video> elements.
Comment 2 Jer Noble 2017-08-18 17:50:35 PDT
It looks like we're not calling prepareForLoad() in the <source /> selection case; prepareForLoad() is what sets the state PlatformSessionManager state to Autoplaying, thus breaking restoring that state to Autoplaying when becoming visible again.
Comment 3 Jer Noble 2017-08-18 18:02:29 PDT
Aha, we set the PlatformMediaSession's state to Autoplaying inside prepareForLoad(), which also sets the m_autoplaying flag to true (as specified in the "media element load algorithm" section of the HTML spec.  But the autoplaying flag is initially true (as specified in just before same), so we should probably notify the client that we're autoplaying on HTMLMediaElement creation.
Comment 4 Radar WebKit Bug Importer 2017-08-18 18:16:41 PDT
<rdar://problem/33974383>
Comment 5 Jer Noble 2017-08-21 12:09:03 PDT
Created attachment 318657 [details]
Patch
Comment 6 Build Bot 2017-08-21 13:05:00 PDT Comment hidden (obsolete)
Comment 7 Build Bot 2017-08-21 13:05:01 PDT Comment hidden (obsolete)
Comment 8 Build Bot 2017-08-21 13:33:31 PDT Comment hidden (obsolete)
Comment 9 Build Bot 2017-08-21 13:33:32 PDT Comment hidden (obsolete)
Comment 10 Build Bot 2017-08-21 13:40:43 PDT Comment hidden (obsolete)
Comment 11 Build Bot 2017-08-21 13:40:44 PDT Comment hidden (obsolete)
Comment 12 Build Bot 2017-08-21 13:56:30 PDT Comment hidden (obsolete)
Comment 13 Build Bot 2017-08-21 13:56:33 PDT Comment hidden (obsolete)
Comment 14 Jer Noble 2017-08-21 16:57:51 PDT
Created attachment 318699 [details]
Patch
Comment 15 WebKit Commit Bot 2017-08-22 09:13:26 PDT
Comment on attachment 318699 [details]
Patch

Clearing flags on attachment: 318699

Committed r221016: <http://trac.webkit.org/changeset/221016>
Comment 16 WebKit Commit Bot 2017-08-22 09:13:27 PDT
All reviewed patches have been landed.  Closing bug.