IOS 7 animation stopped working - ios

Animation frequently stops working in my APP. It may because I did some UI update in background thread and I found someone provide some classes to swizzles some UIKit methods to check if they are called on the main thread.
The linke is as follows:
https://github.com/Cocoanetics/DTFoundation/blob/develop/Core/Source/iOS/Debug/UIView%2BDTDebug.m
The problem is I have no idea how to use it. Anyone used it before? Thank you.

Related

Find cause of: "This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread."

I have a large application that uses a number of third-party libraries and am now seeing the following error in the logs: "This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes."
From what I have found here on SO, this is probably being caused by a UI element being changed on a background thread, which is triggering the autolayout. Unfortunately, we have so many UI elements being changed by so many different moving parts that I do not know the best way to find the culprit.
Can anyone tell me how can I found out what exactly is triggering the autolayout change from a background thread?
Sometimes it's not a completion block, but anything that is performed in the background.
In my case it was notifications that where sent. I implemented iCloud in my app, which means that when data was edited or added on another device, the other app(s) receive an iCloud update/notification, which triggered an update of the UITableView.
The code to update the UITableView was not done in the MainThread. Adding the code as shown in the comments fixes it.

All UIView Transition Animations Stop Working

I have an app who's main view that has 5 modal transitions (presentViewController) and one custom drop down animation ([UIView animateWithDuration:0.15 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^ { ...).
For some reason - potentially connected to updating to the new Xcode 7 beta - after a couple second ALL animations, including the iOS view transitions, stop animating for the entire app.
I'm aware that CALayer has it' own animation thread but I didn't think that it could be blocked.
I can't share code unfortunately, but does anyone have an idea of where to start looking?
I've looked at all the things I can find here and none of the answers seem to be about this particular type of issue.
Thanks
This can happen if you're calling the UI from a thread other than Main.
This one ended up actually being because there was some bad coding on the business logic that was, in fact, blocking the UI thread.
So 1up for Andres Canella. The problem was the blocking of the main thread, only it was business logic blocking it in seemingly unrelated - and difficult to debug - ways.
NEVER BE AFRAID TO REBUILD "TAR BALL" LEGACY CODE!!!!!!!!!!
Also 1up for frakman1 because that's a good reminder.
Thanks all.

iOS unknown delay between animationControllerForPresentedController and animateTransition

I'm having an annoying issue with a custom transition using UIViewControllerContextTransitioning when triggering the animation from a tableView
I followed many tutorials out there, to name a few :
- http://www.brightec.co.uk/blog/ios-7-custom-view-controller-transitions-and-rotation-making-it-all-work
- http://objectivetoast.com/2014/03/17/custom-transitions-on-ios/
This is the exact problem I have (but no solution :/ ): Custom transition animation unknown delay between animationControllerForPresentedController and animateTransition
Sometimes it works, sometimes it's just to slow.
I don't know what happens behind the scenes between animationControllerForPresentedController and animateTransition. If you have an idea on how to debug that I'd like to hear it.
Even without seeing your code I'm pretty sure you having a main thread issue. (see http://www.raywenderlich.com/31166/25-ios-app-performance-tips-tricks#mainthread - understand that, both about not blocking the main thread and always doing UI on the main thread.

iOS 7 animation becomes 0 duration after undetermined amount of time

This is an issue that I've been having since the first beta. I found two threads at the Apple Developer Forums with no solution to it, hoping someone might have the answer here.
Basically, all animations in the app becomes instant including UINavigationController pushViewController UIViewController presentViewController UIView animateWithDuration and etc. after some amount of time (between minutes and hours). I monitored the memory usage and it was fine and nothing came up in the logs. This happens on both the iPhone 5 and iOS Simulator and only on iOS 7.
I know it's not a lot of information, but the problem seems very elusive. I just want to note that the app does use CoreData heavily with GDC calling animation on the main thread.
I also have same problem. Maybe we can find the common points of problem.
Could you let me know which libraries you are using?
I my app with same problem is using following libraries
AFNetworking
HTProgressHUD
MFSideMenu

UIViewController animations stop working

My app runs fine in iOS6, but in an unspecified upcoming version of iOS that I cannot name for NDA reasons, all UIViewController transition animations stop working. New views just pop into place instantly. I am not sure if this unspecified future version of iOS is the cause, as I've seen this happen occasionally in iOS6.
Sometimes animations start working for a while and then stop shortly after, making me think it's some sort of memory warning issue, but my app is using a fairly reasonable ~125MB of RAM at most times. Can anyone offer any advice or things to investigate?
The described behavior has always existed: if you do work on background threads and then call and UIKit methods then more often than not the update will be delayed in a weird way.
Because of this you should always dispatch_async onto the main queue to update the UI.
Those bugs are very hard to catch since they do not always occur predictably.
To catch them I built a method that swizzles some UIKit methods to check if they are called on the main thread. This allows you to stop on a symbolic breakpoint, whenever you have forgotten to dispatch back onto main queue.
https://github.com/Cocoanetics/DTFoundation/blob/develop/Core/Source/iOS/Debug/UIView%2BDTDebug.m
A good workaround from the Apple dev forums on this issue:
Do this:
[UIView setAnimationsEnabled:YES]
And animations start working again. I suspect that this is either a straight up iOS7 bug, or somewhere in my code an animation or UIViewController launch is happening on a background thread, causing animations to stop. Probably unrelated to the unspecified future version of iOS.
This issue appears to be caused by doing UIKit stuff in background threads. I have a pre-render cache full of NSOperations that renders complex UIViews to UIImages to cache the output. This seemed to work fine in iOS6, but probably does cross the line somewhat. I'll need to replace this functionality with something that renders images and text to a graphics buffer rather than using UIViews and UILabels at all.
All you have to do is catch hold of main queue while updating UI on receiving response from an API.Ios uses main queue by default for updating UI but it is not 100 percent efficient.Hence you have to make sure that the UI gets updated on main thread only and the way to do that is as below:
DispatchQueue.main.async{
//UI related code eg:
self.label.text = "abc"
self.button.setTitle("xyz",.normal)
self.tableView.reloadData()
}
If you are not catching hold of main thread animations may or may not work.
But if you are using main thread animations will definetely work.
Correct Code while updating UI on api response:
Alamofire.getApiCall(paramaters: parameters, completion:{
response in
// UI related code.
DispatchQueue.main.async{
self.label.text = "abc"
self.button.setTitle("xyz",.normal)
self.tableView.reloadData()
}
})
Incorrect Code which may cause animations to stop and lead to weird crashes:
Alamofire.getApiCall(paramaters: parameters, completion:{
response in
// UI related code.
self.label.text = "abc"
self.button.setTitle("xyz",.normal)
self.tableView.reloadData()
})

Resources