OpenGL swapping buffers: flickering

Apprentice
Posts: 8
Joined: 2008.10
Post: #1
Hi,
Problem looks like rendering always happens to one buffer, the other buffer keeps first frame. Buffers get swapped properly, so on the screen I see flickering of the first ever rendered frame, and my current frame.

Strange things/details:
if I put break-point anywhere in render loop when the problem happens, and then just continue - problem goes away.
this problem happens approx 30% of time
happens only on device - not in emulator

My rendering loop is based on CrashLanding sample, using MyEAGLView and NSTimer (30 fps, actuall fps sometimes is lower)

Must be some syncing issue, somehow buffers are not properly switched for rendering. Any ideas what to do?
Quote this message in a reply
Member
Posts: 87
Joined: 2006.08
Post: #2
kirill Wrote:Any ideas what to do?

As always, file a bug.
Quote this message in a reply
Apprentice
Posts: 17
Joined: 2008.10
Post: #3
I also run into this... less frequently though - maybe 10% and only happens on hardware....I assumed this was something to do with compiling in debug mode... have you seen this issue when you build for release?
Quote this message in a reply
Apprentice
Posts: 8
Joined: 2008.10
Post: #4
sumiguchi Wrote:I also run into this... less frequently though - maybe 10% and only happens on hardware....I assumed this was something to do with compiling in debug mode... have you seen this issue when you build for release?

Yes, this is the problem, it happens in release.
I was told it happens with other apps as well, but still would really like to know what's happening and to fix it. Here is related quote from other forum:

Quote: I have had this error and a variation of it in other games. I thought it was an iPhone error in how the iPhone handles memory.

As I said I've had a similar error in other games. I've also had a variation where a screen from a game I was playing earlier flashes in the game I am currently playing. One example was when a Mouse About screen flickered very quickly in and out of a Wurdle game I was playing. I was playing an untimed Wurdle game. This pre-loads all possible solutions and you have a short wait while it does so.

It tends to happen if the game I was playing prior to the error is memory intensive (I judge this by loading time, number of animation sequences in game, etc). I've found my own workaround this iPhone bug. I take a screenshot. This seems to stabilize the memory (don't ask me how). If it re-occurs I then reboot my iPhone.
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2010.05
Post: #5
I had the same problem with the flashing/flicker alternating between the current image and a fixed image... it would happen on a 3GS, but not a 3G, first gen, or the simulator.

The problem seemed to happen when I would set up the context in ESRenderer, but not actually draw anything, i.e. in the code below [scene draw] didn't draw anything in certain states (I think it should be legal to do this? ... works lots of other places.) Anyway, my workaround was to stop animation in those states so that I didn't call draw and set up the context in those no draw states It might also be possible to workaround by drawing one black pixel, etc ... I didn't try this to verify.


Code:
- (void) draw
{
   [EAGLContext setCurrentContext:context];
   glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
   glViewport(0, 0, backingWidth, backingHeight);

   //Render the GLScene...
   [scene draw];

   glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
   [context presentRenderbuffer:GL_RENDERBUFFER_OES];  
}
Quote this message in a reply
Member
Posts: 446
Joined: 2002.09
Post: #6
rowol Wrote:The problem seemed to happen when I would set up the context in ESRenderer, but not actually draw anything, i.e. in the code below [scene draw] didn't draw anything in certain states (I think it should be legal to do this? ... works lots of other places.)

The contents of the backbuffer are not guaranteed after a swap unless you specifically asked for them to be retained. Look up kEAGLDrawablePropertyRetainedBacking in the docs for more info.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cocos2D - moving sprite deformed, flickering aerospaceman 2 5,358 Mar 23, 2011 02:50 PM
Last Post: aerospaceman
  Tutorial on Multiple View swapping? dragagon 1 5,507 Oct 28, 2008 12:03 PM
Last Post: dragagon
  Strange Graphics Glitch - Buffers Lostlogic 0 1,740 Oct 10, 2008 05:17 PM
Last Post: Lostlogic