Skip to content

cmake: add ENABLE_VIDEOTOOLBOX=OFF option to fix Apple Silicon (M1/M2/M3) crash#1208

Open
TimeleftXL wants to merge 1 commit intoOpenKinect:masterfrom
TimeleftXL:fix/apple-silicon-videotoolbox-crash
Open

cmake: add ENABLE_VIDEOTOOLBOX=OFF option to fix Apple Silicon (M1/M2/M3) crash#1208
TimeleftXL wants to merge 1 commit intoOpenKinect:masterfrom
TimeleftXL:fix/apple-silicon-videotoolbox-crash

Conversation

@TimeleftXL
Copy link
Copy Markdown

Problem

VTRgbPacketProcessor (VideoToolbox JPEG decoder) causes a hard crash on Apple Silicon (M1/M2/M3):

Thread crashed: VideoToolbox
libfreenect2::VTRgbPacketProcessor::process(libfreenect2::RgbPacket const&)
libfreenect2::AsyncPacketProcessor<libfreenect2::RgbPacket>::execute()

Root cause: heap corruption / double-free in libfreenect2's threading model when VideoToolbox decodes JPEG frames on arm64. This is the same class of issue as the OpenGLDepthPacketProcessor crash on M1.

CpuPacketPipeline alone does not fix this — it only switches the depth decoder to CPU, leaving RGB on VideoToolbox.

Fix

Add an ENABLE_VIDEOTOOLBOX cmake option (default ON for backwards compatibility). Apple Silicon users build with:

cmake .. -DENABLE_VIDEOTOOLBOX=OFF

This makes the library fall through to TurboJpegRgbPacketProcessor, which is unaffected and produces identical output.

Testing

Tested on Apple M1, macOS 15 (Sequoia), libfreenect2 0.2.0, Kinect v2 — stable with ENABLE_VIDEOTOOLBOX=OFF. Crashes reproducibly without it.

Notes

  • Default stays ON so existing Intel Mac / Linux builds are unaffected
  • The VTRgbPacketProcessor code itself is untouched; this just provides an escape hatch
  • A longer-term fix would be porting VTRgbPacketProcessor to use the modern VideoToolbox async API correctly, but that is a much larger change for unmaintained hardware

VTRgbPacketProcessor (VideoToolbox JPEG decoder) causes a heap
corruption / abort on Apple Silicon (M1/M2/M3) due to incompatibilities
between libfreenect2's threading model and the VideoToolbox API on arm64.

Symptom: SIGABRT on a thread named "VideoToolbox" inside
  libfreenect2::VTRgbPacketProcessor::process()
  libfreenect2::AsyncPacketProcessor<RgbPacket>::execute()

The pure-software TurboJPEG decoder (TurboJpegRgbPacketProcessor) is
unaffected and produces identical output.

Add an ENABLE_VIDEOTOOLBOX cmake option (default ON for backwards
compatibility) so Apple Silicon users can opt out cleanly:

  cmake .. -DENABLE_VIDEOTOOLBOX=OFF

This is the same class of issue as the OpenGLDepthPacketProcessor crash
on M1, which is why CpuPacketPipeline alone does not prevent the crash —
it only switches the depth decoder to CPU, leaving the RGB decoder on
VideoToolbox.

Tested on: Apple M1 (macOS 15), libfreenect2 0.2.0, Kinect v2

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants