iPhone Simulator suddenly started running very slow - ios

I have been working on an app in iphone simulator for a number of weeks and it has been running well up until now, but all of a sudden has begun running very slow both when loading content and animations. I have not made any changes to my code since I last tested it successfully.
I tried restarting the simulator (multiple times) and removing the app and doing a completely clean rebuild, but no luck. I also checked my cpu usage through the monitor while the simulator is running and I am only using about 30% of my cpu and 40% of memory.
I fully understand that the simulator is never a quick as the device itself, but it seems strange that it has suddenly started running slow after such a long time, and by slow I mean less than a quarter of its original speed.

In the iOS simulator, at the bar on the top, click on Debug → Toggle Slow Animations (or Slow Animations with Xcode 10+). Chances are you accidentally toggled it on.

Simple Command + T will fix this problem.
Command + T toggles the simulator's Slow Animations, which can be found under the Simulator Menu: Debug -> Slow Animations.

Go to the simulator's Debug menu and select "Toggle Slow Animations".
Update: In Xcode 10, it's just "Slow Animations":

Select Simulator,
Select Debug and uncheck slow animation.
shortcut
command + t
That's work for me.

If the Cmd-T (slow animations) option doesn't work for you and Debug -> Slow Animations is off but you still have slow animations try Simulator -> Reset Contents and Settings (or possibly Hardware -> Erase All Content and Settings). That worked for me when none of the other answers in here did. Anyone have a suggestion as to why?
Also having a debugger attached (at all) may make the animations very slow.

Another potential fix for React-Native users:
Chrome de-prioritizes Javascript running in any tabs not in the foreground. So if you have enabled remote debugging, be sure to put the debugger in its own window.

You accidentally pressed the slow animation on debug when using simulator.
So Run Simulator -> Debug -> Uncheck Slow Animation.

I think you pressed command + T instead of command + R by mistake.

I don't have the rep yet to leave a comment, but I upvoted some answers here and wanted to say more. I had a problem with slow animations in the iOS Simulator, especially on rotation, and I found this post via Google. Indeed, somehow "Toggle Slow Animations" must have been on, because three shifts fixed it. At first, I didn't think this was a problem because there's no checkmark next to "Toggle Slow Animations." It turns out there's never a checkmark, or any indication from the menu whether it's on or off. So just try toggling it and see if the rotation/navigation is faster/slower.
So, thank you!

Simulator -> Reset contents and settings works for me. The issue seems to reappear when I debug my react-native code remotely. It could also be to do with AsyncStorage as nomad suggested.

It is NOT only about slow animations. Xcode simulator has extremely low performance in global. It is Apple's bug. I have reported it via Feedback Assistant. I have created demo with code demonstrating that simulator is 200 times slower than any old real device. I have found that JavaScript code with Date object executed in WKWebView is pain for simulator. Changing options in simulator does not help in my case. See jsfiddle https://jsfiddle.net/kjms16cw/ I hope Apple will fix it soon!
var log = document.getElementById("log");
document.getElementById("button").onclick = function() { run(); };
function run() {
var d1 = new Date();
for (var i = 0; i < 1000; i++) {
var x = new Date();
x.setMilliseconds(0);
x.setSeconds(0);
x.setMinutes(0);
}
var d2 = new Date();
log.innerHTML = ((d2.getTime() - d1.getTime()) / 1000) + " seconds";
}
<h3>Xcode Simulator Extremely Low Performance</h3>
<p>This test runs fast (several tens milliseconds e.g. 30 ms)
in any browser any device any platform including very old iOS device
e.g. iPhone 5C and several years old iPad 2, BUT IN SIMULATOR IT TAKES 6000 ms
(yes, 6 seconds!). Terrible!</p>
<button id="button">run()</button>
<div id="log"></div>

You can try to turn off remote debugging (Cmd-D -> Stop Remote JS Debugging). That usually speed things up.

When the chrome debug is active and the browser tab is not in the foreground, the emulator is slow too. For me, I decided to put the guide in the foreground.

Go to menu of simulator
Device -> Restart
Then everything faster than you think -_-

Related

Swift: XPC connection interrupted and app freezes?

