iDevGames Forums
CGDisplayFade() error 1001 - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: CGDisplayFade() error 1001 (/thread-2437.html)



CGDisplayFade() error 1001 - Wowbagger - Aug 28, 2008 10:00 PM

Kind of a minor issue, but for some reason, every so often CGDisplayFade() will fail to fade the screen and return an error code of 1001. The docs just say "invalid argument" -- I assume this refers to the fade token, but I always reserve the fade token before fading. Anything I'm doing wrong?

Code's a tad long, so I'm going to put it on pastebin:

http://disasterarea.pastebin.com/f5710b606


CGDisplayFade() error 1001 - Blacktiger - Sep 3, 2008 06:33 AM

It doesn't look to me like there is anything wrong with that code. Are you sure that you call fadeOut then fadeIn? The only thing I could think of is that the reservation token is created in one and released in the other, but because you decoupled the code, you aren't guaranteed that they are called in the right order by a client.


CGDisplayFade() error 1001 - Wowbagger - Sep 4, 2008 01:40 AM

No, I always make sure to call FadeOut() and then FadeIn() in that order -- the reason it's decoupled is so I can draw a frame when the screen is faded out and stuff like that. But I'll double check my calls to make sure. Maybe I can try to rework the fading system

Still, the weird thing is that it happens seemingly randomly -- 99% of the time it all works without a hitch. But occasionally, the screen won't smoothly fade, but just quickly blink out of full screen. What's really annoying is that it never happens consistently in one place. Another weird thing is that my checks for an invalid token don't seem to have any effect.

The only thing I can think of it seems to happen most often when going in and out of full screen to show dialogs, so perhaps fading it in and out too quickly has something to do with it. Maybe the kCGMaxDisplayReservationInterval is the problem? What value is normally used for the CGAcquireDisplayFadeReservation() call?


CGDisplayFade() error 1001 - OneSadCookie - Sep 4, 2008 03:25 AM

I've had problems with trying to fade in too soon after fading out before, I think. IIRC I didn't find any solution other than to set the fade duration long enough to cover the switch (back then, on a CRT, way worse than an LCD).


CGDisplayFade() error 1001 - Wowbagger - Sep 5, 2008 05:46 PM

Yeah, I decided to reserve it for 2 seconds instead of the max reservation interval (I recently changed the fade duration to 0.5 seconds instead of 1). I haven't had any issues so far, so hopefully this is a long-term solution (for some reason reserving it for 1 second is too short). The weird thing is that I've never seen this mentioned anywhere in the Apple documentation...

Thanks for the advice.