From e482dcbc685bdde99916a6c097ff8c0c226492c0 Mon Sep 17 00:00:00 2001 From: Alexander Hartmann Date: Mon, 24 Jun 2024 20:47:39 +0200 Subject: [PATCH] fix lost old callback when continuous call requestRenderAndNotify --- .../godotengine/godot/gl/GLSurfaceView.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView.java b/platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView.java index 98384ba5db6..c316812404e 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView.java +++ b/platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView.java @@ -869,7 +869,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback */ public interface EGLConfigChooser { /** - * Choose a configuration from the list. Implementors typically + * Choose a configuration from the list. Implementers typically * implement this method by calling * {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the * EGL specification available from The Khronos Group to learn how to call eglChooseConfig. @@ -1673,7 +1673,24 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback mWantRenderNotification = true; mRequestRender = true; mRenderComplete = false; - mFinishDrawingRunnable = finishDrawing; + + // fix lost old callback when continuous call requestRenderAndNotify + // + // If continuous call requestRenderAndNotify before trigger old + // callback, old callback will lose, cause VRI will wait for SV's + // draw to finish forever not calling finishDraw. + // https://android.googlesource.com/platform/frameworks/base/+/044fce0b826f2da3a192aac56785b5089143e693%5E%21/ + //+++++++++++++++++++++++++++++++++++++++++++++++++++ + final Runnable oldCallback = mFinishDrawingRunnable; + mFinishDrawingRunnable = () -> { + if (oldCallback != null) { + oldCallback.run(); + } + if (finishDrawing != null) { + finishDrawing.run(); + } + }; + //---------------------------------------------------- sGLThreadManager.notifyAll(); } @@ -1938,4 +1955,3 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback private int mEGLContextClientVersion; private boolean mPreserveEGLContextOnPause; } -