views behind modal view controller not properly redrawn after memory warning

Number:rdar://10529236 Date Originated:2011-12-05 4:22PM
Status:Open Resolved:
Product:iPhone SDK Product Version:iOS 5 SDK, Xcode 4.2
Classification:UI/Usability Reproducible:Usually
05-Dec-2011 04:22 PM William Gray:

Starting in iOS 5 SDK: when an application presents a modal view controller on applicationWillResignActive (in my case, a login view controller to hide the application view so that only the login view controller is visible on applicationDidBecomeActive), and the app receives a memory waring while in the background, once the application is resumed and calls applicationDidBecomeActive on the app delegate, the modally-presented view controller from applicationWillResignActive is visible, but when it is dismissed it will often only reveal a blank screen instead of re-drawing the application view on which it was presented. 

This sequence worked fine on iOS 3 and 4, and works fine on 5 as long as the app doesn't receive a memory warning in the background. To fix the problem, I have to avoid presenting a view controller modally on applicationWillResignActive, which is problematic for my apps.

Steps to Reproduce:

0. On a Mac with iOS SDK 5 and Xcode 4.2 installed, launch

1. Download the demonstration project for this issue and open in Xcode 4.2

$ git clone git://
$ cd ./viewWillNotAppear
$ git checkout d856f227dc7d17bbb6d80822177918835f8050ba
$ open viewWillNotAppear.xcodeproj/

2. Set Scheme to iPhone 5.0 Simulator and Run

3. When the app appears in Simulator, the "login" view is visible. Tap the login button to dismiss it and reveal the app view.

4. Background the app by hitting the Home button on the Simulator

5. Hardware menu -> Simulate Memory Warning

6. Tap the viewWillNotAppear icon in the Simulator so that the app becomes active again

7. The login view should appear. Tap the login button to dismiss it. 

Expected Results:

At the end of step 7, you should see the app view, it should look no different from how it appeared after dismissing the login view in step 3. 

Actual Results:

Instead of the app view, you will often see a blank white screen once the login view is dismissed. Not always, but very often. If you repeat these steps without number 5., where you simulate the memory warning, the problem doesn't occur at all.


This was not a problem in iOS 3 and 4. In Build Settings, change Deployment Target to iOS 4.3, set iPhone Simulator 4.3 the active Scheme and re-run the steps: the problem will not occur. We've been using this setup in two apps we have in the iTunes store, and both those apps will exhibit the same problem if you perform these steps with them (net.zetetic.Strip and net.zetetic.Codebook). 

I have not tried this in the beta SDK for iOS 5.1.


The Git repository downloaded in the steps above contains a work-around that's not quite ideal, which you can view here on the web as a diff: The gist of it is that you simply _must_ avoid presenting a modal view controller during applicationWillResignActive in order to avoid the screen-blanking that a memory warning will cause while the app is in the background. The problem with this, though, is that the screen flashes blank instead of properly animating during app-switching, and says blank while the multi-task chooser menu is activated. This itself can be cheaply worked around by drawing an image as a background color on the UIWindow so that at least it's not blank, an interim screen, a la Default.png.

If you wish to update your local clone of this demonstration Git repository to see the fix plus changes we've made since then, you can simply checkout the source to the master branch: `git checkout master`.

Thanks for taking the time to look all this over! Fixing this bug would mean a lot to us.


I've run into this as well. If you have any modal VC presented over a TabBarController and a memory warning occurs while the app is in the background, when you resume and dismiss the modal the current tab's view is not refreshed. Have you submmitted this to Apple and/or heard anything from them? thanks.

Was asked to upload demonstration app for the bug (rather than my git checkout instructions), did so this morning.

By billymeltdown at Jan. 3, 2012, 3:14 p.m. (reply...)


I took a look at your project and you are using a UITabBarController. I found a workaround for my case, should work for you as well. See for details.

Thanks for the link, Russell! I've got a work around, too (just checkout the sample project to master). Hopefully, this will get fixed soon, haven't heard anything back since I uploaded a zip of the demonstration project.

By billymeltdown at Jan. 11, 2012, 11:14 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at 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!