From 38baaa00b1653e4f5dc9644426bb24344a7be6b1 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Tue, 4 Oct 2022 10:01:17 -0700 Subject: [PATCH] Fix GL Tensor (backed by AHardwaBuffer) GL to CPU synchronization. glFinish() must be called on a valid gl context PiperOrigin-RevId: 478816905 --- mediapipe/framework/formats/tensor_ahwb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediapipe/framework/formats/tensor_ahwb.cc b/mediapipe/framework/formats/tensor_ahwb.cc index c839cf5a2..b11f6b55b 100644 --- a/mediapipe/framework/formats/tensor_ahwb.cc +++ b/mediapipe/framework/formats/tensor_ahwb.cc @@ -371,7 +371,7 @@ void* Tensor::MapAhwbToCpuRead() const { if ((valid_ & kValidOpenGlBuffer) && ssbo_written_ == -1) { // EGLSync is failed. Use another synchronization method. // TODO: Use tflite::gpu::GlBufferSync and GlActiveSync. - glFinish(); + gl_context_->Run([]() { glFinish(); }); } else if (valid_ & kValidAHardwareBuffer) { CHECK(ahwb_written_) << "Ahwb-to-Cpu synchronization requires the " "completion function to be set";