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.
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.
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.
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.
<rdar://problem/33974383>
Created attachment 318657 [details] Patch
Comment on attachment 318657 [details] Patch Attachment 318657 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/4355274 New failing tests: media/video-restricted-invisible-autoplay-not-allowed.html media/video-restricted-invisible-autoplay-allowed-if-audible.html
Created attachment 318664 [details] Archive of layout-test-results from ews100 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Comment on attachment 318657 [details] Patch Attachment 318657 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/4355342 New failing tests: media/video-restricted-invisible-autoplay-not-allowed.html media/video-restricted-invisible-autoplay-allowed-if-audible.html
Created attachment 318666 [details] Archive of layout-test-results from ews106 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
Comment on attachment 318657 [details] Patch Attachment 318657 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/4355333 New failing tests: media/video-concurrent-visible-playback.html media/video-restricted-invisible-autoplay-not-allowed.html media/video-restricted-invisible-autoplay-allowed-if-audible.html
Created attachment 318668 [details] Archive of layout-test-results from ews113 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews113 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Comment on attachment 318657 [details] Patch Attachment 318657 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/4355381 New failing tests: media/video-restricted-invisible-autoplay-not-allowed.html media/video-restricted-invisible-autoplay-allowed-if-audible.html
Created attachment 318669 [details] Archive of layout-test-results from ews125 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews125 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.5
Created attachment 318699 [details] Patch
Comment on attachment 318699 [details] Patch Clearing flags on attachment: 318699 Committed r221016: <http://trac.webkit.org/changeset/221016>
All reviewed patches have been landed. Closing bug.