Skip to content

Commit

Permalink
[visionOS] Video fails to render after returning from LinearMediaPlay…
Browse files Browse the repository at this point in the history
…er fullscreen

https://bugs.webkit.org/show_bug.cgi?id=271024
rdar://123333859

Reviewed by Eric Carlson.

When returning from LinearMediaPlayer fullscreen we failed to clear the video receiver endpoint from
MediaPlayer, leaving it in a state where it was rendering to an endpoint that no longer existed. We
attempted to clear the endpoint in PlaybackSessionInterfaceLMK's implementation of
-linearMediaPlayer:didExitFullscreenWithError:, but it turns out this delegate method isn't called
when using `allowFullScreenFromInline`. Instead, clear the entpoint in -linearMediaPlayerToggleInlineMode:.

With this bug fixed, there is a second issue where the inline controls do not appear. This ended up
being a side effect of setting VideoPresentationInterface's captionsLayer on the LinearMediaPlayer.
Since there is still outstanding work for supporting captions (see rdar://124223292), for now just
pass an empty layer to LinearMediaPlayer.

* Source/WebKit/Platform/ios/PlaybackSessionInterfaceLMK.mm:
(-[WKLinearMediaPlayerDelegate linearMediaPlayerToggleInlineMode:]):
(-[WKLinearMediaPlayerDelegate linearMediaPlayer:didExitFullscreenWithError:]): Deleted.
* Source/WebKit/Platform/ios/VideoPresentationInterfaceLMK.mm:
(WebKit::VideoPresentationInterfaceLMK::setupPlayerViewController):

Canonical link: https://commits.webkit.org/276179@main
  • Loading branch information
aestes committed Mar 15, 2024
1 parent 5512680 commit 2464f16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions Source/WebKit/Platform/ios/PlaybackSessionInterfaceLMK.mm
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,12 @@ - (void)linearMediaPlayer:(WKSLinearMediaPlayer *)player setLegibleTrack:(WKSLin

- (void)linearMediaPlayerToggleInlineMode:(WKSLinearMediaPlayer *)player
{
if (auto model = _model.get())
model->toggleFullscreen();
}
auto model = _model.get();
if (!model)
return;

- (void)linearMediaPlayer:(WKSLinearMediaPlayer *)player didExitFullscreenWithError:(NSError * _Nullable)error
{
if (auto model = _model.get())
model->setVideoReceiverEndpoint(nullptr);
model->toggleFullscreen();
model->setVideoReceiverEndpoint(nullptr);
}

- (void)linearMediaPlayer:(WKSLinearMediaPlayer *)player setVideoReceiverEndpoint:(xpc_object_t)videoReceiverEndpoint
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/Platform/ios/VideoPresentationInterfaceLMK.mm
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
linearMediaPlayer().allowFullScreenFromInline = YES;
linearMediaPlayer().contentType = WKSLinearMediaContentTypePlanar;
linearMediaPlayer().presentationMode = WKSLinearMediaPresentationModeInline;
linearMediaPlayer().captionLayer = captionsLayer();
linearMediaPlayer().videoLayer = [m_playerLayerView playerLayer];
// FIXME: pass a valid caption layer (rdar://124223292)
linearMediaPlayer().captionLayer = CALayer.layer;

m_playerViewController = [linearMediaPlayer() makeViewController];
}
Expand Down

0 comments on commit 2464f16

Please sign in to comment.