⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 264177 in webkit


Ignore:
Timestamp:
Jul 9, 2020, 9:57:19 AM (6 years ago)
Author:
eric.carlson@apple.com
Message:

Reset AVSystemController_PIDToInheritApplicationStateFrom when mediaserverd dies
​https://bugs.webkit.org/show_bug.cgi?id=214112
<rdar://problem/65229214>

Reviewed by Jer Noble.

Source/WebCore:

Tested manually because this can only be tested by killing a system process while
capturing on iOS hardware.

  • platform/audio/cocoa/MediaSessionManagerCocoa.h: Add task queue accessor.

(WebCore::MediaSessionManagerCocoa::taskQueue):

  • platform/audio/ios/MediaSessionHelperIOS.h:

(WebCore::MediaSessionHelperClient::mediaServerConnectionDied):

  • platform/audio/ios/MediaSessionHelperIOS.mm:

(MediaSessionHelperiOS::mediaServerConnectionDied): Renamed from carPlayServerDied.
Inform clients if we previously set the PID proxy.
(-[WebMediaSessionHelper initWithCallback:]): Call mediaServerConnectionDied.
(-[WebMediaSessionHelper mediaServerConnectionDied:]): Ditto.
(MediaSessionHelperiOS::carPlayServerDied): Deleted.
(-[WebMediaSessionHelper carPlayServerDied:]): Deleted.

  • platform/audio/ios/MediaSessionManagerIOS.h:
  • platform/audio/ios/MediaSessionManagerIOS.mm:

(WebCore::MediaSessionManageriOS::mediaServerConnectionDied): Call providePresentingApplicationPID
if we previously set the PID proxy.

  • platform/mediastream/mac/AVVideoCaptureSource.mm:

(WebCore::AVVideoCaptureSource::captureSessionRuntimeError): Don't try to restart the
session immediately since this is called directly from the notification handler.

Source/WebKit:

  • GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp:

