2

I've written an OpenGL ES 2 app using NativeActivity that renders around 6 textured triangles that you can drag around using touch input. The app is rendering as fast as possible, calling glClear() before and eglSwapBuffers() after rendering. As expected the frame rate is capped to the display frequency of around 60 fps and the scene moves around smoothly. However, after some time (10 to 60 seconds) the movement starts to stutter even though the frame rate is still 60 fps. The device I'm using is OnePlus 3.

At first I suspected the culprit was battery saving mode, but investigation revealed no correlation between cpus' frequencies and the stutter.

I did notice something interesting though, the stutter starts when queueBuffer() execution time goes up.

This is the systrace before stutter: Before stutter This is the systrace after stutter: After stutter This is the systrace during the transition from before to after: Transition

How do I stop the app from stuttering?

BDL
  • 21,052
  • 22
  • 49
  • 55
gq3
  • 839
  • 1
  • 8
  • 20
  • Very hard to help without seeing any code... could be a garbage collection issue? Are you creating many objects in each frame? – Gil Moshayof Jan 26 '17 at 11:55
  • Not at all, I use NativeActivity and currently don't use Java objects at all. – gq3 Jan 27 '17 at 09:16

1 Answers1

0

I still don't know the exact cause of the stuttering, but I managed to find a work-around: Only render frames on Choreographer.postFrameCallback and set eglPresentationTimeANDROID to two vsyncs in the future. This avoids filling up the buffer queue, which seems to be one of the causes of the stuttering.

As a bonus it also improved the touch input latency a little.

More info here: Minimize Android GLSurfaceView lag

Community
  • 1
  • 1
gq3
  • 839
  • 1
  • 8
  • 20