Changeset 243958 in webkit
- Timestamp:
- Apr 5, 2019, 6:08:50 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/platform/mac/media/audio-session-deactivated-when-suspended-expected.txt (added)
-
LayoutTests/platform/mac/media/audio-session-deactivated-when-suspended.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (modified) (3 diffs)
-
Source/WebCore/platform/audio/PlatformMediaSessionManager.h (modified) (5 diffs)
-
Source/WebCore/testing/InternalSettings.cpp (modified) (4 diffs)
-
Source/WebCore/testing/InternalSettings.h (modified) (2 diffs)
-
Source/WebCore/testing/InternalSettings.idl (modified) (1 diff)
-
Source/WebCore/testing/Internals.cpp (modified) (1 diff)
-
Source/WebCore/testing/Internals.h (modified) (1 diff)
-
Source/WebCore/testing/Internals.idl (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/WebProcess.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243953 r243958 1 2019-04-05 Jer Noble <jer.noble@apple.com> 2 3 [Cocoa] Deactivate the audio session before the WebProcess suspends. 4 https://bugs.webkit.org/show_bug.cgi?id=196658 5 6 Reviewed by Eric Carlson. 7 8 * platform/mac/media/audio-session-deactivated-when-suspended-expected.txt: Added. 9 * platform/mac/media/audio-session-deactivated-when-suspended.html: Added. 10 1 11 2019-04-05 Devin Rousso <drousso@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r243957 r243958 1 2019-04-05 Jer Noble <jer.noble@apple.com> 2 3 [Cocoa] Deactivate the audio session before the WebProcess suspends. 4 https://bugs.webkit.org/show_bug.cgi?id=196658 5 6 Reviewed by Eric Carlson. 7 8 Test: platform/mac/media/audio-session-deactivated-when-suspended.html 9 10 Deactivate the audio session when we are notified that the session will suspend. 11 12 Drive-by fix: don't try to begin playback when the process is suspended. 13 14 * platform/audio/PlatformMediaSessionManager.cpp: 15 (WebCore::PlatformMediaSessionManager::sessionWillBeginPlayback): 16 (WebCore::PlatformMediaSessionManager::processWillSuspend): 17 (WebCore::PlatformMediaSessionManager::processDidResume): 18 * platform/audio/PlatformMediaSessionManager.h: 19 (WebCore::PlatformMediaSessionManager::processIsSuspended const): 20 * testing/InternalSettings.cpp: 21 (WebCore::InternalSettings::Backup::Backup): 22 (WebCore::InternalSettings::Backup::restoreTo): 23 (WebCore::InternalSettings::setShouldDeactivateAudioSession): 24 * testing/InternalSettings.h: 25 * testing/InternalSettings.idl: 26 * testing/Internals.cpp: 27 (WebCore::Internals::processWillSuspend): 28 (WebCore::Internals::processDidResume): 29 * testing/Internals.h: 30 * testing/Internals.idl: 31 1 32 2019-04-05 Sihui Liu <sihui_liu@apple.com> 2 33 -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
r242901 r243958 205 205 bool PlatformMediaSessionManager::sessionWillBeginPlayback(PlatformMediaSession& session) 206 206 { 207 ALWAYS_LOG(LOGIDENTIFIER, session.logIdentifier());208 209 207 setCurrentSession(session); 210 208 211 209 PlatformMediaSession::MediaType sessionType = session.mediaType(); 212 210 SessionRestrictions restrictions = m_restrictions[sessionType]; 213 if (session.state() == PlatformMediaSession::Interrupted && restrictions & InterruptedPlaybackNotPermitted) 211 if (session.state() == PlatformMediaSession::Interrupted && restrictions & InterruptedPlaybackNotPermitted) { 212 ALWAYS_LOG(LOGIDENTIFIER, session.logIdentifier(), " returning false because session.state() is Interrupted, and InterruptedPlaybackNotPermitted"); 214 213 return false; 214 } 215 216 if (m_processIsSuspended) { 217 ALWAYS_LOG(LOGIDENTIFIER, session.logIdentifier(), " returning false because process is suspended"); 218 return false; 219 } 215 220 216 221 #if USE(AUDIO_SESSION) 217 if (activeAudioSessionRequired() && !AudioSession::sharedSession().tryToSetActive(true)) 222 if (activeAudioSessionRequired() && !AudioSession::sharedSession().tryToSetActive(true)) { 223 ALWAYS_LOG(LOGIDENTIFIER, session.logIdentifier(), " returning false failed to set active AudioSession"); 218 224 return false; 225 } 219 226 220 227 m_becameActive = true; … … 233 240 }); 234 241 242 ALWAYS_LOG(LOGIDENTIFIER, session.logIdentifier(), " returning true"); 235 243 return true; 236 244 } … … 363 371 } 364 372 373 void PlatformMediaSessionManager::processWillSuspend() 374 { 375 if (m_processIsSuspended) 376 return; 377 m_processIsSuspended = true; 378 379 #if USE(AUDIO_SESSION) 380 if (m_becameActive && shouldDeactivateAudioSession()) { 381 AudioSession::sharedSession().tryToSetActive(false); 382 ALWAYS_LOG(LOGIDENTIFIER, "tried to set inactive AudioSession"); 383 m_becameActive = false; 384 } 385 #endif 386 } 387 388 void PlatformMediaSessionManager::processDidResume() 389 { 390 if (!m_processIsSuspended) 391 return; 392 m_processIsSuspended = false; 393 394 #if USE(AUDIO_SESSION) 395 if (!m_becameActive && activeAudioSessionRequired()) { 396 m_becameActive = AudioSession::sharedSession().tryToSetActive(true); 397 ALWAYS_LOG(LOGIDENTIFIER, "tried to set active AudioSession, ", m_becameActive ? "succeeded" : "failed"); 398 } 399 #endif 400 } 401 402 365 403 void PlatformMediaSessionManager::sessionIsPlayingToWirelessPlaybackTargetChanged(PlatformMediaSession& session) 366 404 { -
trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h
r242901 r243958 58 58 59 59 WEBCORE_EXPORT static void setShouldDeactivateAudioSession(bool); 60 WEBCORE_EXPORT static bool shouldDeactivateAudioSession(); 60 61 61 62 virtual ~PlatformMediaSessionManager() = default; … … 85 86 WEBCORE_EXPORT void applicationWillEnterForeground(bool suspendedUnderLock) const; 86 87 WEBCORE_EXPORT void applicationDidEnterBackground(bool suspendedUnderLock) const; 88 WEBCORE_EXPORT void processWillSuspend(); 89 WEBCORE_EXPORT void processDidResume(); 87 90 88 91 void stopAllMediaPlaybackForDocument(const Document*); … … 142 145 AudioHardwareListener* audioHardwareListener() { return m_audioHardwareListener.get(); } 143 146 147 bool processIsSuspended() const { return m_processIsSuspended; } 148 144 149 #if !RELEASE_LOG_DISABLED 145 150 const Logger& logger() const final { return m_logger; } … … 167 172 void systemDidWake() override; 168 173 169 static bool shouldDeactivateAudioSession();170 171 174 SessionRestrictions m_restrictions[PlatformMediaSession::MediaStreamCapturingAudio + 1]; 172 175 mutable Vector<PlatformMediaSession*> m_sessions; … … 184 187 bool m_willIgnoreSystemInterruptions { false }; 185 188 mutable int m_iteratingOverSessions { 0 }; 189 bool m_processIsSuspended { false }; 186 190 187 191 #if USE(AUDIO_SESSION) -
trunk/Source/WebCore/testing/InternalSettings.cpp
r243763 r243958 37 37 #include "Page.h" 38 38 #include "PageGroup.h" 39 #include "PlatformMediaSessionManager.h" 39 40 #include "RenderTheme.h" 40 41 #include "RuntimeEnabledFeatures.h" … … 98 99 , m_accessibilityEventsEnabled(settings.accessibilityEventsEnabled()) 99 100 #endif 101 , m_shouldDeactivateAudioSession(PlatformMediaSessionManager::shouldDeactivateAudioSession()) 100 102 , m_userInterfaceDirectionPolicy(settings.userInterfaceDirectionPolicy()) 101 103 , m_systemLayoutDirection(settings.systemLayoutDirection()) … … 203 205 settings.setFrameFlattening(m_frameFlattening); 204 206 settings.setIncompleteImageBorderEnabled(m_incompleteImageBorderEnabled); 207 PlatformMediaSessionManager::setShouldDeactivateAudioSession(m_shouldDeactivateAudioSession); 205 208 #if ENABLE(ACCESSIBILITY_EVENTS) 206 209 settings.setAccessibilityEventsEnabled(m_accessibilityEventsEnabled); … … 973 976 } 974 977 978 void InternalSettings::setShouldDeactivateAudioSession(bool should) 979 { 980 PlatformMediaSessionManager::setShouldDeactivateAudioSession(should); 981 } 982 975 983 // If you add to this class, make sure that you update the Backup class for test reproducability! 976 984 -
trunk/Source/WebCore/testing/InternalSettings.h
r243763 r243958 130 130 static bool webAnimationsCSSIntegrationEnabled(); 131 131 132 void setShouldDeactivateAudioSession(bool); 133 132 134 private: 133 135 explicit InternalSettings(Page*); … … 197 199 bool m_accessibilityEventsEnabled; 198 200 #endif 201 bool m_shouldDeactivateAudioSession; 199 202 UserInterfaceDirectionPolicy m_userInterfaceDirectionPolicy; 200 203 TextDirection m_systemLayoutDirection; -
trunk/Source/WebCore/testing/InternalSettings.idl
r243763 r243958 116 116 117 117 [MayThrowException] void setAccessibilityEventsEnabled(boolean enabled); 118 void setShouldDeactivateAudioSession(boolean shouldDeactivate); 118 119 }; 119 120 -
trunk/Source/WebCore/testing/Internals.cpp
r243899 r243958 4972 4972 } 4973 4973 4974 void Internals::processWillSuspend() 4975 { 4976 PlatformMediaSessionManager::sharedManager().processWillSuspend(); 4977 } 4978 4979 void Internals::processDidResume() 4980 { 4981 PlatformMediaSessionManager::sharedManager().processDidResume(); 4982 } 4983 4974 4984 } // namespace WebCore -
trunk/Source/WebCore/testing/Internals.h
r243804 r243958 804 804 805 805 void setAlwaysAllowLocalWebarchive(bool); 806 void processWillSuspend(); 807 void processDidResume(); 806 808 807 809 private: -
trunk/Source/WebCore/testing/Internals.idl
r243804 r243958 740 740 741 741 void setAlwaysAllowLocalWebarchive(boolean alwaysAllowLocalWebarchive); 742 }; 742 743 void processWillSuspend(); 744 void processDidResume(); 745 }; -
trunk/Source/WebKit/ChangeLog
r243957 r243958 1 2019-04-05 Jer Noble <jer.noble@apple.com> 2 3 [Cocoa] Deactivate the audio session before the WebProcess suspends. 4 https://bugs.webkit.org/show_bug.cgi?id=196658 5 6 Reviewed by Eric Carlson. 7 8 Notify the PlatformMediaSessionManager when the process suspends or resumes. 9 10 * WebProcess/WebProcess.cpp: 11 (WebKit::WebProcess::actualPrepareToSuspend): 12 (WebKit::WebProcess::cancelPrepareToSuspend): 13 (WebKit::WebProcess::processDidResume): 14 1 15 2019-04-05 Sihui Liu <sihui_liu@apple.com> 2 16 -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r243957 r243958 1454 1454 #if ENABLE(VIDEO) 1455 1455 suspendAllMediaBuffering(); 1456 PlatformMediaSessionManager::sharedManager().processWillSuspend(); 1456 1457 #endif 1457 1458 … … 1520 1521 1521 1522 #if ENABLE(VIDEO) 1523 PlatformMediaSessionManager::sharedManager().processDidResume(); 1522 1524 resumeAllMediaBuffering(); 1523 1525 #endif … … 1593 1595 1594 1596 #if ENABLE(VIDEO) 1597 PlatformMediaSessionManager::sharedManager().processDidResume(); 1595 1598 resumeAllMediaBuffering(); 1596 1599 #endif
Note:
See TracChangeset
for help on using the changeset viewer.