From de18d900741990a443f6f166f2186fdf8e8a0a81 Mon Sep 17 00:00:00 2001 From: MxSoul Date: Tue, 7 Dec 2021 19:27:11 +0800 Subject: [PATCH 1/2] Fix eglPresentationTimeANDROID is no effective --- shell/platform/android/android_environment_gl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/android/android_environment_gl.cc b/shell/platform/android/android_environment_gl.cc index cd04e9afe1d00..2623f0c508017 100644 --- a/shell/platform/android/android_environment_gl.cc +++ b/shell/platform/android/android_environment_gl.cc @@ -24,7 +24,7 @@ AndroidEnvironmentGL::AndroidEnvironmentGL() if (strstr(extensions, "EGL_ANDROID_presentation_time")) { presentation_time_proc_ = reinterpret_cast( - eglGetProcAddress("sEGL_ANDROID_presentation_time")); + eglGetProcAddress("eglPresentationTimeANDROID")); } valid_ = true; From a99c6b4b0fce912862d3b6855ec5b008ec6e83ca Mon Sep 17 00:00:00 2001 From: Dan Field Date: Thu, 9 Dec 2021 09:39:51 -0800 Subject: [PATCH 2/2] Update android_environment_gl.cc --- shell/platform/android/android_environment_gl.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/shell/platform/android/android_environment_gl.cc b/shell/platform/android/android_environment_gl.cc index 2623f0c508017..e84ee88d56d8f 100644 --- a/shell/platform/android/android_environment_gl.cc +++ b/shell/platform/android/android_environment_gl.cc @@ -20,6 +20,19 @@ 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_ =