OpenGL ES Frame Skipping causing visible artifacts

I'm using OpenGL ES 3.0 on Android 5.1, and am noticing the following issues. I tried to implement the game loop which does exactly 60 updates and do as many frames as it can. Everything is smooth, but the object is being rendered twice, I think due to interpolation by hardware.

If you zoom the image (click to view in separate tab) you'll see that the green square is being rendered twice. And now if I remove the catch-up code, it works correctly.

As you can see it now renders fine. Now I'll show you my game loop. I'm using GLSurfaceView class, and doing my render in onDrawFrame of the renderer.

double now = TimeUtils.currentTime();

if (previous == -1)
previous = now;

double delta = now - previous;

if (delta >= SECOND)
delta = frameTime;

lag += delta;

while (lag >= frameTime)  // This line plays catchup.
// If commented, it works otherwise the
// artifact occurs
{
doUpdate(frameTime);

lag -= frameTime;
}

frames++;
glClear(GL_COLOR_BUFFER_BIT);
doRender(frameTime);

if (now - lastStatsTime >= SECOND)
{
framesPerSecond = frames;

lastStatsTime = now;
}

previous = now;


Is there anything that I'm doing wrong? I'm using a dynamic VBO for rendering, the lines are generated every frame and I use glBufferData to send them to GPU. This happens every frame (This is being done for educational purpose, to learn how VBOs are streamed).

Are there any issues that I'm forgetting?

• Exactly yes! Dunno why I missed this thing, but the surface view is calling the onSurfaceCreated twice, and my game starts twice. I have a static list of handlers for render and the handlers gets added twice, causing the render to be twice every frame. Thanks to you, I also found a bug in my framework here that I fixed just now. – Sri Harsha Chilakapati Jul 19 '16 at 13:26