Title: [250828] branches/safari-608.3.10.0-branch/Source/WebCore
Revision
250828
Author
alanc...@apple.com
Date
2019-10-08 09:00:00 -0700 (Tue, 08 Oct 2019)

Log Message

Cherry-pick r250694. rdar://problem/56061133

    [iOS] WebContent process can be interrupted during suspension; loses "Now Playing" status
        https://bugs.webkit.org/show_bug.cgi?id=202537
        <rdar://problem/55952707>

        Reviewed by Eric Carlson.

        Always deactivate the AVAudioSession when the last playing PlatformAudioSession ends playback and the application is in the background.

        * platform/audio/PlatformMediaSessionManager.cpp:
        (WebCore::PlatformMediaSessionManager::removeSession):
        (WebCore::PlatformMediaSessionManager::processWillSuspend):
        (WebCore::PlatformMediaSessionManager::maybeDeactivateAudioSession):
        * platform/audio/PlatformMediaSessionManager.h:
        (WebCore::PlatformMediaSessionManager::isApplicationInBackground const):
        * platform/audio/ios/MediaSessionManagerIOS.h:
        * platform/audio/ios/MediaSessionManagerIOS.mm:
        (WebCore::MediaSessionManageriOS::sessionWillEndPlayback):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250694 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-608.3.10.0-branch/Source/WebCore/ChangeLog (250827 => 250828)


--- branches/safari-608.3.10.0-branch/Source/WebCore/ChangeLog	2019-10-08 15:51:03 UTC (rev 250827)
+++ branches/safari-608.3.10.0-branch/Source/WebCore/ChangeLog	2019-10-08 16:00:00 UTC (rev 250828)
@@ -1,3 +1,49 @@
+2019-10-08  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r250694. rdar://problem/56061133
+
+    [iOS] WebContent process can be interrupted during suspension; loses "Now Playing" status
+        https://bugs.webkit.org/show_bug.cgi?id=202537
+        <rdar://problem/55952707>
+    
+        Reviewed by Eric Carlson.
+    
+        Always deactivate the AVAudioSession when the last playing PlatformAudioSession ends playback and the application is in the background.
+    
+        * platform/audio/PlatformMediaSessionManager.cpp:
+        (WebCore::PlatformMediaSessionManager::removeSession):
+        (WebCore::PlatformMediaSessionManager::processWillSuspend):
+        (WebCore::PlatformMediaSessionManager::maybeDeactivateAudioSession):
+        * platform/audio/PlatformMediaSessionManager.h:
+        (WebCore::PlatformMediaSessionManager::isApplicationInBackground const):
+        * platform/audio/ios/MediaSessionManagerIOS.h:
+        * platform/audio/ios/MediaSessionManagerIOS.mm:
+        (WebCore::MediaSessionManageriOS::sessionWillEndPlayback):
+    
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250694 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-10-03  Jer Noble  <jer.no...@apple.com>
+
+        [iOS] WebContent process can be interrupted during suspension; loses "Now Playing" status
+        https://bugs.webkit.org/show_bug.cgi?id=202537
+        <rdar://problem/55952707>
+
+        Reviewed by Eric Carlson.
+
+        Always deactivate the AVAudioSession when the last playing PlatformAudioSession ends playback and the application is in the background.
+
+        * platform/audio/PlatformMediaSessionManager.cpp:
+        (WebCore::PlatformMediaSessionManager::removeSession):
+        (WebCore::PlatformMediaSessionManager::processWillSuspend):
+        (WebCore::PlatformMediaSessionManager::maybeDeactivateAudioSession):
+        * platform/audio/PlatformMediaSessionManager.h:
+        (WebCore::PlatformMediaSessionManager::isApplicationInBackground const):
+        * platform/audio/ios/MediaSessionManagerIOS.h:
+        * platform/audio/ios/MediaSessionManagerIOS.mm:
+        (WebCore::MediaSessionManageriOS::sessionWillEndPlayback):
+
 2019-10-03  Kocsen Chung  <kocsen_ch...@apple.com>
 
         Cherry-pick r250642. rdar://problem/55947639

