diff --git a/shell/platform/android/android_environment_gl.cc b/shell/platform/android/android_environment_gl.cc index cd04e9afe1d00..e84ee88d56d8f 100644 --- a/shell/platform/android/android_environment_gl.cc +++ b/shell/platform/android/android_environment_gl.cc @@ -20,11 +20,24 @@ AndroidEnvironmentGL::AndroidEnvironmentGL() return; } + // See if we can use the EGL_ANDROID_presentation_time extension. This + // extension may be available from API18 onward. + // If this extension is available, it will be invoked with the target vsync + // for the current frame before calling eglSwapBuffers. This helps when the + // engine over-stuffs the buffer queue. This can happen when a frame goes over + // budget into the next vsync period, and a subsequent frame is quickly + // submitted in the same vsync period. Dequeuing buffers will then be slow + // until the engine stops submitting frames and lets the GPU catch up. + // However, using this extension means the SurfaceFlinger will only use the + // newest buffer for the current vsync, and the GPU and CPU will stay more + // in sync. + // See https://developer.android.com/games/sdk/frame-pacing for more + // details and diagrams. auto* extensions = eglQueryString(display_, EGL_EXTENSIONS); if (strstr(extensions, "EGL_ANDROID_presentation_time")) { presentation_time_proc_ = reinterpret_cast( - eglGetProcAddress("sEGL_ANDROID_presentation_time")); + eglGetProcAddress("eglPresentationTimeANDROID")); } valid_ = true;