From e23e72bd49c2d5aa9485bf89da102422ed7a45ce Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sat, 25 Oct 2025 19:04:25 +0200 Subject: [PATCH] vo/context_android: fix surface tearing on resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's not clear why this is needed, but it works (on my device). fixes https://github.com/mpv-android/mpv-android/issues/991 Co-authored-by: 茶茶 --- video/out/opengl/context_android.c | 7 +++++++ video/out/vulkan/context_android.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/video/out/opengl/context_android.c b/video/out/opengl/context_android.c index 12f290b161..0a12cf8add 100644 --- a/video/out/opengl/context_android.c +++ b/video/out/opengl/context_android.c @@ -109,6 +109,13 @@ static bool android_reconfig(struct ra_ctx *ctx) if (!vo_android_surface_size(ctx->vo, &w, &h)) return false; + // Update window geometry to prevent screen tearing + ANativeWindow *native_window = vo_android_native_window(ctx->vo); + if (native_window) { + int32_t current_format = ANativeWindow_getFormat(native_window); + ANativeWindow_setBuffersGeometry(native_window, w, h, current_format); + } + ctx->vo->dwidth = w; ctx->vo->dheight = h; ra_gl_ctx_resize(ctx->swapchain, w, h, 0); diff --git a/video/out/vulkan/context_android.c b/video/out/vulkan/context_android.c index 9e6785ea8c..512830db9f 100644 --- a/video/out/vulkan/context_android.c +++ b/video/out/vulkan/context_android.c @@ -77,6 +77,13 @@ static bool android_reconfig(struct ra_ctx *ctx) if (!vo_android_surface_size(ctx->vo, &w, &h)) return false; + // Update window geometry to prevent screen tearing + ANativeWindow *native_window = vo_android_native_window(ctx->vo); + if (native_window) { + int32_t current_format = ANativeWindow_getFormat(native_window); + ANativeWindow_setBuffersGeometry(native_window, w, h, current_format); + } + ra_vk_ctx_resize(ctx, w, h); return true; }