google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://mediapipe.dev
Apache License 2.0
26.09k stars 5.04k forks source link

mediapipe::CvPixelBufferPoolWrapper::GetBuffer() fatal: Check failed: !err Error creating pixel buffer: -6662 #5510

Open bhamiltoncx opened 3 days ago

bhamiltoncx commented 3 days ago

Also see Google bug http://b/349815177.

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

Yes

OS Platform and Distribution

iOS 15.8.2, 16.7.8, 17.5.1

Mobile device if the issue happens on mobile device

iPad11,7, iPhone10,2, iPhone9,4

Browser and version if the issue happens on browser

No response

Programming Language and version

C++

MediaPipe version

0.10.15

Bazel version

head

Solution

N/A

Android Studio, NDK, SDK versions (if issue is related to building in Android environment)

No response

Xcode & Tulsi version (if issue is related to building for iOS)

No response

Describe the actual behavior

Fatal error Check failed: !err Error creating pixel buffer: -6662 from mediapipe::CvPixelBufferPoolWrapper::GetBuffer()

Describe the expected behaviour

Should not fatal on memory allocation failure

Standalone code/steps you may have used to try to get what you need

The error `kCVReturnAllocationFailed` (aka `-6662`) is defined in  `CoreVideo.framework/Headers/CVReturn.h`.

https://developer.apple.com/documentation/corevideo/kcvreturnallocationfailed

This error is occasionally returned by `CVPixelBufferPoolCreatePixelBufferWithAuxAttributes()` here:

https://github.com/google-ai-edge/mediapipe/blob/4aea8e7723a6ebe79a7e0ae4cce9b1e89c1d633d/mediapipe/gpu/pixel_buffer_pool_util.cc#L107

This causes mediapipe to abort the process. Instead, it should return an `absl::ResourceExhaustedError()` here when `kCVReturnAllocationFailed` is returned:

https://github.com/google-ai-edge/mediapipe/blob/4aea8e7723a6ebe79a7e0ae4cce9b1e89c1d633d/mediapipe/gpu/pixel_buffer_pool_util.cc#L109

However, the fix isn't trivial, because this then turns into another fatal a little higher in the stack in `mediapipe::GlCalculatorHelper::CreateDestinationTexture()`:

https://github.com/google-ai-edge/mediapipe/blob/4aea8e7723a6ebe79a7e0ae4cce9b1e89c1d633d/mediapipe/gpu/gl_calculator_helper.cc#L219

This will require changing `GlCalculatorHelper::CreateDestinationTexture()` to return an `absl::StatusOr<GlTexture>`, which will require updating all callsites.

Other info / Complete Logs

Example crash:

Thread 60 drishti/0 (id: 0x0006f3da) CRASHED
Exception info 0x00010003 / 0x00000006 @0x00000001dc5ab198

0x00000001dc5ab198  (libsystem_kernel.dylib + 0x00007198)       __pthread_kill
0x00000001ebb3a5f4  (libsystem_pthread.dylib + 0x0000d5f4)      pthread_kill
0x00000001a7bf44b4  (libsystem_c.dylib + 0x0001c4b4)        abort
0x0000000109fb2374  (NameOfApp -log_message.cc:359)     absl::log_internal::LogMessage::FailWithoutStackTrace()
0x0000000109fb2774  (NameOfApp -log_message.cc:516)     absl::log_internal::LogMessage::Die()
0x0000000109fb2530  (NameOfApp -log_message.cc:525)     absl::log_internal::LogMessage::SendToLog()
0x0000000109fb2220  (NameOfApp -log_message.cc:437)     absl::log_internal::LogMessage::Flush()
0x0000000109fb27b4  (NameOfApp -log_message.cc:617)     absl::log_internal::LogMessageFatal::~LogMessageFatal()
0x0000000109fb27cc  (NameOfApp -log_message.cc:616)     absl::log_internal::LogMessageFatal::~LogMessageFatal()
0x00000001092d5154  (NameOfApp -log_message.h)      mediapipe::CvPixelBufferPoolWrapper::CreateBufferWithoutPool(mediapipe::internal::GpuBufferSpec const&)
0x000000010922f41c  (NameOfApp -multi_pool.h:118)       mediapipe::MultiPool<mediapipe::CvPixelBufferPoolWrapper, mediapipe::internal::GpuBufferSpec, mediapipe::GpuBuffer>::Get(mediapipe::internal::GpuBufferSpec const&)
0x00000001092b82d8  (NameOfApp -gpu_buffer_multi_pool.h:53)     mediapipe::GpuBufferMultiPool::GetBuffer(int, int, mediapipe::GpuBufferFormat)
0x00000001092b82d8  (NameOfApp -gl_calculator_helper.cc:237)        mediapipe::GlCalculatorHelper::CreateDestinationTexture(int, int, mediapipe::GpuBufferFormat)
kuaashish commented 4 hours ago

Hi @bhamiltoncx,

I cannot access the CL in Buganizer as I do not have permission for that component. Could you provide the complete steps you are following from our documentation or the standalone command you are using? This will help us reproduce and understand the issue better for resolution.

Thank you!!