VTCompressionSessionCreate hangs on Iphone 8

I am trying to run the videotoolbox api. It works fine on both emulator (tested Iphone 14 Pro and Iphone SE) and osx Macbook. When running on the Iphone the synchronous method VTCompressionSessionCreate does not return but gets stuck.

This is hitting pause in XCode after a few seconds of wait time:

The code leading up to this:

"
let imageBufferAttributes = [
        kCVPixelBufferWidthKey: NSNumber(value: width),
        kCVPixelBufferHeightKey: NSNumber(value: height),
        kCVPixelBufferPixelFormatTypeKey: NSNumber(value: kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange)
      ]
       
      let encoderSpecification = [
        kVTVideoEncoderSpecification_EnableLowLatencyRateControl: NSNumber(value: true),
      ]
       
      let compressionSessionOut = UnsafeMutablePointer<VTCompressionSession?>.allocate(capacity: 1)

       
      // Callback
      let encodeCallback: VTCompressionOutputCallback = { outputCallbackRefCon, sourceFrameRefCon, status, infoFlags, sampleBuffer in
        if CMSampleBufferDataIsReady(sampleBuffer!) {
          let encoder: Encoder = Unmanaged<Encoder>.fromOpaque(sourceFrameRefCon!).takeUnretainedValue()
          encoder.writeData(sampleBuffer: sampleBuffer!, infoFlags: infoFlags)
        }
      }

      // Create session
      var status = VTCompressionSessionCreate(allocator: kCFAllocatorDefault,
                          width: Int32(width),
                          height: Int32(height),
                          codecType: codecType, //kCMVideoCodecType_H264,
                          encoderSpecification: nil,//encoderSpecification as CFDictionary?,
                          imageBufferAttributes: imageBufferAttributes as CFDictionary?,
                          compressedDataAllocator: kCFAllocatorDefault,
                          outputCallback: encodeCallback,
                          refcon: Unmanaged.passUnretained(self).toOpaque(),
                          compressionSessionOut: compressionSessionOut)
"

I have searched the web for anyone else seeing this but so far not found anyone.

Is my hardware broken? It is an old device (I am waiting for a newer device).

Same here, did you ever get this working?

restarting the phone fixed the problem. smells like a major bug in iOS!

The same experienced with iPhone X and avcodec (ffmpeg).

It seems to be related to thermal mitigation if i force via debugger critical thermal state its frequent (if not always) to freeze on VTCompressionSessionCreate. If i disable thermal condition it is enough just to kill application. I understand that routine returns error, but freeze?

Same here for me. Not always, but sometimes. I am debugging Compression/Decompression via VTCompressionSession and VTDecompressionSession, and at some point this method just hands for no reason. iPHone 14 pro max. and it is cold, not hot. So no idea.

VTCompressionSessionCreate hangs on Iphone 8
 
 
Q