Bug 190794

Summary: Attribute & value allow autoplay not respected for video content with volume after click-to-play
Product: WebKit Reporter: John Crosby <john.crosby>
Component: FramesAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Major CC: jer.noble, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 12   
Hardware: iPhone / iPad   
OS: iOS 12   
URL: https://www.jccrosby.com/playground/html-player/iframe-embed.html

Description John Crosby 2018-10-22 07:41:32 PDT
An iframe added to the DOM with the 'allow="autoplay"' attribute and value in response to a user click event will not auto play video content with volume.

*On iPad iOS 12.0.1 in Safari or Chrome*

- Expected results: When the user clicks on the play button, the video plays with sound
- Actual results: When the user clicks on the play button, the video is blocked from autoplaying 


The provided example below illustrates the issue. I've also provided the sample here: https://github.mlbam.net/pages/jcrosby/html-player-test/iframe-embed.html


*simple-video.html*

<video controls playsinline autoplay
    src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
    width="480" height="270"></video>


*iframe-embed.html*

<button id="play-btn">PLAY</button>
<div id="video-container"></div>

<script>

    document.addEventListener('DOMContentLoaded', function() {

        var videoCntr = document.getElementById('video-container');
        var playBtn = document.getElementById('play-btn');
        var ifm = document.createElement('iframe');

        ifm.setAttribute('src', '/simple-video.html');
        ifm.setAttribute('allow', 'autoplay');
        ifm.setAttribute('scrolling', 'no');
        ifm.setAttribute('width', 480);
        ifm.setAttribute('height', 270);

        playBtn.addEventListener('click', function(event) {

            videoCntr.appendChild(ifm);

        });

    });

</script>
Comment 1 John Crosby 2018-10-22 08:47:12 PDT
Public sample page: https://www.jccrosby.com/playground/test-html-playback/iframe-embed.html
Comment 2 Alexey Proskuryakov 2018-10-22 14:53:37 PDT
Thank you for the report! Could you please confirm whether this was happening in earlier iOS version, or new in iOS 12?
Comment 3 Radar WebKit Bug Importer 2018-10-22 14:54:14 PDT
<rdar://problem/45467412>
Comment 4 John Crosby 2018-10-22 15:12:22 PDT
Seems new in iOS 12.
Comment 5 Jer Noble 2018-10-24 00:01:54 PDT
I suspect that this has nothing to do with "allow=autoplay", since we do not honor that attribute. Instead, I suspect that the iframe does not actually load simple-video.html synchronously when added to the DOM, and thus the video element isn't created within an active user gesture.

In other words, it's surprising that this ever worked, and I don't anticipate that we will fix this.