Ok, have no idea what is going on here but from what I understand from other questions
(XPC connection interrupted in Xcode 7 for iOS 9) , XPC connection interrupted means theres a storyboard problem. Per a similar answer I opened the storyboard as source code and looked for repeated
<keycommand>
tags, but there aren't any. I had to copy and paste a storyboard from another project since something changed, and I believe this caused it. What are my options here? What could be causing this freeze since there aren't any weird tags that I can see?
Same problem, getting the XPC error when tapping in a (SwiftUI) Text Field. Different solution:
Simulator > Device > Erase All Content and Settings
As described here,
The problem came from the keyboard that wasn't showing up. And I am not really sure why, I probably pressed a command that disables it.
To get it to work I have restarted the simulator. In the simulator menu, Hardware > Erase All Content And Settings
Now when I tap in a UITextField, the keyboard shows up and I don't get the "XPC connection interrupted" error anymore. Everything works fine.
This error was incredibly frustrating because there is no crash report, just a one-line "XPC connection interrupted" and the app freezes. And, to complicate things, it's apparently possible to get this error from some wildly differing causes -- various discussions have cases of VPN's, Bluetooth, and threading generating this. And of course -- Murphy's law -- I started getting the error after having implemented something utterly unrelated, but which has me troubleshooting threading & Core Data issues, all to no avail.
Hopefully this can help somebody else with the quick fix.
The problem for me was that there are two storyboards, the main storyboard and the launchScreen storyboard. If you go to the top left of Xcode and click on the Xcode file, it will bring you to a screen about the file. You then scroll to deployment info and switch the main interface to whichever storyboard you use. I think that since you copied and pasted the code is not linked up to the storyboard.

Appium: iOS, real device, driver.hidekeyboard() doesn't operate

I'm using Appium on Mac OS with iPhone 5S with operation system 9.2.
When i'm trying to hide the Keyboard with the method:
driver.hidekeyboard();
Nothing happens and the application crash.
Need help please
Thanks
Ohad
If in case your application is crashing on when you are trying to hide the keyboard, then that could be a possible bug you are looking at and to understand the cause of that and get it fixed would be the topmost recommendation. Your statement
driver.hidekeyboard();
is good enough for what you desire out of the execution assuming the driver used is AppiumDriver or its subclass.
Also if you are sure that the keyboard is displayed and you can even manually hide the keyboard, a forced way to do that is as #Gaurav has suggested in the comments using the following code :
driver.navigate().back();
In case of uncertainty of the visibility of keyboard, you can give this a try :
driver.getKeyboard();
driver.hideKeyboard();

Solving Rendering Artifacts in Frame Buffer with WebView and EditText on Android 5.0?

