Internal change
PiperOrigin-RevId: 528632873
This commit is contained in:
parent
fca728d226
commit
0a8be0d09d
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "mediapipe/java/com/google/mediapipe/framework/jni/graph_texture_frame_jni.h"
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "mediapipe/gpu/gl_calculator_helper.h"
|
||||
#include "mediapipe/gpu/gl_context.h"
|
||||
#include "mediapipe/gpu/gl_texture_buffer.h"
|
||||
|
@ -89,9 +90,20 @@ JNIEXPORT jlong JNICALL GRAPH_TEXTURE_FRAME_METHOD(
|
|||
|
||||
JNIEXPORT void JNICALL GRAPH_TEXTURE_FRAME_METHOD(nativeDidRead)(
|
||||
JNIEnv* env, jobject thiz, jlong nativeHandle, jlong consumerSyncToken) {
|
||||
if (!consumerSyncToken) return;
|
||||
|
||||
GlTextureBufferSharedPtr* buffer =
|
||||
reinterpret_cast<GlTextureBufferSharedPtr*>(nativeHandle);
|
||||
mediapipe::GlSyncToken& token =
|
||||
*reinterpret_cast<mediapipe::GlSyncToken*>(consumerSyncToken);
|
||||
// The below check attempts to detect when an invalid or already deleted
|
||||
// `consumerSyncToken` is passed. (That results in undefined behavior.
|
||||
// However, `DidRead` may succeed resulting in a later crash and masking the
|
||||
// actual problem.)
|
||||
if (token.use_count() == 0) {
|
||||
LOG_FIRST_N(ERROR, 5) << absl::StrFormat("invalid sync token ref: %d",
|
||||
consumerSyncToken);
|
||||
return;
|
||||
}
|
||||
(*buffer)->DidRead(token);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user