Summary: | Autoplay muted videos still stop playback of other streaming apps in the background | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Jon Lee <jonlee> | ||||||||
Component: | Media | Assignee: | Jer Noble <jer.noble> | ||||||||
Status: | RESOLVED FIXED | ||||||||||
Severity: | Normal | CC: | commit-queue, eric.carlson, ibrahim, jeremyj-wk, jer.noble, mizmaar3, nourdine.dahmani, webkit-bug-importer | ||||||||
Priority: | P2 | Keywords: | InRadar | ||||||||
Version: | Safari 11 | ||||||||||
Hardware: | Unspecified | ||||||||||
OS: | iOS 11 | ||||||||||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=163993 | ||||||||||
Attachments: |
|
Description
Jon Lee
2017-10-05 00:26:48 PDT
Hi guys, It looks like there was a regression on this bug. It reappeared with iOS11. Where can I follow its resolution? Is there another ticket to follow? Thanks, Ibrahim The underlying cause seems to be the order in which HTMLMediaElement ivars are constructed. The MediaElementSession is created before m_isPlayingToWirelessTarget is initialized to false (so therefore, is sometimes true), and when it checks whether the element canProduceAudio(), that check will sometimes return true (because m_isPlayingToWirelessTarget is true). TL,DR: other audio is being interrupted because the PlatformMediaSessionManager thinks the media element is AirPlaying. *** Bug 178743 has been marked as a duplicate of this bug. *** Created attachment 324712 [details]
Patch
Comment on attachment 324712 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=324712&action=review > Source/WebCore/html/HTMLMediaElement.cpp:489 > +void HTMLMediaElement::setMediaSession(std::unique_ptr<MediaElementSession>&& mediaSession) Why do some of the initialization in the constructor and some here? Why not call this something like "finishSetup" and move everything from the constructor here. Alternatively, instead of requiring the derived classes to create and pass a media session, you can call this "createMediaSession" and allocate the session here. Comment on attachment 324712 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=324712&action=review >> Source/WebCore/html/HTMLMediaElement.cpp:489 >> +void HTMLMediaElement::setMediaSession(std::unique_ptr<MediaElementSession>&& mediaSession) > > Why do some of the initialization in the constructor and some here? Why not call this something like "finishSetup" and move everything from the constructor here. > > Alternatively, instead of requiring the derived classes to create and pass a media session, you can call this "createMediaSession" and allocate the session here. Yeah, I considered doing the first option; making a virtual "void initialize()" function that did all this. I'll look into this. Created attachment 324735 [details]
Patch for landing
Comment on attachment 324735 [details] Patch for landing View in context: https://bugs.webkit.org/attachment.cgi?id=324735&action=review > Source/WebCore/ChangeLog:18 > + own ivars (much less their vtables). So instead, we'll create and set the MediaElementSession > + in the HTMLVideoElement and HTMLAudioElement's create() factory methods. Nit: this should be updated. Created attachment 324827 [details]
Patch for landing
Comment on attachment 324827 [details] Patch for landing Clearing flags on attachment: 324827 Committed r223960: <https://trac.webkit.org/changeset/223960> All reviewed patches have been landed. Closing bug. Hi, Do you have an idea of when the patch will be available to the public and which iOS version will benefit? Hi, could we please get any information about the delivery of this fix? That could be very helpful. It is something that could be expected in the coming days? If you have an Apple Developer account, you can test out this fix on the latest beta seed of macOS 10.13.2 and iOS 11.2. I noticed if there are multiple videos on a page and any of the video does not have `muted=true` but have autoplay and playsinline enabled, the background app paused if a video which have muted, playsinline, autoplay attributes starts playing. The sequence of videos does not matters: https://jsfiddle.net/msta5bcr/ it can be reproduce here where first video have muted=true and will autoplay while a video down below the page dont have muted=true, and if Spotify is playing music in background the iPhone will pause it. |