Title: [264471] trunk/Source/WebCore
- Revision
- 264471
- Author
- peng.l...@apple.com
- Date
- 2020-07-16 10:59:22 -0700 (Thu, 16 Jul 2020)
Log Message
Double tapping to zoom out a fullscreen video will zoom in slightly before zooming out
https://bugs.webkit.org/show_bug.cgi?id=214400
Reviewed by Jer Noble.
When changing the video gravity of a fullscreen video from AVLayerVideoGravityResizeAspectFill
to AVLayerVideoGravityResizeAspect, the implicit animation of the AVPlayerLayer in the web process
will conflict with the implicit animation of the _videoSublayer in the WebAVPlayerLayer in the
UI process. To avoid the implicit animation in the web process because of the video gravity change,
we have to let the remote hosting layer and the corresponding AVPlayerLayer in the web process
to include the whole video, even when the video gravity is AVLayerVideoGravityResizeAspectFill
and the video will be clipped by the superlayer. When the AVPlayerLayer has the whole video,
changing the video gravity from AVLayerVideoGravityResizeAspectFill to AVLayerVideoGravityResizeAspect
will not generate an implicit animation in the web process.
This patch also adds an instance variable _previousVideoGravity to make sure the transform is
correctly calculated when video gravity is changing.
* platform/ios/VideoFullscreenInterfaceAVKit.mm:
(-[WebAVPlayerLayer init]):
(-[WebAVPlayerLayer layoutSublayers]):
(-[WebAVPlayerLayer resolveBounds]):
(-[WebAVPlayerLayer setVideoGravity:]):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (264470 => 264471)
--- trunk/Source/WebCore/ChangeLog 2020-07-16 17:43:12 UTC (rev 264470)
+++ trunk/Source/WebCore/ChangeLog 2020-07-16 17:59:22 UTC (rev 264471)
@@ -1,3 +1,29 @@
+2020-07-16 Peng Liu <peng.l...@apple.com>
+
+ Double tapping to zoom out a fullscreen video will zoom in slightly before zooming out
+ https://bugs.webkit.org/show_bug.cgi?id=214400
+
+ Reviewed by Jer Noble.
+
+ When changing the video gravity of a fullscreen video from AVLayerVideoGravityResizeAspectFill
+ to AVLayerVideoGravityResizeAspect, the implicit animation of the AVPlayerLayer in the web process
+ will conflict with the implicit animation of the _videoSublayer in the WebAVPlayerLayer in the
+ UI process. To avoid the implicit animation in the web process because of the video gravity change,
+ we have to let the remote hosting layer and the corresponding AVPlayerLayer in the web process
+ to include the whole video, even when the video gravity is AVLayerVideoGravityResizeAspectFill
+ and the video will be clipped by the superlayer. When the AVPlayerLayer has the whole video,
+ changing the video gravity from AVLayerVideoGravityResizeAspectFill to AVLayerVideoGravityResizeAspect
+ will not generate an implicit animation in the web process.
+
+ This patch also adds an instance variable _previousVideoGravity to make sure the transform is
+ correctly calculated when video gravity is changing.
+
+ * platform/ios/VideoFullscreenInterfaceAVKit.mm:
+ (-[WebAVPlayerLayer init]):
+ (-[WebAVPlayerLayer layoutSublayers]):
+ (-[WebAVPlayerLayer resolveBounds]):
+ (-[WebAVPlayerLayer setVideoGravity:]):
+
2020-07-16 Andres Gonzalez <andresg...@apple.com>
Crash caused by clients that don't support isolated tree mode calling on the secondary thread.
Modified: trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm (264470 => 264471)
--- trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm 2020-07-16 17:43:12 UTC (rev 264470)
+++ trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm 2020-07-16 17:59:22 UTC (rev 264471)
@@ -202,7 +202,9 @@
RefPtr<VideoFullscreenInterfaceAVKit> _fullscreenInterface;
RetainPtr<WebAVPlayerController> _avPlayerController;
RetainPtr<CALayer> _videoSublayer;
+ FloatRect _videoSublayerFrame;
RetainPtr<NSString> _videoGravity;
+ RetainPtr<NSString> _previousVideoGravity;
}
- (instancetype)init
@@ -212,6 +214,7 @@
self.masksToBounds = YES;
self.allowsHitTesting = NO;
_videoGravity = AVLayerVideoGravityResizeAspect;
+ _previousVideoGravity = AVLayerVideoGravityResizeAspect;
}
return self;
}
@@ -270,27 +273,34 @@
FloatRect sourceVideoFrame;
FloatRect targetVideoFrame;
float videoAspectRatio = self.videoDimensions.width / self.videoDimensions.height;
-
- if ([AVLayerVideoGravityResize isEqualToString:self.videoGravity]) {
+
+ if ([AVLayerVideoGravityResize isEqualToString:_previousVideoGravity.get()])
sourceVideoFrame = self.modelVideoLayerFrame;
+ else if ([AVLayerVideoGravityResizeAspect isEqualToString:_previousVideoGravity.get()])
+ sourceVideoFrame = largestRectWithAspectRatioInsideRect(videoAspectRatio, self.modelVideoLayerFrame);
+ else if ([AVLayerVideoGravityResizeAspectFill isEqualToString:_previousVideoGravity.get()])
+ sourceVideoFrame = smallestRectWithAspectRatioAroundRect(videoAspectRatio, self.modelVideoLayerFrame);
+ else
+ ASSERT_NOT_REACHED();
+
+ if ([AVLayerVideoGravityResize isEqualToString:self.videoGravity])
targetVideoFrame = self.bounds;
- } else if ([AVLayerVideoGravityResizeAspect isEqualToString:self.videoGravity]) {
- sourceVideoFrame = largestRectWithAspectRatioInsideRect(videoAspectRatio, self.modelVideoLayerFrame);
+ else if ([AVLayerVideoGravityResizeAspect isEqualToString:self.videoGravity])
targetVideoFrame = largestRectWithAspectRatioInsideRect(videoAspectRatio, self.bounds);
- } else if ([AVLayerVideoGravityResizeAspectFill isEqualToString:self.videoGravity]) {
- sourceVideoFrame = smallestRectWithAspectRatioAroundRect(videoAspectRatio, self.modelVideoLayerFrame);
+ else if ([AVLayerVideoGravityResizeAspectFill isEqualToString:self.videoGravity])
targetVideoFrame = smallestRectWithAspectRatioAroundRect(videoAspectRatio, self.bounds);
- } else
+ else
ASSERT_NOT_REACHED();
UIView *view = (UIView *)[_videoSublayer delegate];
CGAffineTransform transform = CGAffineTransformMakeScale(targetVideoFrame.width() / sourceVideoFrame.width(), targetVideoFrame.height() / sourceVideoFrame.height());
[view setTransform:transform];
-
+
NSTimeInterval animationDuration = [CATransaction animationDuration];
dispatch_async(dispatch_get_main_queue(), ^{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(resolveBounds) object:nil];
+ _videoSublayerFrame = targetVideoFrame;
[self performSelector:@selector(resolveBounds) withObject:nil afterDelay:animationDuration + 0.1];
});
}
@@ -314,7 +324,9 @@
if (!CGRectEqualToRect(self.modelVideoLayerFrame, [self bounds])) {
self.modelVideoLayerFrame = [self bounds];
if (auto* model = _fullscreenInterface->videoFullscreenModel())
- model->setVideoLayerFrame(self.modelVideoLayerFrame);
+ model->setVideoLayerFrame(_videoSublayerFrame);
+
+ _previousVideoGravity = _videoGravity;
}
[(UIView *)[_videoSublayer delegate] setTransform:CGAffineTransformIdentity];
@@ -329,8 +341,12 @@
videoGravity = AVLayerVideoGravityResizeAspect;
#endif
+ if ([_videoGravity.get() isEqualToString:videoGravity])
+ return;
+
+ _previousVideoGravity = _videoGravity;
_videoGravity = videoGravity;
-
+
if (![_avPlayerController delegate])
return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes