Changing Configuration from "Debug" to "Release" causes Graphics Bugs

Member
Posts: 95
Joined: 2009.09
Post: #1
Dear Fellow Developers,

I was working on Version 1.4 of my Game Tactica, added quite a lot new features and when I finally finished everything and it worked smoothly I wanted to change "Release", build, and upload the update to itunes Connect.
After building for the configuration "Release", xCode asked me, whether I would like to install the corresponding Provisioning Profile on my iPod because he lacked the "Sale"-mobileprovisioning - profile to run it.

I did so, started my app and everything worked ok.
But when I entered my 3D Open GL screen I had all kinds of weird graphics bugs.
So I changed back into the "Debug"-Profile and everything worked nice again.

I can't get rid of those graphics errors, what may be the reason for this sudden change?

My "Debug" and "Release" Configuration Profiles are virtually identic, except for the Code Signing Profiles.
Everything worked smoothly the last time I submitted a new version, except that I upgraded xcode and my ipad to iOS 4.0 in between.

But what problem could iOS4 do to my "Release"-Config, that it wouldn't do to my "Debug"-Config?
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
90% of the time when I've had issues like that it's because of accidentally using junk data initialized variables. In debug mode, the code isn't optimized and you get different patterns of random left-over data in your uninitialized variables because of it. Another potential issue is that with optimizations on, you are running into floating point precision problems because the results aren't quite the same. I would find this highly unlikely though.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
If you're loading textures with a CGBitmapContext, make sure the memory for the context is cleared (using memset, or allocated with calloc to begin with).
Quote this message in a reply
Member
Posts: 95
Joined: 2009.09
Post: #4
Well I didn't change the Texture Loading Code for quite a while, I would wonder why It would have a problem there, here is the code lines:
Code:
        void *imageData = malloc( height * width * 4 );
        CGContextRef context = CGBitmapContextCreate( imageData, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big );

I mean, its not a definite part of my Geometry that is causing the error, if I turn the viewing angle, I can see all parts clearly at different angles.

And wouldn't I have problems in debug mode too, if I had junk-initialized any variable? (In Debug-Mode everything works fine and was tested many many times)

Can you explain where floating point errors could come in?

I mean everything worked fine before, I just don't see what could have changed the behaviour between the last two builds...
Thank you for your suggestions though!

EDIT: Here's a picture of the bug:
[Image: 3dbug.png]

EDIT2: The bug is really strange, when I turn the map the hexagons stay the same, but units disappear and pop up again randomly. But turning the view doesn't invoke any of my Code, its all handled inside OpenGL, since I'm not changing the arrays I give to OpenGL as long as the underlying Geometries don't change. Which they don't do , as long as I only change viewing angles.

EDIT3: The Error has some connection to the flags on top of the flagpoles next to the bunkers. If I start the game with only the blue player, everything is fine except for the flags of the poles, that don't appear. If I start with blue and green player, I get the mentioned graphics bug, but somehow its connected to the green flags. In "Debug" Mode the flags appear to be fine again.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #5
Change all your malloc() calls to calloc(), that might improve things Smile
Quote this message in a reply
Member
Posts: 95
Joined: 2009.09
Post: #6
Sorry about bothering you, it was all my fault,
the line that was supposed to calculate the direction a flag was facing looked like this:

Code:
    float si=sinf(angle),co=co;

Appearently I stopped typing after the "co..", its just weird that at worked and all and xcode never complained.

This post is solved and may be deleted Smile

EDIT: Just for clarification, this line of code is more than 2 months old, compiled and ran without problems and was a part of my "New and Noteworthy" App Grin
(And nobody saw that some flags looked weird if you zoomed in very close, namingly the ones with sinf(angle) = 0 )
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #7
Yup. Uninitialized variables.

Quote: And wouldn't I have problems in debug mode too, if I had junk-initialized any variable?

Yes, but particularly with floats the problem can go unnoticed for a long time. Half of the the valid floating point numbers are less than 1.0, and half of those are extremely tiny. So if you meant to initialize the variable to something that was less than 1.0, it might just end up being close enough every time that you don't notice that it's wrong.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  adhoc different then device debug? kendric 8 4,937 Jan 15, 2010 11:42 AM
Last Post: kendric
  app crashes in non-debug environment Gillissie 2 3,058 Dec 12, 2009 05:03 PM
Last Post: DoG
  #define DEBUG, RELEASE haudio 8 7,328 Feb 5, 2009 12:50 AM
Last Post: kalimba
  Debug Break Code haudio 4 3,764 Jan 21, 2009 11:50 PM
Last Post: haudio