UIViewPropertyAnimator does not update the view when expected

Originator:let.adrian.know
Number:rdar://30856746 Date Originated:05/03/2017
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode Version 8.2.1 (8C1002)
Classification:Serious Bug Reproducible:Always
 
Summary:
The UIViewPropertyAnimator does not update the view when `fractionComplete` is set while it's in an `inactive` state, or even in `active` state.

Steps to Reproduce:
Run this Swift Playground code.

let liveView = UIView(frame: CGRect(x: 0, y: 0, width: 400, height: 50))
liveView.backgroundColor = .white

PlaygroundPage.current.needsIndefiniteExecution = true
PlaygroundPage.current.liveView = liveView

let square = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
square.backgroundColor = .red

liveView.addSubview(square)

let animator = UIViewPropertyAnimator.init(duration: 5, curve: .easeIn)

animator.addAnimations {

    square.frame.origin.x = 350
}

// State: inactive
// Does nothing, position is at 0.0
DispatchQueue.main.async {

    animator.fractionComplete = 0.5
}

// State: active
// Stil does nothing, position is at 0.0
DispatchQueue.main.async {

    animator.fractionComplete = 0.5
}

// Updates from 0.0 to 0.75 - Why now?
DispatchQueue.main.asyncAfter(deadline: .now() + 5) { 

    animator.fractionComplete = 0.75
}

Expected Results:
The view is expected to change its position on each call of `fractionComplete`.

Actual Results:
The animator does nothing for the first two calls, except changing the state to from `inactive` to `active`. The view changes it's position after the third call of `fractionComplete` after 5 seconds.

CURRENT WORKAROUND:
Put these two lines before the first call:

animator.startAnimation()
animator.pauseAnimation()


Configuration:
The issue was testen in Swift Playground, in iOS simulator and on and iPhone 6 Plus and had always the same results

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!