5

Developing an iPhone app.

I've got a really strange problem where, every once in a while, the status bar at the top of my app screen will turn solid black. Not like the black version of the status bar, but like a solid black rectangle with NO text/icons. It's very rare, but usually seems to occur after returning to the app via multi-tasking or from a locked device (the app has been running in the background). I've seen it occur on both 3GS and iPhone4. Here's a screenshot:

enter image description here

I can never reproduce it when trying, it just seems to eventually happen at some point (sometimes it will go for days without happening).

Once it does occur, the app seems to continue functioning fine, even with the status bar gone, except for when I do one specific action in the app which will cause everything to freeze up all the sudden (the app doesn't crash, but everything on screen is frozen and non-interactive). Without explaining the design in detail, the specific action that causes it to freeze up (after the bug appears) is performing a simple upload in the background to a SQL database. Resetting the app is the only way to fix the problem once the black status bar appears.

Anyone else ever experienced this? I can't find a single thread anywhere explaining similar behavior, and it's driving me nuts.

Blitz
  • 5,521
  • 3
  • 35
  • 53
Gabe
  • 163
  • 2
  • 7
  • What's this specific action which causes the app to freezes? Did you already check the memory consumption? – Pascalius Feb 24 '11 at 23:06
  • Pascalius, I'm waiting to hear back from my developer regarding memory consumption and the specific action that causes it to freeze. It's iOS 4.2.1 on every device that has reproduced the bug. I just did a bunch of testing and reproduced the bug 3 different times all after returning to the app (running in the background) from a phone call. That seems to have something to do with it, but it's completely inconsistent. I did it probably 50 times (went from phone call to app) and the bug only occurred 3 times. – Gabe Feb 25 '11 at 04:11
  • One time, the bug appeared a bit different. The black bar appeared UNDER the status bar with the rest of the screen pushed down. It seems possible it has something to do with the green "Touch here to return to phone call" UI that appears when your phone call is running in the background. – Gabe Feb 25 '11 at 04:16
  • I assume a method, which draws something is messed up or gets bad parameters – Pascalius Feb 28 '11 at 00:34
  • Well, we at least figured out that it's not related to phone calls because it's been reproduced without any phone calls occurring. Memory consumption has been checked, that's not the problem. My developer has never once seen this occur on his iPod Touch or 3G. I've seen it dozens of times on 3GS, iPhone4, and iPad. – Gabe Mar 02 '11 at 08:24
  • I have this same problem in my iPad application, without any substantial leads. I think I've also seen it when dismissing a full screen modal window. – Bryan Irace Mar 09 '11 at 22:53
  • Bryan, we're hunting down a fix right now. Will let you know if and when we figure out what it is. Please do the same if you figure it out. – Gabe Mar 10 '11 at 17:10
  • Will do. Fixing this is a high priority. – Bryan Irace Mar 12 '11 at 20:55

4 Answers4

2

It happened once in my app when I called a drawing method in my custom subclass of UIView instance right before I added it as a subview to parent view.

The solution was apparently easy: add it as a subview first before sending/calling any custom drawing methods.

Examples:

CustomView *aView = [[CustomView alloc] init];

[aView drawSomething];

[self.view addSubview:aView]; //wrong approach
[aView release];

Should be:

CustomView *aView = [[CustomView alloc] init];

[self.view addSubview:aView];
[aView release];

[aView drawSomething];
tebo
  • 21
  • 1
  • 2
  • 7
0

I had a similar problem, which I described in this question here

If you have any, try removing any CGRect frame created by reference to: [UIScreen mainScreen].applicationFrame] and instead create the frame using a more manual definition. If that works, you can decide how to proceed from that point.

Community
  • 1
  • 1
Narwhal
  • 744
  • 1
  • 8
  • 22
0

The screenshot is missing, but what you describe sounds as though you've incorrectly implemented the use of Apple's built-in view controllers.

Both UINavigationController and UITabBarController will automagically shift all the content inside them down by 20-pixels, if they detect there is "supposed" to be a statusbar on screen at the moment.

My guess is that you have some code that is removing the statusbar, but which is kicking-in after the Apple code has already detected it and shifted everything down to accomodate.

The "fix" is to re-read the docs on Apple's classes very carefully and use them as Apple dictates (usually, people use them in ways that seem sensible - e.g. embedding them inside other views - but which Apple has expressly declared are unsupported. Sadly those classes from Apple are very fragile)

Adam
  • 32,900
  • 16
  • 126
  • 153
  • It's possible that I'm seeing this because I am using UINavigationController incorrectly, although I do not have any code to remove the status bar. – Bryan Irace Mar 18 '11 at 20:56
  • The only other thing that could obscure status bar is if you have some code that's adding custom UIWindow instances - and declaring them to be status-bar layer, or higher-than-status-bar layer (e.g. alert layer is higher, IIRC). Maybe some 3rd party code doing so? I'd do a project-wide search for UIStatusBar and UIWindow – Adam Mar 19 '11 at 13:48
  • This is how I reproduce: - View something full screen using QLPreviewController - Dismiss the preview controller - Background the app - Foreground the app - The status bar disappears and the window's background color is visible I cannot figure out why it is happening OR how to fix it. – Bryan Irace Mar 22 '11 at 19:17
0

Are you holding a reference to a QLPreviewController instance? I was able to solve this problem in my app by creating a new autoreleased QLPreviewController whenever I need to display a file modally, as opposed to reusing the same instance over and over again.

Bryan Irace
  • 1,855
  • 2
  • 20
  • 38
  • We fixed the problem, but not exactly sure how. We rewrote much of the UIViewController code, making sure to follow Apple's guidelines, and it appears to have fixed the issue. So not entirely sure what specifically did it as I don't know what was causing it in the first place. – Gabe Mar 24 '11 at 04:35
  • Well, we released our app thinking this was fixed. And low and behold it's not fixed. And we still can't figure out what the problem is. Bryan, we don't use QLPreviewController at all so it seems our problems are caused by different things. Anyone else have any idea? This is driving me nuts, and now my app is already live and people are seeing this bug pretty regularly. If you're curious, the app is Prose with Bros. It's not easy to reproduce the bug, but it'll indefinitely happen. – Gabe Apr 26 '11 at 16:34