After upgrading Nexus 5 to Android 5.0, an activity with default focus on an EditText does not render correctly (EditText repeats down across the screen with grey dots in between and if you click again or dump the ViewHierarchy with UiAutomator, it will return to normal rendering).
(I would upload the image, but don't yet have reputation for images).
NOTE: This is ONLY after I have loaded a WebView within the application (though in a separate activity). The same screen renders correctly prior to loading the first WebView in the application.
NOTE: This is ONLY a problem on Android 5.0 and (so far) on Nexus 5. I do not have another 5.0 (non-nexus) device to try.
EDIT: This also happened on HTC One with Android 5.01.
NOTE: I have tried disabling hardware acceleration, modifying inputMode, and defaultFocus.
Has anyone seen or solved this problem?
Ended up solving this by changing softInputMode (similar to previous WebView/Keyboard issues, but this time with a native View and EditText).
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
I had a similar issue on Lollipop 5.0.1 devices. My solution was to deactivate hardware acceleration in the WebView on these devices before loading any content with loadURL or loadData.
int SDKversion = android.os.Build.VERSION.SDK_INT;
if(SDKversion >= android.os.Build.VERSION_CODES.LOLLIPOP){
webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
If you do not want to do this, I could also drastically reduce the problem by adding a visibility="gone" webview to the disturbed activities and then calling something like:
webview_dummy.loadData("<head></head><body></body>", "text/html", "utf8");
after the loadURL of the actual webview.
Man, this is really some weird bug!
What solved my problem was to disable the hardware acceleration only on the activity which hosted my fragment. Not on the whole app, but specifically on that activity.

Dismiss alert on initial launch on iOS simulator

I'm working on the automated UI tests for my app and I'm having trouble when trying to set up the environment for running the tests. The plan is roughly this:
build the application
shutdown simulator if running
erase the simulator to make a clean install
install my app on the simulator
run UIAutomation tests
Everything is working except when the application is launched by instruments to execute the tests, the alert appears to ask if the user allows notifications. This is all as expected, but I can't find the way to get rid of the alert.
Things I have already tried:
creating onAlert as a first thing in my test script, in case it appears before the my alert callback is defined
delay the target by 5 seconds in case the tests actually run even before the UI of the app is visible in the simulator
I also went through all the permutations of the above that can be found on SO, I never get my onAlert callback invoked, no matter what I do. So another thing I tried was:
try dismissing the alert with applescript
The script I wrote:
tell application "System Events"
tell process "iOS Simulator"
set allUIElements to entire contents of window 1
repeat with anElement in allUIElements
try
log anElement
end try
end repeat
end tell
end tell
and it displays:
static text “MyApp” Would Like to Send You Notifications of window iOS Simulator - iPhone 6 - iPhone 6 / iOS 8.1 (12B411) of application process iOS Simulator
static text Notifications may include alerts, sounds, and icon badges. These can be configured in Settings. of window iOS Simulator - iPhone 6 - iPhone 6 / iOS 8.1 (12B411) of application process iOS Simulator
UI element 3 of window iOS Simulator - iPhone 6 - iPhone 6 / iOS 8.1 (12B411) of application process iOS Simulator
Looks like the buttons are placed inside the "UI element 3" but I can't retrieve any elements from inside it, let alone clicking on it. So I checked with Accessibility Manager:
It sits there as one of the children, the other ones are notification title and message. But when I go to that element, it is highlighted and I see this:
It is identified as generic element, it doesn't have any children...
The interesting thing is when I choose the OK button in the Accessibility Inspector, I can actually see it's a child of the window, yet it is never listed:
Can someone please shed some light on what is going on here? How can I press that button with Applescript?
If you are doing automation using Instrument, the you will need to register callback (onAlert) for performing any action on alerts.
But the problem in your case is that the alert appears before your script actually start executing and at that time no callback is registered for alert.
So if the alert can come with a delay of around 10 sec when you start application, then only it can be handled. But this can only be controlled through source code and not by your Automation code.
So only option which is left is you need to manual dismiss the alert once fresh application is installed
I am also facing same problem and found it to be a limitation of the tool
There are too many limitaion of this tool and thats why i shifted to UFT
I had a similar problem. I just wanted position of the last control on the alert. So I came up with following piece of code:
on get_simulator_last_object_rect(simulator_index)
tell application "System Events"
set ProcessList to (unix id of processes whose name is "iOS Simulator")
set myProcessId to item simulator_index of ProcessList
tell window 1 of (processes whose unix id is myProcessId)
-- Forcefully print the UI elements so that Accessibility hierarchy is built
UI elements
-- Then wait precisely to let the Accessibility view hierarchy is ready
delay 0.5
set lowest_label_lowest_position to 0
set _x to 0
set _y to 0
set _width to 0
set _height to 0
repeat with element in UI elements
set {_x, _y} to position of element
set {_width, _height} to size of element
set current_control_lowest_position to _y + _height
if current_control_lowest_position > lowest_label_lowest_position then set lowest_label_lowest_position to current_control_lowest_position - _height / 2
end repeat
return {{_x, _y}, {_width, lowest_label_lowest_position}}
end tell
end tell
end get_simulator_alert_ok_button_position
I have a desktop app to control my actions. I use this apple script in my Desktop app to get the frame of the last control. Now that I have the frame, I create a mouse event and perform click on the frame, after activating the simulator.
Although I have not yet tried, but I am pretty sure that you can create mouse events from apple script and perform click on the frame / center of the frame.
Hope this helps.
Thanks,
RKS

iOS UI Automated Testing: How to pull down, drag or scroll in a CollectionView?

I am testing my app with the UI Automated Testing framework. I have a UIACollectionView I would like to pull down or drag my CollectionView. I already tried the ways from the documentation:
to drag up
target.dragInsideWithOptions({startOffset:{x:0.5, y:0.9}, endOffset:{x:0.5, y:0.2}, duration:2.0});
or to pull down:
target.dragInsideWithOptions({startOffset:{x:0.5, y:0.3}, endOffset:{x:0.5, y:0.8}, duration:2.0});
when this didnt work I tried to use the inheritated methods of the UIAScrollView. chatList is my UIACollectionView
archivedChatCell = chatList.cells()["Noise"]
archivedChatCell.scrollToElementWithValueForKey(1, "isVisible")
chatList.scrollDown()
chatList.scrollToElementWithPredicate("Noise")
But nothing is moving in the screen. I read in some threads that this (dragInsideWithOptions) is a Apple problem that needs to be fixed for the iOS7 UI Testing.
Does someone have any idea what the problem is? Am I missing something or is there a work around for that?
The weird thing is, I am using the same code in a different CollectionView in my App, the dragInsideWithOptions works fine and drags or pulls the screen.
thank you
Yes, dragInsideWithOptions and flickInsideWithOptions are not working on the simulator. However, they do work on a real device. Therefore, my suggestion is to use a real device until Apple fixes the problem.

Resources