Showing the keyboard in an app the first time is very slow

Originator:dieter.komendera
Number:rdar://18465821 Date Originated:26-Sep-2014
Status:Open Resolved:
Product:iOS Product Version:8.0.2 12A405
Classification: Reproducible:Always
 
Summary:
With iOS 8 we're getting numerous user complaints about our apps having a significant lag when tapping a text field. When investigating I found that the lag is mostly attributed to slow initialisation of the keyboard.

On an 3rd gen iPad Instruments Time Profiler reports up to 500ms running time before the keyboard is first shown. But the lag is still very noticeable on an iPad Air as well.

I've a attached a sample app and a sample Instruments trace showing the cpu spike at around the 10 second mark.

Most time is spent here:

Running Time	Self		Symbol Name
424.0ms   38.2%	0,0	 	           -[UIKeyboardSliceTransitionView _delayedUpdateTransition]
289.0ms   26.0%	0,0	 	            -[UIKeyboardSliceTransitionView refreshKeyplaneImages]
104.0ms    9.3%	1,0	 	            -[UIKeyboardSliceTransitionView rebuildSliceTransitions]
19.0ms    1.7%	0,0	 	            -[UIKeyboardSliceTransitionView rebuildMoreIntlKeys]
6.0ms    0.5%	0,0	 	            CA::Transaction::commit()
2.0ms    0.1%	0,0	 	            -[UIKeyboardSliceTransitionView rebuildShiftSlices]
2.0ms    0.1%	0,0	 	            -[UIKeyboardSliceTransitionView rebuildBackgroundAndShadowTransitions]
1.0ms    0.0%	0,0	 	            -[UIKeyboardSliceTransitionView rebuildPositionTransition]
1.0ms    0.0%	0,0	 	            -[UIKeyboardSliceTransitionView rebuildReturnSlices]

While this also takes a significant amount of time:

Running Time	Self		Symbol Name
112.0ms   10.1%	0,0	 	                         -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:]
72.0ms    6.4%	0,0	 	                          -[UIKeyboardImpl setDelegate:force:]
60.0ms    5.4%	0,0	 	                           -[UIKeyboardImpl updateLayout]
6.0ms    0.5%	0,0	 	                           +[UIDictationController keyboardWillChangeFromDelegate:toDelegate:]
2.0ms    0.1%	0,0	 	                           -[UIKeyboardImpl takeTextInputTraitsFromDelegate]
2.0ms    0.1%	0,0	 	                           -[UIKeyboardTaskQueue continueExecutionOnMainThread]
1.0ms    0.0%	0,0	 	                           -[UIKeyboardImpl recomputeActiveInputModesFromList:]
1.0ms    0.0%	0,0	 	                           -[UIKeyboardImpl setAutocorrectSpellingEnabled:]
38.0ms    3.4%	0,0	 	                          -[UIPeripheralHost(UIKitInternal) _inputViewsForResponder:withAutomaticKeyboard:]
38.0ms    3.4%	0,0	 	                           +[UIInputViewSet inputSetWithKeyboardAndAccessoryView:]
37.0ms    3.3%	0,0	 	                            -[UIPeripheralHost automaticKeyboard]
1.0ms    0.0%	0,0	 	                            -[UIViewController view]

Steps to Reproduce:
1) Profile the attached sample app on a device with the Time Profile
2) tap the text field
3) Inspect the Time Profilers track

Expected Results:
Keyboard slides out with no noticeable lag

Actual Results:
Up to 500ms lag before the keyboard is shown on older devices. Up to 200ms lag on an iPad Air, which is still pretty bad.

Version:
iOS 8.0.2 12A405

Notes:


Configuration:
iPad 3 MD370FD/A

Attachments:
'keyboardlag.trace.zip' and 'Keyboardlag.zip' were successfully uploaded.

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!