From 6a832f37f466b21d2c93a5d9da901b2bdd2e3fe2 Mon Sep 17 00:00:00 2001 From: Nick Entin Date: Fri, 4 Oct 2024 12:17:57 -0700 Subject: [PATCH] Disable implicit layer animations while rendering frames --- Sources/Stagehand/AnimationInstance/Renderer.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sources/Stagehand/AnimationInstance/Renderer.swift b/Sources/Stagehand/AnimationInstance/Renderer.swift index a86b75a..adf35d9 100644 --- a/Sources/Stagehand/AnimationInstance/Renderer.swift +++ b/Sources/Stagehand/AnimationInstance/Renderer.swift @@ -15,6 +15,7 @@ // import Foundation +import QuartzCore internal final class Renderer: AnyRenderer { @@ -55,7 +56,13 @@ internal final class Renderer: AnyRenderer { return } + // Disable implicit layer animations while rendering the frame. Otherwise animations that include keyframes for animatable layer properties will not animate those properties in sync with the rest of the animation. + CATransaction.begin() + CATransaction.setDisableActions(true) + animation.apply(to: &element, at: relativeTimestamp, initialValues: initialValues) + + CATransaction.commit() } func renderInitialFrame() {