[UIView animateWithDuration:...] with very small duration and certain frame values corrupts view

Originator:Gordonsniff
Number:rdar://27844287 Date Originated:15.08.2016
Status:Open Resolved:No
Product:UIKit Product Version:Xcode 7.3.1
Classification:Bug Reproducible:Always
 
Area:
UIKit

Summary:
When animating the multiple values of a frame of some view with a very small duration (for example 0.00001) - the animation does not take place and all subsequent animations to that view complete instantly.

Steps to Reproduce:
- (void)reproduceBug
{
    CGRect initialFrame = CGRectMake(0, 0, 0, 0);
    CGRect frame2 = CGRectMake(100, 100, 100, 100);
    CGRect finalFrame = CGRectMake(200, 200, 200, 200);
    
    
    __block UIView *view = [[UIView alloc] initWithFrame:initialFrame];
    view.backgroundColor = [UIColor greenColor];
    [self.view addSubview:view];
    
    NSLog(@"Initial frame is: %@", NSStringFromCGRect(view.frame));
    NSLog(@"Final frame should be: %@", NSStringFromCGRect(finalFrame));

    [UIView animateWithDuration:0.00000001 delay:0.0
                        options:UIViewAnimationOptionBeginFromCurrentState
                     animations:^{
                         view.frame = frame2;
                     } completion:^(BOOL finished) {
                             NSLog(@"After first animation frame is: %@", NSStringFromCGRect(view.frame));

                             [UIView animateWithDuration:.1 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
                                 view.frame = finalFrame;
                             }completion:^(BOOL finished) {
                                 NSLog(@"After second animation frame is: %@", NSStringFromCGRect(view.frame));
                                 [self doFurtherAnimationOnView:view];
                             }];
                     }];
    
}

Expected Results:
Initial frame is: {{0, 0}, {0, 0}}
Final frame should be: {{200, 200}, {200, 200}}
After first animation frame is: {{150, 150}, {0, 0}}
After second animation frame is: {{300, 300}, {0, 0}}


Actual Results:
A green square view appears on screen with no animation.

Version:
iOS 9.3

Notes:
A tiny project that reproduces the bug:
https://github.com/alexgo84/UIViewAnimationBug

Configuration:
iPhone simulator 6s Plus



Reproduces on iOS 8.4 and iOS 9.3.

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!