views:

51

answers:

0

I am using OpenGL for a 2D graphing application. I have recently started having strange problems with the UIView that displays the GL render buffer.

Sometimes (40% of the time?) when it initialises, the view is in a frozen state, occasionally displaying artefacts of the last successful running of the program.

The rest of the program is responsive but unstable (attempting to change tabs causes an immediate crash) when this occurs. When this doesn't occur, it's rock solid.

I believe I may have been having these problems since removing some initialisation code (so that the application doesn't use a depth buffer, and other things not relevant to a 2D application) but I'm not sure.

This problem only occurs on the device (testing on iPod touch); it doesn't occur in the simulator.

This is the setup code for my GLView: (Removed in edit as it is no longer relevant and made eyes bleed)

No unusual or erroneous debug messages are displayed in the console.

Edit

The crashing was caused by the way the animation timer was(n't) set up, I have fixed the problem with these new methods:

- (void)startAnimation 
{
    if(animationTimer == nil)
        animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawView) userInfo:nil repeats:YES];
}

- (void)stopAnimation 
{
    [animationTimer invalidate];
    animationTimer = nil;
}

but now I have another problem. On the device, drawview isn't being called (as if the timer schedule didn't initialise properly), until I navigate away from and back to the graph view tab. The simulator doesn't have this problem.