VTLowLatencyFrameInterpolation can crash when frame-buffer geometry is inconsistent

GitHub source

Reproduced. This page is generated from GitHub Issue #25; GitHub remains the canonical authoring and discussion source.

Source#

Apple Developer Forums — “Swift Array Out of Bounds Crash in VTFrameProcessor when using VTLowLatencyFrameInterpolationParameters”:
https://developer.apple.com/forums/thread/817573

Environment reported by the developer:

iPhone 16
iOS 26.3
Xcode 26.3
VideoToolbox
live 60-fps LL-HLS input

The developer later reported the root cause after debugging: inconsistent buffer sizes across different parts of the pipeline. Standardizing the buffer size everywhere removed the crash.

Apple references:

Problem#

A low-latency interpolation pipeline wraps two decoded LL-HLS frames in VTFrameProcessorFrame, allocates destination frames, builds VTLowLatencyFrameInterpolationParameters, and calls VTFrameProcessor.process(parameters:).

Instead of returning a normal VTFrameProcessorError, the process crashes inside Apple's interpolation implementation with:

Fatal error: Swift/ContiguousArrayBuffer.swift:184:
Array index out of range

with the stack containing:

VTLowLatencyFrameInterpolationImplementation
    processWithParameters:frameOutputHandler:
→ VTFrameProcessor.process(parameters:)

This can look like a VideoToolbox internal bounds bug or an LL-HLS/60-fps limitation. The reporter's controlled debugging instead found a concrete upstream invariant violation: buffer sizes were not consistent across the pipeline.

Evidence level#

DOCUMENTED#

Apple models frame processing as a configured session plus per-operation parameters. VTFrameProcessorFrame wraps a CVPixelBuffer and presentation timestamp. VTLowLatencyFrameInterpolationParameters explicitly carries the current source frame, previous frame, interpolation phases, and destination frames.

The frame-processor configuration surface exposes source and destination pixel-buffer attributes; these are the authoritative requirements to use when constructing buffers for a session.

OBSERVED / VERIFIED#

The forum report reproduces the crash on iOS 26.3 with live LL-HLS input. The developer subsequently states that inconsistent buffer sizes existed across different parts of the code and that standardizing them fixed the crash.

This is the strongest evidence in the incident because changing the buffer-size invariant removes the failure without requiring an HLS, network, or DRM change.

IMPLEMENTATION EVIDENCE#

The exception occurs inside VTLowLatencyFrameInterpolationImplementation, below the public process(parameters:) boundary. The internal Swift array trap indicates the framework reached a state its implementation did not safely reject before indexing internal data.

It does not establish which private array or exact private predicate failed.

INFERENCE#

A mismatch among configured frame geometry, source/reference pixel-buffer geometry, and/or allocated destination geometry plausibly causes internal interpolation state to have incompatible dimensions/counts. The exact private mechanism remains unproven.

UNKNOWN#

  • Which specific pair of buffer dimensions differed in the original application.
  • Whether the framework should have returned a public validation error instead of trapping.
  • Whether later iOS releases add validation for this mismatch.
  • Whether LL-HLS or 60 fps changes only the frequency/timing of the condition rather than being causal.

Investigation / Explanation#

Do not begin with the LL-HLS manifest or interpolation timing merely because the source is live. First validate the frame-processing contract at the CVPixelBuffer boundary.

For every process(parameters:) call, record:

session configuration width/height
configuration sourcePixelBufferAttributes
configuration destinationPixelBufferAttributes

previousFrame buffer width/height/pixelFormat/bytesPerRow
sourceFrame   buffer width/height/pixelFormat/bytesPerRow

each destinationFrame:
  width/height/pixelFormat/bytesPerRow

interpolationPhase.count
destinationFrames.count
previousFrame PTS
sourceFrame PTS

Then enforce before entering VideoToolbox:

previous frame geometry
        == expected source geometry
source frame geometry
        == expected source geometry
all destination geometry
        == expected destination geometry

Do not infer geometry from the HLS variant's RESOLUTION alone. Validate the actual decoded CVPixelBuffers and the actual buffers allocated for VideoToolbox.

A live ABR switch is especially useful as a stress discriminator: if decoded dimensions can change while a frame-processor session remains configured for the old geometry, a new-format frame must not silently enter the old processing session. Treat that as a hypothesis to test, not as the established cause of this report.

Also keep array cardinality separate from geometry. Because the API accepts both interpolationPhase: [Float] and destinationFrames: [VTFrameProcessorFrame], log and validate their counts independently even though the reported fix was buffer-size consistency.

Verification matrix#

Start with decoded local frames so HLS is not involved:

A. previous/source/destination all match configured geometry
B. previous frame has different dimensions
C. source frame has different dimensions
D. one destination frame has different dimensions
E. matching geometry but different pixel format
F. interpolationPhase.count == destinationFrames.count
G. deliberately mismatched phase/destination counts

Then test the live path:

H. LL-HLS fixed-resolution single rendition
I. LL-HLS ABR ladder with all renditions same resolution
J. LL-HLS ABR ladder with resolution changes

For every call capture the actual pixel-buffer properties immediately before process(parameters:).

Interpretation:

A stable, B/C/D reproduce
→ geometry invariant is isolated

A–G stable, J fails exactly after a resolution switch
→ session/configuration lifetime across format changes becomes primary

H/I/J all stable after buffer standardization
→ LL-HLS and 60 fps were environmental context, not root cause

If a source-format change is observed, compare:

old VTFrameProcessor session + new geometry
vs
endSession → new configuration → startSession → new geometry

Only call session recreation necessary if this A/B demonstrates it.

Solution / Guideline#

  1. Treat the VTFrameProcessorConfiguration pixel-buffer attributes as the processing contract.
  2. Before every process call, verify the actual CVPixelBuffer width, height, pixel format, and relevant allocation attributes for previous, source, and destination frames.
  3. Allocate destination buffers from one centralized geometry/configuration source rather than independently recomputing sizes in multiple pipeline components.
  4. Validate interpolationPhase.count and destinationFrames.count as a separate invariant.
  5. If decoded format changes during ABR/live playback, do not pass new-format frames into a processor session configured for another geometry; first prove whether the session must be rebuilt for that change.
  6. Keep LL-HLS, FairPlay, and network investigation downstream until the same buffers pass the frame-processor input invariants.
  7. A framework array trap is still worth filing with Apple because invalid public input should ideally fail through a documented error surface rather than crash the process; include a minimal mismatched-buffer repro if one can be reduced.

Reusable engineering rule#

For hardware/ML media processors, validate the actual frame-buffer contract before debugging the media transport that produced those frames.

Use this boundary order:

stream / decoder
→ actual CVPixelBuffer geometry
→ processor configuration contract
→ previous/source frame compatibility
→ destination allocation compatibility
→ parameter cardinality
→ VTFrameProcessor execution

A crash inside an Apple processing implementation does not prove the source stream is invalid or the framework algorithm is intrinsically broken. First compare every buffer entering the call against the session configuration. In this incident, restoring that invariant removed the crash.

References#