Metal and CAAnimation

I'm trying to synchronize contents of a Metal layer with UIView animations (CAAnimation-based). I've tried using custom CALayer animations by overriding the needsDisplay and action(forKey:) methods of CAMetalLayer, setting presentsWithTransaction to true, then performing a change inside a CATransaction. This works, but when animating a UIView and the contents of a CAMetalLayer side by side, the Metal contents slightly lags behind the UIView.

Is there any way to perfectly synchronize the app-side animated drawing with render server-side animations?

Metal and CAAnimation
 
 
Q