2

I am keeping a close eye on the start time of my app in development. In main I store the start time using CFAbsoluteTimeGetCurrent() and log elapsed time when didFinishLaunchingWithOptions gets called, as well as during the initialization and painting of my StopWatchView and finally in the viewDidAppear of the main view controller. This served me very well in figuring out where my start time goes and keeping it in check. My startup performance tests on actual devices were done on iPhone 3G (iOS 4.2.1) and iPhone 4.

Since upgrading the device to iOS 5.1 I was forced to upgrade the Xcode to the version 4.3.1, too. I have immediately noticed that the start times on iPhone 4 changed dramatically. All measurements were performed with Xcode attached for debugging, reading the elapsed times from logs in console. Now I've also added debugging label that displays elapsed time to be able to measure without debugger attached.

To eliminate the possibility that the change was caused by something in my code, I've created new Utility Application and confirmed the slowdown. The iPhone 4 used to be ~3x faster than iPhone 3G, now it starts slower(!!!) than 3G. The startup time has also become highly volatile (+- 0.3s), where it used to be +-0.05s. The volatility disappears in Airplane Mode, so I suspect it's caused by some background process related to iCloud. However I'm very puzzled by 3x slower startup time on iPhone 4 before and after the upgrade.

Here are the average startup times, first during debugging in Xcode (then without Xcode):

             Debug   No-debug
iPhone 3G:   1.23s   (0.67s)  
iPhone 4:    0.43s   (-----)  [iOS 5.0.1, Xcode 4.3]
iPhone 4:    1.53s   (1.18s)  [iOS 5.1, Xcode 4.3.1]

iPad 2:      0.41s   (0.22s)  [iOS 5.1, Xcode 4.3.1]

I don't know if this is caused by iOS 5.1 or Xcode 4.3.1 or if this is iPhone 4 specific problem. Does anybody see similar slowdown?

Palimondo
  • 7,281
  • 4
  • 39
  • 58

1 Answers1

1

On further investigation, I have noticed during profiling (after watching WWDC 2012 Session 235 "iOS App Performance - Responsiveness") that the time difference I have noticed is attributable to the call to _UIAccessibilityInitialize.

I have been testing the accessibility of my app and have enabled Settings > Accessibility > Tripple-click Home > Ask. This coincided with the release of the 5.1 update and I have erroneously attributed the problem to the new version. I guess that the OS has to initialize the accessibility machinery, so that you can turn on the VoiceOver anytime, without it needing to restart all open apps.

The performance impact of enabling accessibility is not clearly documented, as far as I know. So, to save other performance and accessibility conscious developers this surprise, know that even with Tripple-click Home set to Ask, you pay the cost of _UIAccessibilityInitialize.

I'm also about to devise a scheme to do my custom accessibilityLabels lazily, as they too, are having non-negligable impact on the responsiveness of my app in normal use. I guess there is no free lunch after all ;-)

Palimondo
  • 7,281
  • 4
  • 39
  • 58