Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f1122551722bf80eedb0eaf548808a999282e0ce
      
https://github.com/WebKit/WebKit/commit/f1122551722bf80eedb0eaf548808a999282e0ce
  Author: Andy Estes <[email protected]>
  Date:   2024-04-06 (Sat, 06 Apr 2024)

  Changed paths:
    M Source/WebCore/platform/cocoa/PlaybackSessionModel.h
    M Source/WebCore/platform/cocoa/PlaybackSessionModelMediaElement.h
    M Source/WebCore/platform/cocoa/PlaybackSessionModelMediaElement.mm
    M Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
    M Source/WebKit/Platform/ios/PlaybackSessionInterfaceLMK.mm
    M Source/WebKit/Platform/ios/VideoPresentationInterfaceLMK.mm
    M Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h
    M Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm
    M Source/WebKit/WebKitSwift/LinearMediaKit/LinearMediaPlayer.swift
    M Source/WebKit/WebKitSwift/LinearMediaKit/LinearMediaTypes.swift
    M Source/WebKit/WebKitSwift/LinearMediaKit/WKSLinearMediaPlayer.h
    M Source/WebKit/WebKitSwift/LinearMediaKit/WKSLinearMediaTypes.h
    M Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.h
    M Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.messages.in
    M Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm

  Log Message:
  -----------
  [visionOS] Repeated attempts to enter and exit LinearMediaPlayer fullscreen 
may fail
https://bugs.webkit.org/show_bug.cgi?id=272253
rdar://125994291

Reviewed by Jer Noble.

When exiting LinearMediaPlayer fullscreen LinearMediaKit may call 
willExitFullscreen() twice, and
each time PlaybackSessionInterfaceLMK would respond by calling
PlaybackSessionModel::toggleFullscreen(). The first call would exit fullscreen 
and ultimately
destroy the LinearMediaPlayer, but since the second call would occur before
VideoPresentationInterfaceIOS::cleanupFullscreen() was called the fullscreen 
state machine would be
left in a bad state where it believed it was in standard fullscreen but a 
LinearMediaPlayer would
not exist. Later attempts to enter fullscreen would fail due to the 
LMPlayableViewController not
having a valid Playable-conforming object.

Resolved this by teaching LinearMediaPlayer to track a presentationState 
indepenently of the value
of presentationMode, allowing it to tolerate multiple calls to 
willEnterFullscreen(),
willExitFullscreen(), and toggleInlineMode(). When LinearMediaKit calls 
willEnterFullscreen() and
presentationState is .inline we change it to .enteringFullscreen an ddispatch
-linearMediaPlayerEnterFullscreen:, otherwise we ignore the call. When 
LinearMediaKit calls
willExitFullscreen() and presentationState is .fullscreen we change it to 
.exitingFullscreen and
dispatch -linearMediaPlayerExitFullscreen:, otherwise we ignore the call. When 
LinearMediaKit calls
toggleInlineMode() and presentationState is .inline or .fullscreen, we change 
it to
.enteringFullscreen or .exitingFullscreen respectively, otherwise we ignore the 
call.

Next, rather than allowing LinearMediaPlayer's client to mutate 
presentationMode directly, exposed
-enterFullscreen and -exitFullscreen methods. When -enterFullscreen is called 
when presentationState
is anything but .fullscreen, we change presentationState to .fullscreen and 
presentationMode to
.fullscreenFromInline. When -exitFullscreen is called when presentationState is 
anything but
.inline, we change presentationState and presentationMode to .inline.

Finally, PlaybackSessionModel::toggleFullscreen() was removed and an explicit
PlaybackSessionModel::exitFullscreen() was added. When 
PlaybackSessionInterfaceLMK receives
-linearMediaPlayerEnterFullscreen: or -linearMediaPlayerExitFullscreen: it calls
PlaybackSessionModel::enterFullscreen() and 
PlaybackSessionModel::exitFullscreen() respectively.
VideoPresentationInterfaceLMK was also changed to call -enterFullscreen and 
-exitFullscreen instead
of mutating LinearMediaPlayer's presentationMode directly.

The net result of these changes is that a request from LinearMediaKit to enter 
or exit fullscreen is
ignored if a previous request is still in progress or if the state machine is 
already in the
requested state.

* Source/WebCore/platform/cocoa/PlaybackSessionModel.h:
* Source/WebCore/platform/cocoa/PlaybackSessionModelMediaElement.h:
* Source/WebCore/platform/cocoa/PlaybackSessionModelMediaElement.mm:
(WebCore::PlaybackSessionModelMediaElement::exitFullscreen):
(WebCore::PlaybackSessionModelMediaElement::toggleFullscreen): Deleted.
* Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm:
* Source/WebKit/Platform/ios/PlaybackSessionInterfaceLMK.mm:
(-[WKLinearMediaPlayerDelegate linearMediaPlayerEnterFullscreen:]):
(-[WKLinearMediaPlayerDelegate linearMediaPlayerExitFullscreen:]):
(-[WKLinearMediaPlayerDelegate linearMediaPlayerToggleInlineMode:]): Deleted.
(-[WKLinearMediaPlayerDelegate linearMediaPlayerWillEnterFullscreen:]): Deleted.
(-[WKLinearMediaPlayerDelegate linearMediaPlayerWillExitFullscreen:]): Deleted.
(-[WKLinearMediaPlayerDelegate _exitFullscreen]): Deleted.
* Source/WebKit/Platform/ios/VideoPresentationInterfaceLMK.mm:
(WebKit::VideoPresentationInterfaceLMK::setupPlayerViewController):
(WebKit::VideoPresentationInterfaceLMK::presentFullscreen):
(WebKit::VideoPresentationInterfaceLMK::dismissFullscreen):
* Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.h:
* Source/WebKit/UIProcess/Cocoa/PlaybackSessionManagerProxy.mm:
(WebKit::PlaybackSessionModelContext::exitFullscreen):
(WebKit::PlaybackSessionManagerProxy::exitFullscreen):
(WebKit::PlaybackSessionModelContext::toggleFullscreen): Deleted.
(WebKit::PlaybackSessionManagerProxy::toggleFullscreen): Deleted.
* Source/WebKit/WebKitSwift/LinearMediaKit/LinearMediaPlayer.swift:
(SwiftOnlyData.presentationMode):
(SwiftOnlyData.presentationState):
(WKSLinearMediaPlayer.presentationState):
(WKSLinearMediaPlayer.cancellables):
(WKSLinearMediaPlayer.enterFullscreen):
(WKSLinearMediaPlayer.exitFullscreen):
(WKSLinearMediaPlayer.presentationStateChanged(_:)):
(WKSLinearMediaPlayer.presentationModePublisher):
(WKSLinearMediaPlayer.toggleInlineMode):
(WKSLinearMediaPlayer.willEnterFullscreen):
(WKSLinearMediaPlayer.willExitFullscreen):
(WKSLinearMediaPlayer.presentationMode): Deleted.
* Source/WebKit/WebKitSwift/LinearMediaKit/LinearMediaTypes.swift:
(WKSLinearMediaPresentationMode.presentationMode): Deleted.
* Source/WebKit/WebKitSwift/LinearMediaKit/WKSLinearMediaPlayer.h:
* Source/WebKit/WebKitSwift/LinearMediaKit/WKSLinearMediaTypes.h:
* Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.h:
* Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.messages.in:
* Source/WebKit/WebProcess/cocoa/PlaybackSessionManager.mm:
(WebKit::PlaybackSessionManager::exitFullscreen):
(WebKit::PlaybackSessionManager::toggleFullscreen): Deleted.

Canonical link: https://commits.webkit.org/277169@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to