Title: [250694] trunk/Source/WebCore
- Revision
- 250694
- Author
- jer.no...@apple.com
- Date
- 2019-10-03 18:09:43 -0700 (Thu, 03 Oct 2019)
Log Message
[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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (250693 => 250694)
--- trunk/Source/WebCore/ChangeLog 2019-10-04 00:37:54 UTC (rev 250693)
+++ trunk/Source/WebCore/ChangeLog 2019-10-04 01:09:43 UTC (rev 250694)
@@ -1,3 +1,23 @@
+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 Chris Dumez <cdu...@apple.com>
Allow pages using FontFaceSet to enter the back/forward cache
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (250693 => 250694)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2019-10-04 00:37:54 UTC (rev 250693)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2019-10-04 01:09:43 UTC (rev 250694)
@@ -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: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (250693 => 250694)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2019-10-04 00:37:54 UTC (rev 250693)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2019-10-04 01:09:43 UTC (rev 250694)
@@ -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: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (250693 => 250694)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2019-10-04 00:37:54 UTC (rev 250693)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2019-10-04 01:09:43 UTC (rev 250694)
@@ -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: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (250693 => 250694)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2019-10-04 00:37:54 UTC (rev 250693)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2019-10-04 01:09:43 UTC (rev 250694)
@@ -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