(WebKit::RemoteMediaSessionHelperProxy::providePresentingApplicationPID): Don't bother
tracking whether or not providePresentingApplicationPID has been called, the session
helper already does that.

  • GPUProcess/media/ios/RemoteMediaSessionHelperProxy.h:
Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r264176 r264177  
     12020-07-09  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Reset AVSystemController_PIDToInheritApplicationStateFrom when mediaserverd dies
     4        https://bugs.webkit.org/show_bug.cgi?id=214112
     5        <rdar://problem/65229214>
     6
     7        Reviewed by Jer Noble.
     8
     9        Tested manually because this can only be tested by killing a system process while
     10        capturing on iOS hardware.
     11
     12        * platform/audio/cocoa/MediaSessionManagerCocoa.h: Add task queue accessor.
     13        (WebCore::MediaSessionManagerCocoa::taskQueue):
     14
     15        * platform/audio/ios/MediaSessionHelperIOS.h:
     16        (WebCore::MediaSessionHelperClient::mediaServerConnectionDied):
     17        * platform/audio/ios/MediaSessionHelperIOS.mm:
     18        (MediaSessionHelperiOS::mediaServerConnectionDied): Renamed from carPlayServerDied.
     19        Inform clients if we previously set the PID proxy.
     20        (-[WebMediaSessionHelper initWithCallback:]): Call mediaServerConnectionDied.
     21        (-[WebMediaSessionHelper mediaServerConnectionDied:]): Ditto.
     22        (MediaSessionHelperiOS::carPlayServerDied): Deleted.
     23        (-[WebMediaSessionHelper carPlayServerDied:]): Deleted.
     24
     25        * platform/audio/ios/MediaSessionManagerIOS.h:
     26        * platform/audio/ios/MediaSessionManagerIOS.mm:
     27        (WebCore::MediaSessionManageriOS::mediaServerConnectionDied): Call providePresentingApplicationPID
     28        if we previously set the PID proxy.
     29
     30        * platform/mediastream/mac/AVVideoCaptureSource.mm:
     31        (WebCore::AVVideoCaptureSource::captureSessionRuntimeError): Don't try to restart the
     32        session immediately since this is called directly from the notification handler.
     33
    1342020-07-09  Clark Wang  <clark_wang@apple.com>
    235
  • trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h

    r261709 r264177  
    8383    PlatformMediaSession* nowPlayingEligibleSession();
    8484
     85    GenericTaskQueue<Timer>& taskQueue() { return m_taskQueue; }
     86
    8587private:
    8688#if !RELEASE_LOG_DISABLED
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.h

    r258324 r264177  
    4343    virtual void applicationWillBecomeInactive() = 0;
    4444    virtual void applicationDidBecomeActive() = 0;
     45    virtual void mediaServerConnectionDied() { };
    4546
    4647    enum class HasAvailableTargets : bool { No, Yes };
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.mm

    r259303 r264177  
    9999    void applicationDidBecomeActive();
    100100#if HAVE(CELESTIAL)
    101     void carPlayServerDied();
     101    void mediaServerConnectionDied();
    102102    void updateCarPlayIsConnected(Optional<bool>&&);
    103103#endif
    … …  
    227227
    228228#if HAVE(CELESTIAL)
    229 void MediaSessionHelperiOS::carPlayServerDied()
     229void MediaSessionHelperiOS::mediaServerConnectionDied()
    230230{
    231231    updateCarPlayIsConnected(WTF::nullopt);
     232
     233    if (!m_havePresentedApplicationPID)
     234        return;
     235
     236    m_havePresentedApplicationPID = false;
     237    for (auto& client : m_clients)
     238        client.mediaServerConnectionDied();
    232239}
    233240
    … …  
    334341#if HAVE(CELESTIAL)
    335342    if (canLoadAVSystemController_ServerConnectionDiedNotification())
    336         [center addObserver:self selector:@selector(carPlayServerDied:) name:getAVSystemController_ServerConnectionDiedNotification() object:nil];
     343        [center addObserver:self selector:@selector(mediaServerConnectionDied:) name:getAVSystemController_ServerConnectionDiedNotification() object:nil];
    337344    if (canLoadAVSystemController_CarPlayIsConnectedDidChangeNotification())
    338345        [center addObserver:self selector:@selector(carPlayIsConnectedDidChange:) name:getAVSystemController_CarPlayIsConnectedDidChangeNotification() object:nil];
    … …  
    513520
    514521#if HAVE(CELESTIAL)
    515 - (void)carPlayServerDied:(NSNotification *)notification
    516 {
    517     if (!_callback)
    518         return;
    519 
    520     LOG(Media, "-[WebMediaSessionHelper carPlayServerDied:]");
     522- (void)mediaServerConnectionDied:(NSNotification *)notification
     523{
     524    if (!_callback)
     525        return;
     526
     527    LOG(Media, "-[WebMediaSessionHelper mediaServerConnectionDied:]");
    521528    UNUSED_PARAM(notification);
    522529    callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self)]() mutable {
    523530        if (auto* callback = protectedSelf->_callback)
    524             callback->carPlayServerDied();
     531            callback->mediaServerConnectionDied();
    525532    });
    526533}
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h

    r259303 r264177  
    7777    void applicationWillBecomeInactive() final;
    7878    void applicationDidBecomeActive() final;
     79    void mediaServerConnectionDied() final;
    7980    void externalOutputDeviceAvailableDidChange(HasAvailableTargets) final;
    8081    void activeAudioRouteDidChange(ShouldPause) final;
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm

    r261839 r264177  
    116116}
    117117
     118void MediaSessionManageriOS::mediaServerConnectionDied()
     119{
     120    ALWAYS_LOG(LOGIDENTIFIER, m_havePresentedApplicationPID);
     121
     122    if (!m_havePresentedApplicationPID)
     123        return;
     124
     125    m_havePresentedApplicationPID = false;
     126    taskQueue().enqueueTask([] () {
     127        providePresentingApplicationPID();
     128    });
     129}
     130
    118131void MediaSessionManageriOS::providePresentingApplicationPID()
    119132{
  • trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm

    r262122 r264177  
    616616void AVVideoCaptureSource::captureSessionRuntimeError(RetainPtr<NSError> error)
    617617{
    618     ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, [[error localizedDescription] UTF8String]);
     618    auto identifier = LOGIDENTIFIER;
     619    ERROR_LOG_IF(loggerPtr(), identifier, [error code], ", ", [[error localizedDescription] UTF8String]);
    619620
    620621    if (!m_isRunning || error.get().code != AVErrorMediaServicesWereReset)
    621622        return;
    622623
    623     // Try to restart the session, but reset m_isRunning immediately so if it fails we won't try again.
    624     [m_session startRunning];
    625     m_isRunning = [m_session isRunning];
     624    scheduleDeferredTask([this, identifier] {
     625        // Try to restart the session, but reset m_isRunning immediately so if it fails we won't try again.
     626        ERROR_LOG_IF(loggerPtr(), identifier, "restarting session");
     627        [m_session startRunning];
     628        m_isRunning = [m_session isRunning];
     629    });
    626630}
    627631
  • trunk/Source/WebKit/ChangeLog

    r264170 r264177  
     12020-07-09  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Reset AVSystemController_PIDToInheritApplicationStateFrom when mediaserverd dies
     4        https://bugs.webkit.org/show_bug.cgi?id=214112
     5        <rdar://problem/65229214>
     6
     7        Reviewed by Jer Noble.
     8
     9        * GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp:
     10        (WebKit::RemoteMediaSessionHelperProxy::providePresentingApplicationPID): Don't bother
     11        tracking whether or not providePresentingApplicationPID has been called, the session
     12        helper already does that.
     13        * GPUProcess/media/ios/RemoteMediaSessionHelperProxy.h:
     14
    1152020-07-09  Wenson Hsieh  <wenson_hsieh@apple.com>
    216
  • trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp

    r258324 r264177  
    6868void RemoteMediaSessionHelperProxy::providePresentingApplicationPID(int pid)
    6969{
    70     if (m_providedApplicationPID)
    71         return;
    72 
    73     m_providedApplicationPID = true;
    7470    MediaSessionHelper::sharedHelper().providePresentingApplicationPID(pid);
    7571}
  • trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.h

    r258324 r264177  
    6262    void activeVideoRouteDidChange(SupportsAirPlayVideo, Ref<WebCore::MediaPlaybackTarget>&&) final;
    6363
    64     bool m_providedApplicationPID { false };
    6564    bool m_isMonitoringWirelessRoutes { false };
    6665    GPUConnectionToWebProcess& m_gpuConnection;
Note: See TracChangeset for help on using the changeset viewer.