Bug 190794 - Attribute & value allow autoplay not respected for video content with volume after click-to-play
Summary: Attribute & value allow autoplay not respected for video content with volume ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Frames (show other bugs)
Version: Safari 12
Hardware: iPhone / iPad iOS 12
: P2 Major
Assignee: Nobody
URL: https://www.jccrosby.com/playground/h...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-10-22 07:41 PDT by John Crosby
Modified: 2018-10-24 00:01 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.