iPad, iOS6 very long delay between viewWIllAppear and view appearing on the screen

≯℡__Kan透↙ 提交于 2019-12-01 11:51:00

问题


I'm working with a fairly complex storyboard based iPad app. My workflow is as follows A collection view pushes another view, which presents another view modally.

The 3rd view which is presented modally is fairly complex and has 19 subviews, some of them are image views. The app does a lot to organize the view hierarchy within viewDidLoad. There's nothing else within viewWillAppear or viewDidAppear.

What bothers me is if I put logging statements within viewDidLoad, I see that viewDidLoad completes within 1.5 seconds of the user initiating a storyboard segue. Then the viewWillAppear is called. After that, the screen is sitting there for somewhere between 3 to 80 (yes, eighty!) seconds. Sometimes the view appears relatively fast, other times it takes a long time.

Is this a symptom of my viewDidLoad taking too much memory? In other words, is the delay because iOS cleans up enough memory to make my view appear?

After hitting the stop button in xCode, I restart the app, perform the sequence of steps to present the view controller, here's the first run:

/

/80 seconds!
    2013-03-27 22:56:30.311 iconmaker[2076:907] -[GLFirstViewController viewWillAppear:] [Line 597] viewWillAppear
    2013-03-27 22:57:50.351 iconmaker[2076:907] -[GLFirstViewController viewDidAppear:] [Line 604] viewDidAppear

//after popping the view controller and repeating:
//less than 2 seconds
2013-03-27 22:59:23.698 iconmaker[2076:907] -[GLFirstViewController viewWillAppear:] [Line 597] viewWillAppear
2013-03-27 22:59:24.306 iconmaker[2076:907] -[GLFirstViewController viewDidAppear:] [Line 604] viewDidAppear

Update: After turning the device off, then starting it again, the view controller is displayed very fast, less than 2 seconds again on the first run. Here's the allocations profiling after pushing /popping the controller 4 times.

Is this a memory freeing issue?


回答1:


After profiling the app, I figured out that two issues were at play:

1) I was saving large UIImages as binarydata into coredata, which should not be done if NSFetchedResultsControllers are used, as they pulled out all of the image data and kept it in memory.

2) iOS6 has changed the way viewDidUnload works - it is never called, so I added some calls to manually free up objects when my view controller disappears.

The end result is that the memory footprint is at around 4mb baseline now, getting higher as I push the previously offending controller. Additionally, I can push/pop the controler mulitple times without out of memory crash.



来源:https://stackoverflow.com/questions/15673536/ipad-ios6-very-long-delay-between-viewwillappear-and-view-appearing-on-the-scre

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!