EarlGrey Freezes Animation And Doesn't Call Callback - ios

There is a method with an asynchronous block as a parameter.
The first time the app runs, this method is called, and there is an animation that covers the entire screen. The method is making a network call that can take a pretty long time, around 7 seconds or so. When the block runs, the callback ends the animation and the app is ready to be interacted with again.
When I run the app in the simulator and tap around, everything runs as it should. When I run the EarlGrey test target, the animation freezes, and the test ultimately fails, because there is an element that can't be found. Behind the animation view (a subclass of UIView), some steps are still successfully carried out, even though the elements are not visible.
Lastly, this only happens on the first run of the app, since the network call in subsequent test runs is much shorter.
I've tried changing configurations to disable animations, and nothing seems to work for me. I can't really paste code, since the app is proprietary.
I'm happy to answer any and all clarifying questions, and very much looking forward to some help!

Disclaimer: This was all #khandpur. I joined the Google Open Source Slack channel, and he helped me debug hard.
The issue was the use of Facebook's Shimmer. I had this line in the setUp method:
[UIApplication sharedApplication].keyWindow.layer.speed = 100;
This was speeding up animations, but causing some conflict with shimmer, not too sure why. I'm going to comment in their repo.
I deleted that line, and while tests are a little slower, they're totally stable now.

Have you considered using kGREYConfigKeyURLBlacklistRegex to black list the URL, i.e prevent EarlGrey from waiting on the request? (assuming that the network wait is unnecessary for ur test). see EarlGrey/Common/GREYConfiguration.h

Related

Having trouble with AppDelegate didFinishLoadingWithOptions execution order/timing

I'm having an issue with this code (I have it in didFinishLaunchingWithOptions). I need it to finish executing the code inside before the app continues because it sets up some critical things in core data. It sends this to the background though and starts running the rest of the app and it doesn't finish quick enough for the data to be usable.
DataManager.getDataWithSuccess { (data) -> Void in
//code to execute here
}
How can I force the app to wait for this code to finish before moving on?
You shouldn't block the didFinishLaunchingWithOptions method from returning so that it can wait on an asynchronous task. It's crucially important to note that iOS applications are only given a limited amount of time to complete launching before the application is killed by the operating system.
An approach I have used in the past when waiting on asynchronous things to happen that need to happen before I really launch my app is to create a LaunchViewController. The interface for this view controller matches perfectly to the app's splash screen. From an end-user perspective, you can't even tell we've left the splash screen.
Here, we do any set up code such as asking your DataManager to get data. Then, when it (and any other set up actions) completes, you simply present the next view controller in much the same way you'd move between any other view controllers.
A huge positive side effect here is that you can have much nice looking animations from your splash screen into the first screen of your application.

Game programming in Xcode and Sprite-builder. Display while computer "thinks"

I am working on an app for a physical boardgames I have produced in the past. Everything is working fine (for now). But the app "freezes up" when the code for the computer "thinking" kicks in.
This is understandable, the computer needs time to make it's turn.
My question is. Is there any way I can simultaneously set an animation to run (like a progress icon), while the computer continues to "think" over it's turn?
Thank You.
You can't make something like a progress bar which indicates exactly when the computer will finish 'thinking' exactly because the computer does not know when it will be done.
However, you can create an animation that will run as long as the computer 'thinks'.
In your Gameplay file in Spritebuilder, create the animation that you want shown while the user waits. Chain this animation timeline to itself. Let's call the default timeline animation 'default' and the 'computer is thinking' timeline animation 'think'.
Inside the method you use to start the computer's turn, add a line of code that warns cocos2d to run the 'think' animation sequence; it would also be good to make any user interaction with the game impossible at this time (example below is given in Swift):
animationManager.runAnimationsForSequenceNamed("think")
self.userInteractionEnabled = false
Since the 'think' timeline was chained to itself, it will run in an infinite loop, only stopping once cocos2d receives an instruction to break that timeline and start executing another one, so, just inside the method you execute once the computer's turn is over, add these two lines in order to stop the 'think' animation from running and to enable user interaction once again:
animationManager.runAnimationsForSequenceNamed("default")
self.userInteractionEnabled = true
Not knowing where you are building your actual game in, using different threads is the way to go. What are you building your game in? Which language, framework, platform?

iOS Launch Screen Animation Time

It seems like the fade animation between the launch screen and my first view is really slow.
I don't think it used to be like that. Is there a way to control the speed of that transitional animation?
I looked at some apps on my phone and the launch screen doesn't fade as slowly as mine. What things could I have done to affect that?
(No I don't have slow animations turned on, only the fade animation is slow)
In WWDC 2012 video iOS App Performance: Responsiveness they enumerate a whole list of issues that have impact on the app startup time, ranging from attaching to unnecessary frameworks, optional linking to frameworks that you really could make required, the use of static initializers, overly complicated initial scenes, too much information stored in preferences, etc.
That video covers a range of topics, like the above, which impact startup time. In the demonstration, they show how one might benchmark the startup time. Unfortunately, in my experience, there's a good chance that you might not be able to do anything to fix this issue (e.g. you need certain features and therefore need certain frameworks), but it's still an illuminating video and it might give you some ideas of things you can try to alleviate the start-up performance issues.
If your app splash screen show more time, so please check following things in your app.
1. AppDelegate.m
in didFinishLaunchingWithOptions method have you called any heavy method which takes more time for finish task if yes then change that method location, basically in appDelegate class don't write any heavy methods.
2. first view of your app.
check viewDidLoad() method, if you call many method or any heavy method from here then your launch image will show still your control not come out from viewDidLoad method, so if you want call any methods at view launch time then call them from viewWillAppear or viewDidAppear method (in viewDidAppear method don't call any UI related methods)
I never figured out what was going on here, but the next day when I started up xCode and the simulator it was back to the normal loading time.

UIWebView async requests blocks scrolling

I've been searching for something like this in SO and nothing came up. So i've decided to ask for the first time here.
I'm working on an iOS project. I have a UIWebView working fine with a NSURLRequest. But, when i load a URL with multiple asynchronous requests (i.e. wsj.com) like ads and Facebook likes stuff; the scroll interaction of the web view becomes laggy and unresponsive.
I've been debbugging and that happens when the delegate method shouldStartRequest is executed (several times)
First shoot: using threads. Didn't work.
Second shoot: playing with web view properties of interaction.
Third shoot: tried to stop the unnecessary calls (my business rules doesn't need them) didn't work. Even if i kill them, the laggy effect remains.
The curious thing about all this is that Safari renders and works fine with the same URL.
I'm looking for thoughts, does anybody has some clue of what's happening here?
Thanks!!

jQuery queue animation speeds up after stop and restart

edit: when I add .stop() right before I call .clearQueue(), it works correctly. Don't know why though, I thought they were basically doing the same thing.
I have a jQuery animation that animates the background of each character in a span, that makes it basically look like a loading bar of some kind (the animation is in a queue).
Check it out here: http://jsbin.com/efawub/4/edit#preview (for one reason or the other it does not work in FF for me)
Issue is the following:
Hit play, then hit stop quickly after; then hit play again: the animation now runs faster than it should, (most promiment in the first span)!
Compare this to a normal run: hit play, let it run til the end, hit stop, hit play again: normal speed
The phenomenon also goes away when you wait a few seconds after hitting stop and pressing play again; the problem is also less prominent when you stop the animation towards the end, instead of towards the beginning.
Any ideas?
I finally wanted to address this. The solution was to use standard javascript, not jquery (I still don't know why it happens with jquery). A simple setTimeout loop did the trick. I updated the original jsbin, and left the old code commented out.

Resources