From 0cb36c4ad8722e2d6c52a062aead7567d9a16aee Mon Sep 17 00:00:00 2001 From: John McCutchan Date: Thu, 3 Aug 2023 11:50:52 -0700 Subject: [PATCH] Add @Keep annotations to avoid dead code elimination of classes only referenced by JNI (flutter/engine#44337) Missing piece --- .../io/flutter/embedding/engine/renderer/FlutterRenderer.java | 2 ++ .../shell/platform/android/io/flutter/view/TextureRegistry.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/renderer/FlutterRenderer.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/renderer/FlutterRenderer.java index 423a355038..270e51a28a 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/renderer/FlutterRenderer.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/renderer/FlutterRenderer.java @@ -12,6 +12,7 @@ import android.media.Image; import android.os.Build; import android.os.Handler; import android.view.Surface; +import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; @@ -319,6 +320,7 @@ public class FlutterRenderer implements TextureRegistry { } } + @Keep final class ImageTextureRegistryEntry implements TextureRegistry.ImageTextureEntry { private final long id; private boolean released; diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/TextureRegistry.java b/engine/src/flutter/shell/platform/android/io/flutter/view/TextureRegistry.java index 98ec564766..86b5e71aad 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/TextureRegistry.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/TextureRegistry.java @@ -6,6 +6,7 @@ package io.flutter.view; import android.graphics.SurfaceTexture; import android.media.Image; +import androidx.annotation.Keep; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -75,6 +76,7 @@ public interface TextureRegistry { default void setOnTrimMemoryListener(@Nullable OnTrimMemoryListener listener) {} } + @Keep interface ImageTextureEntry extends TextureEntry { /** @return the identity of this ImageTextureEntry */ long id();