From 3ee7e91ded3a6dee10028c482229abb37056682b Mon Sep 17 00:00:00 2001 From: Steven Elliott Date: Mon, 2 Mar 2026 22:18:56 -0500 Subject: [PATCH] Fix R8 stripping JNI callback methods causing SIGABRT (#6045) R8 tree-shakes process() implementations on lambda-desugared classes implementing PacketCallback, PacketListCallback, and PacketWithHeaderCallback because it cannot see that these methods are invoked from native JNI code in graph.cc (CallbackToJava). When GetMethodID fails to find the stripped process() method at runtime, the JNI layer triggers a fatal SIGABRT that cannot be caught by try/catch. The existing -keep rule on the interfaces preserves the interface definitions but does not prevent R8 from removing method implementations on anonymous classes. Add explicit -keep rules for all classes implementing the three callback interfaces to retain their process() methods. Fixes: #6045 --- .../google/mediapipe/framework/proguard.pgcfg | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mediapipe/java/com/google/mediapipe/framework/proguard.pgcfg b/mediapipe/java/com/google/mediapipe/framework/proguard.pgcfg index 34dce63d09..3bf1d1f324 100644 --- a/mediapipe/java/com/google/mediapipe/framework/proguard.pgcfg +++ b/mediapipe/java/com/google/mediapipe/framework/proguard.pgcfg @@ -1,13 +1,25 @@ # Additional flags to pass to Proguard when processing a binary that uses # MediaPipe. -# Keep public members of our public interfaces. This also prevents the -# obfuscation of the corresponding methods in classes implementing them, -# such as implementations of PacketCallback#process. +# Keep public members of our public interfaces. -keep public interface com.google.mediapipe.framework.* { public *; } +# Keep process() on all callback implementations including lambda-desugared +# anonymous classes. R8 cannot see that these methods are invoked via JNI +# (graph.cc CallbackToJava) and will strip them, causing a fatal SIGABRT when +# GetMethodID fails at runtime. See #6045. +-keep class * implements com.google.mediapipe.framework.PacketCallback { + void process(com.google.mediapipe.framework.Packet); +} +-keep class * implements com.google.mediapipe.framework.PacketListCallback { + void process(java.util.List); +} +-keep class * implements com.google.mediapipe.framework.PacketWithHeaderCallback { + void process(com.google.mediapipe.framework.Packet, com.google.mediapipe.framework.Packet); +} + # This method is invoked by native code. -keep public class com.google.mediapipe.framework.Packet { public static *** create(***);