Bug 163993

Summary: Autoplay muted videos stop playback of any streaming app in the background
Product: WebKit Reporter: Ibrahim Ennafaa <ibrahim>
Component: MediaAssignee: Jer Noble <jer.noble>
Status: RESOLVED FIXED    
Severity: Critical CC: commit-queue, eric.carlson, ibrahim, jer.noble, jonlee, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 10   
Hardware: iPhone / iPad   
OS: iOS 10   
See Also: https://bugs.webkit.org/show_bug.cgi?id=177920
Attachments:
Description Flags
Patch
eric.carlson: review+
Patch for landing
none
Patch for landing
none
Patch for landing none

Description Ibrahim Ennafaa 2016-10-25 16:00:06 PDT
Summary:
We use autoplay inline muted videos as introduced in iOS10 by Safari browsers. However, when an app is streaming music in the background and we start the video (even muted), the playback of the background app is stopped.
In a recent blogpost on the Webkit blog (https://webkit.org/blog/6784/new-video-policies-for-ios/), these new features were named as a way to replace the animated GIF format. But for the moment, the user experience is disappointing when it comes to this use case. Many of our users are complaining. 

Steps to Reproduce:
1. Open any background streaming sound app 
2. Play a sound
3. Press home button (sound is still playing in the background)
4. Open Safari and load http://misc.teads.tv/demo/product/breitlingWithLogo.html
5. Scroll until you see the video (it will automatically start)

Expected Results:
A good user experience would be to stop the playback only if we activate the sound on the video (user initiated). I guess this is why the requirements around autoplay videos are to have the video muted at start and un-muted only after a user action.

We would expect that a playing muted video doesn't disrupt with a streaming background app playback as long as the video stays muted.

Actual Results:
The playback of the streaming sound app is stopped when the muted video starts on Safari. 

Version:
Safari 10.0 (iOS10)
Comment 1 Radar WebKit Bug Importer 2016-10-30 18:25:43 PDT
<rdar://problem/29020431>
Comment 2 Ibrahim Ennafaa 2016-11-14 12:10:27 PST
Hi,

Is there any feedback on this issue? It is becoming more and more a blocker on our side and for our publishers.

Here is another test page with a simple video tag on which we have the exact same issue: http://misc.teads.tv.s3.amazonaws.com/demo/product/test-webkit/video.html

Steps:
- Run a sound streaming app
- Sound is playing in background
- Launch Safari with the link above
- Video is started muted and the streaming app is stopped!

Thanks for your help
Comment 3 Jon Lee 2016-11-15 01:18:12 PST
We are aware of the issue and hope to look into it soon.
Comment 4 Ibrahim Ennafaa 2016-11-30 05:19:08 PST
Thanks Jon,

Do you have any precision on a ETA for this issue to be fixed? 

This is becoming a blocker on our side and many publishers & users are complaining.

Is there anything we could do or anyone we could reach out to and get more visibility on the process?

Best,
Ibrahim
Comment 5 Ibrahim Ennafaa 2016-12-15 06:07:17 PST
FYI the bug existed also on Chrome Android. It was fixed since : https://bugs.chromium.org/p/chromium/issues/detail?id=638463

It could help since Chrome is using a fork of Webkit ...

Jon, any news on the prioritization of this bugfix?
Comment 6 Ibrahim Ennafaa 2017-01-26 05:03:26 PST
Hi everyone,

Is there any update?

Thanks,
Ibrahim
Comment 7 Jer Noble 2017-01-26 08:48:33 PST
Hi Ibrahim, 

There's been some work done in https://bugs.webkit.org/show_bug.cgi?id=166347, but there's still more to do. I'll keep you updated here.
Comment 8 Jer Noble 2017-01-26 11:43:04 PST
Created attachment 299829 [details]
Patch
Comment 9 Eric Carlson 2017-01-26 11:54:20 PST
Comment on attachment 299829 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=299829&action=review

> Source/WebCore/html/HTMLMediaElement.cpp:6851
> +    if (m_isPlayingToWirelessTarget)
> +        return true;

This is obvious, so it is probably worth adding a comment to make sure this isn't accidentally changed in the future.

> Tools/TestWebKitAPI/Tests/WebKit/ios/video-with-muted-audio-and-webaudio.html:11
> +            function go() {
> +                var audioContext = new webkitAudioContext();
> +                audioContext.resume();
> +
> +                var video = document.getElementsByTagName('video')[0];
> +                video.play().then(playing).catch(notPlaying);
> +            }

Nit: funky indentation.
Comment 10 Jer Noble 2017-01-26 12:36:41 PST
Created attachment 299834 [details]
Patch for landing
Comment 11 Jer Noble 2017-01-26 14:17:14 PST
Created attachment 299854 [details]
Patch for landing
Comment 12 Jer Noble 2017-01-26 14:46:33 PST
Created attachment 299858 [details]
Patch for landing
Comment 13 WebKit Commit Bot 2017-01-26 16:39:42 PST
Comment on attachment 299858 [details]
Patch for landing

Clearing flags on attachment: 299858

Committed r211240: <http://trac.webkit.org/changeset/211240>
Comment 14 Ibrahim Ennafaa 2017-03-15 15:27:59 PDT
Hi,

Do you have an idea of when this fix is going to be released? Which iOS version will have it included?

Best,
Ibrahim
Comment 15 Jon Lee 2017-03-16 01:19:34 PDT
(In reply to comment #14)
> Do you have an idea of when this fix is going to be released? Which iOS
> version will have it included?

We don't discuss release schedules.
Comment 16 Ibrahim Ennafaa 2017-03-16 12:44:49 PDT
Thanks Jon,

Is there a way to get notified when the fix is going to be deployed?

It is kind of difficult for us to communicate with our clients if we don't have more information about the fix deploy. They are using our technology which is affected by this bug.

We appreciate the communication and the work done here.

Ibrahim
Comment 17 Jon Lee 2017-10-05 00:27:37 PDT
Not sure why this is still in "new". Moving to "resolved". The fix is in iOS 11.

That said we're getting reports that this is still happening. If that is still the case, please follow b177920.
Comment 18 Ibrahim Ennafaa 2017-10-13 13:20:54 PDT
Hi guys,

It looks like there was a regression on this bug. It reappeared with iOS11. It was fixed in one of the iOS 10.x versions. But now  we have the exact same issue with iOS11.

Thanks,
Ibrahim
Comment 19 Jon Lee 2017-10-13 13:52:11 PDT
Moving back to resolved. We're tracking additional fixed in 177920.