13

Starting from iOS 9 (I used Xcode 7.0 beta 6 (7A192o)), an Objective-C app with UITextView will hang if the text view's text is less than 10 characters. CPU usage goes up to 99-100% and the whole system hangs.

How to reproduce:

  1. Create a brand new single view app from template (or anything else).
  2. In storyboard, add a UITextView with default settings anywhere in the main view.
  3. Set the text to a string that is less than 10 characters long.
  4. Launch the app in simulator (any device, as long as it's iOS 9).
  5. Upon launch, before displaying the single view, the system will hang and CPU usage will go to maximum forever.
  6. Set the text to any other text that's more than 10 characters and the app runs correctly.a

Looks like constraints or any other settings do not affect this behaviour.

The immediate solution would be to simply not have less than 10 characters, but, well, that's lame.

You can check out this github repository that also demonstrates the problem.

I also submitted a bug report to Apple (bug no. 22736256, although you probably can't see it there yet).

Weirdest. Bug. Ever.

Is anyone also encountering this one??

mllm
  • 17,068
  • 15
  • 53
  • 64

4 Answers4

9

Took me half a day to narrow the error down to a UITextView. This has got to be the stupidest bug ever.

You don't need to ensure that the UITextView holds at least 10 characters. Just adding a default of at least 10 characters to the UITextView in Interface Builder will fix the problem. Then, you can empty the UITextView using code.

By the way, this is an Xcode 7 bug, not an iOS9 bug. New builds built using Xcode 7 will create the same problem in iOS7 and iOS8.

Lai Xin Chu
  • 2,462
  • 15
  • 29
  • 2
    I also just lost 3 hours on this bug. You know, when you wade through all the sales talk you get to hear in the WWDC videos, and then see the *real* state of their IDE and technology... it's just unbelievable. – Thomas Wana Oct 19 '15 at 16:59
1

Refer the blow. It is a bug in Xcode 7 and still has not been fixed.

http://xcode7criticalbug.blogspot.in/2015/10/uitextview-bug-in-xcode-ios-app-getting.html

It can overcome by programatically setting the text property for UITextView.

Mithun Ravindran
  • 2,292
  • 2
  • 14
  • 23
  • 1
    Right, I posted also a link there to this question, as we're expecting the solution to probably come up here – mllm Oct 21 '15 at 13:07
1

According to the release notes of Xcode 7.1.1 this should be fixed now:

Storyboards and nibs containing UITextView elements with between 1 and 11 characters no longer hang when loaded on iOS. (23264732)

Thomas Wana
  • 837
  • 2
  • 8
  • 19
-2

i have found the solution first check the memory leak and please add the this line of code in particular class.

-(void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:YES];

}

This is helpful for me my problem is resolved.

Amit Srivastava
  • 1,105
  • 9
  • 18
  • This is not recommended as you're overriding the `animated` param to `super`. What if `animated` needs to be `NO`? – mllm Jan 20 '16 at 13:16