From 2ce3a9719e773e3bbc6754cf1f41ae9789210944 Mon Sep 17 00:00:00 2001 From: Jiuqiang Tang Date: Thu, 10 Nov 2022 09:25:38 -0800 Subject: [PATCH] Remove the problematic packet release calls in OutputHandler::run. OutputHandler::run is installed as a MultiStreamCallback into the TaskRunner and it's invoked in the Graph::CallbackToJava() jni method. In CallbackToJava(), the packets are removed in RemovePacket() calls after the multi stream callback is invoked. The current logic lets the MultiStreamCallback release the packets first and leaves null pointers to RemovePacket() to remove, which may cause the app crash. The fix is to remove the packet release calls in the MultiStreamCallback and always leave the packet release work to RemovePacket(). PiperOrigin-RevId: 487558809 --- .../java/com/google/mediapipe/tasks/core/OutputHandler.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mediapipe/tasks/java/com/google/mediapipe/tasks/core/OutputHandler.java b/mediapipe/tasks/java/com/google/mediapipe/tasks/core/OutputHandler.java index 6a83c729..d18f0e41 100644 --- a/mediapipe/tasks/java/com/google/mediapipe/tasks/core/OutputHandler.java +++ b/mediapipe/tasks/java/com/google/mediapipe/tasks/core/OutputHandler.java @@ -119,12 +119,6 @@ public class OutputHandler { } else { Log.e(TAG, "Error occurs when getting MediaPipe task result. " + e); } - } finally { - for (Packet packet : packets) { - if (packet != null) { - packet.release(); - } - } } } }