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.