I'm working on a project with SDL and OpenGL. The game works great on Windows, Linux, OS X and iOS. However, the Android version is showing a problem on my phone in particular. I have tested another device and there it works great as well.

The problem I'm facing is a visual glitch. It happens in bursts: for example: 90 frames okay and then 40 frames the glitch. The glitch itself is kind of hard to describe but I'll try. The screen is being updated partially correct (from the top of my phone to approximately halfway down) and partially flickering. The flickering effect is some sort of back and forth jumping. I'm thinking that it is related to double buffering. I think that because what I get to see on the screen is jumping back and forth every frame. It is like half of the screen is one frame in time and the next frame 2 frames late. Pretty much like a procession of Echternach, I guess you could say. If I plot it in a chart where time goes on when moving down the chart, I think I'm seeing this (numbers in the table are the indices of the frames in my game loop I am actually seeing):

          left half | right half  (phone is in landscape)
time  1 |      1           1
time  2 |      2           2
time  3 |      3           1
time  4 |      4           4
time  5 |      5           3
time  6 |      6           6
time  7 |      7           5
time  8 |      8           8
time  9 |      9           7

So the right half is one frame in time, and the next frame, it shows the previous frame. This is supports my theory that there is a problem with double buffering. It looks like it somehow doesn't get to completely update the backbuffer before it is put on the screen, or something.

Also, the split between good and glitch on the screen is different from frame to frame, which points I think proves it is a synchronisation issue and heavily depends on timing of what is going on. Adding glFinish(); before the SDL_GL_SwapWindow(); call doesn't help.

Version info: SDL reports vsync to be turned on. However, I believe that this isn't tearing. My phone a Samsung Galaxy S3 mini and is running Android 5.1.1 (CM12) and the GPU (Mali-400) supports OpenGL ES 2.0. Other games run okay on my phone.

  • \$\begingroup\$ What is the phone model ? \$\endgroup\$
    – concept3d
    Oct 25, 2015 at 18:28
  • \$\begingroup\$ Samsung Galaxy S3 mini. Running CyanogenMod 12. \$\endgroup\$ Oct 25, 2015 at 18:33
  • \$\begingroup\$ I discovered it's everywhere in my phone, but more subtle. Even in the system UI scrolling through menus. \$\endgroup\$ Nov 11, 2015 at 12:43
  • 2
    \$\begingroup\$ This sound more like a bug in your phone. My guess is a firmware update is the most likely way to solve it. \$\endgroup\$
    – rolobo
    Dec 9, 2015 at 12:27
  • \$\begingroup\$ @rolobo: Yes, indeed. However I'm very happy with everything else and my phone is just a test device for this project and not part of my main development process. \$\endgroup\$ Dec 9, 2015 at 16:56

1 Answer 1


A section of the readme talks about it:

A note regarding the use of the "dirty rectangles" rendering technique

[...] where you only update a portion of the screen on each frame, you may notice a variety of visual glitches on Android, that are not present on other platforms. This is caused by SDL's use of EGL as the support system to handle OpenGL ES/ES2 contexts, in particular the use of the eglSwapBuffers function. As stated in the documentation for the function "The contents of ancillary buffers are always undefined after calling eglSwapBuffers".

Setting the EGL_SWAP_BEHAVIOR attribute of the surface to EGL_BUFFER_PRESERVED is not possible for SDL as it requires EGL 1.4, available only on the API level, so the only workaround available on this platform is to redraw the entire screen each frame.

  • \$\begingroup\$ Please included a summary of the information relevant from that link and an explanation of how the information answers the question. \$\endgroup\$
    – tyjkenn
    Aug 4, 2017 at 22:45
  • \$\begingroup\$ ...the original question didn't say anything about doing "dirty rectangles" rendering? \$\endgroup\$ Aug 5, 2017 at 2:11

Not the answer you're looking for? Browse other questions tagged .