Modified: branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (250827 => 250828)


--- branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2019-10-08 15:51:03 UTC (rev 250827)
+++ branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2019-10-08 16:00:00 UTC (rev 250828)
@@ -166,10 +166,7 @@
         m_remoteCommandListener = nullptr;
         m_audioHardwareListener = nullptr;
 #if USE(AUDIO_SESSION)
-        if (m_becameActive && shouldDeactivateAudioSession()) {
-            AudioSession::sharedSession().tryToSetActive(false);
-            m_becameActive = false;
-        }
+        maybeDeactivateAudioSession();
 #endif
     }
 
@@ -363,16 +360,14 @@
         return;
     m_processIsSuspended = true;
 
+    ALWAYS_LOG(LOGIDENTIFIER);
+
     forEachSession([&] (auto& session) {
         session.client().processIsSuspendedChanged();
     });
 
 #if USE(AUDIO_SESSION)
-    if (m_becameActive && shouldDeactivateAudioSession()) {
-        AudioSession::sharedSession().tryToSetActive(false);
-        ALWAYS_LOG(LOGIDENTIFIER, "tried to set inactive AudioSession");
-        m_becameActive = false;
-    }
+    maybeDeactivateAudioSession();
 #endif
 }
 
@@ -545,6 +540,18 @@
     });
 }
 
+#if USE(AUDIO_SESSION)
+void PlatformMediaSessionManager::maybeDeactivateAudioSession()
+{
+    if (!m_becameActive || !shouldDeactivateAudioSession())
+        return;
+
+    ALWAYS_LOG(LOGIDENTIFIER, "tried to set inactive AudioSession");
+    AudioSession::sharedSession().tryToSetActive(false);
+    m_becameActive = false;
+}
+#endif
+
 static bool& deactivateAudioSession()
 {
     static bool deactivate;

Modified: branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (250827 => 250828)


--- branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2019-10-08 15:51:03 UTC (rev 250827)
+++ branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2019-10-08 16:00:00 UTC (rev 250828)
@@ -149,6 +149,11 @@
 
     AudioHardwareListener* audioHardwareListener() { return m_audioHardwareListener.get(); }
 
+    bool isApplicationInBackground() const { return m_isApplicationInBackground; }
+#if USE(AUDIO_SESSION)
+    void maybeDeactivateAudioSession();
+#endif
+
 #if !RELEASE_LOG_DISABLED
     const Logger& logger() const final { return m_logger; }
     const void* logIdentifier() const final { return nullptr; }

Modified: branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (250827 => 250828)


--- branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2019-10-08 15:51:03 UTC (rev 250827)
+++ branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2019-10-08 16:00:00 UTC (rev 250828)
@@ -62,6 +62,7 @@
 
     void configureWireLessTargetMonitoring() override;
     void providePresentingApplicationPIDIfNecessary() final;
+    void sessionWillEndPlayback(PlatformMediaSession&) final;
 
 #if !RELEASE_LOG_DISABLED
     const char* logClassName() const final { return "MediaSessionManageriOS"; }

Modified: branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (250827 => 250828)


--- branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2019-10-08 15:51:03 UTC (rev 250827)
+++ branches/safari-608.3.10.0-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2019-10-08 16:00:00 UTC (rev 250828)
@@ -190,6 +190,16 @@
 #endif
 }
 
+void MediaSessionManageriOS::sessionWillEndPlayback(PlatformMediaSession& session)
+{
+    MediaSessionManagerCocoa::sessionWillEndPlayback(session);
+
+#if USE(AUDIO_SESSION)
+    if (isApplicationInBackground() && !anyOfSessions([] (auto& session) { return session.state() == PlatformMediaSession::Playing; }))
+        maybeDeactivateAudioSession();
+#endif
+}
+
 void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to