Changeset 250694 in webkit


Ignore:
Timestamp:
Oct 3, 2019 6:09:43 PM (5 years ago)
Author:
jer.noble@apple.com
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):
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r250693 r250694  
     12019-10-03  Jer Noble  <jer.noble@apple.com>
     2
     3    [iOS] WebContent process can be interrupted during suspension; loses "Now Playing" status
     4    https://bugs.webkit.org/show_bug.cgi?id=202537
     5    <rdar://problem/55952707>
     6
     7    Reviewed by Eric Carlson.
     8
     9    Always deactivate the AVAudioSession when the last playing PlatformAudioSession ends playback and the application is in the background.
     10
     11    * platform/audio/PlatformMediaSessionManager.cpp:
     12    (WebCore::PlatformMediaSessionManager::removeSession):
     13    (WebCore::PlatformMediaSessionManager::processWillSuspend):
     14    (WebCore::PlatformMediaSessionManager::maybeDeactivateAudioSession):
     15    * platform/audio/PlatformMediaSessionManager.h:
     16    (WebCore::PlatformMediaSessionManager::isApplicationInBackground const):
     17    * platform/audio/ios/MediaSessionManagerIOS.h:
     18    * platform/audio/ios/MediaSessionManagerIOS.mm:
     19    (WebCore::MediaSessionManageriOS::sessionWillEndPlayback):
     20
    1212019-10-03  Chris Dumez  <cdumez@apple.com>
    222
  • trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp

    r247182 r250694  
    167167        m_audioHardwareListener = nullptr;
    168168#if USE(AUDIO_SESSION)
    169         if (m_becameActive && shouldDeactivateAudioSession()) {
    170             AudioSession::sharedSession().tryToSetActive(false);
    171             m_becameActive = false;
    172         }
     169        maybeDeactivateAudioSession();
    173170#endif
    174171    }
     
    364361    m_processIsSuspended = true;
    365362
     363    ALWAYS_LOG(LOGIDENTIFIER);
     364
    366365    forEachSession([&] (auto& session) {
    367366        session.client().processIsSuspendedChanged();
     
    369368
    370369#if USE(AUDIO_SESSION)
    371     if (m_becameActive && shouldDeactivateAudioSession()) {
    372         AudioSession::sharedSession().tryToSetActive(false);
    373         ALWAYS_LOG(LOGIDENTIFIER, "tried to set inactive AudioSession");
    374         m_becameActive = false;
    375     }
     370    maybeDeactivateAudioSession();
    376371#endif
    377372}
     
    546541}
    547542
     543#if USE(AUDIO_SESSION)
     544void PlatformMediaSessionManager::maybeDeactivateAudioSession()
     545{
     546    if (!m_becameActive || !shouldDeactivateAudioSession())
     547        return;
     548
     549    ALWAYS_LOG(LOGIDENTIFIER, "tried to set inactive AudioSession");
     550    AudioSession::sharedSession().tryToSetActive(false);
     551    m_becameActive = false;
     552}
     553#endif
     554
    548555static bool& deactivateAudioSession()
    549556{
  • trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h

    r247118 r250694  
    150150    AudioHardwareListener* audioHardwareListener() { return m_audioHardwareListener.get(); }
    151151
     152    bool isApplicationInBackground() const { return m_isApplicationInBackground; }
     153#if USE(AUDIO_SESSION)
     154    void maybeDeactivateAudioSession();
     155#endif
     156
    152157#if !RELEASE_LOG_DISABLED
    153158    const Logger& logger() const final { return m_logger; }
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h

    r248978 r250694  
    6363    void configureWireLessTargetMonitoring() override;
    6464    void providePresentingApplicationPIDIfNecessary() final;
     65    void sessionWillEndPlayback(PlatformMediaSession&) final;
    6566
    6667#if !RELEASE_LOG_DISABLED
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm

    r248978 r250694  
    191191}
    192192
     193void MediaSessionManageriOS::sessionWillEndPlayback(PlatformMediaSession& session)
     194{
     195    MediaSessionManagerCocoa::sessionWillEndPlayback(session);
     196
     197#if USE(AUDIO_SESSION)
     198    if (isApplicationInBackground() && !anyOfSessions([] (auto& session) { return session.state() == PlatformMediaSession::Playing; }))
     199        maybeDeactivateAudioSession();
     200#endif
     201}
     202
    193203void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
    194204{
Note: See TracChangeset for help on using the changeset viewer.