Skip to content

fix(export): throw on overlay exports on the iOS Simulator instead of crashing - #212

Merged
SteliyanH merged 1 commit into
developfrom
fix/simulator-overlay-export-error
Oct 29, 2026
Merged

SteliyanH merged 1 commit into
developfrom
fix/simulator-overlay-export-error

Conversation

@SteliyanH

Copy link
Copy Markdown
Owner

Follow-up to the Simulator crash analysis (PR #210, docs PR #211).

Problem

On the iOS 26.5 and 27.0 Simulators, any export with overlays kills the app: AVVideoCompositionCoreAnimationTool's renderer wraps AVFoundation's malloc-backed frames in an IOSurface, and libxpc traps with "Attempt to pass a malloc(3)ed region to xpc_shmem_create()". The trap can't be caught. It also crashes any iOS Simulator test run that reaches an overlay export test.

Change

  • ExportEngine.simulatorOverlayError(hasOverlays:onIOSSimulator:): on the iOS Simulator (targetEnvironment(simulator) && os(iOS)), an export with overlays throws KadrError.exportFailed before rendering, with a message pointing to the Known Platform Issues article. No new error case, so it stays source-compatible for a patch release.
  • Limited to the iOS Simulator, the only one verified. tvOS and visionOS Simulators are untouched.
  • Docs: the article now describes the refusal, and Video.export(to:) has an Important callout.
  • Tests:
    • SimulatorOverlayExportTests: 3 decision tests that run everywhere, plus a Simulator-only test that the export throws and writes no file.
    • The 14 tests that export with overlays (including the .watermark one) get .disabled(if: TestEnvironment.overlayExportsUnsupported, …), so they're skipped with a reason on the iOS Simulator.

Why not a real workaround

A pass-through compositor writing into IOSurface-backed buffers does avoid the crash, but AVFoundation's built-in compositor can't be asked for such buffers. A workaround would mean re-implementing the built-in compositor's transforms, opacity ramps and transitions as a Simulator-only rendering path. Revisit if someone needs overlay exports on the Simulator (e.g. UI tests on CI), or drop this check once Apple fixes the runtime.

Results

  • macOS: 683 tests pass (swift test --no-parallel).
  • iOS 26.5 Simulator, full suite: 683 tests pass, 15 skipped, 0 failures, no crash. Before this change, the first overlay export test crashed the whole run.
  • xcodebuild docbuild succeeds with no new warnings.

… crashing

On the iOS 26.5 and 27.0 Simulators, AVVideoCompositionCoreAnimationTool's
renderer wraps AVFoundation's malloc-backed frames in an IOSurface, and
libxpc kills the app ("Attempt to pass a malloc(3)ed region to
xpc_shmem_create()"). The trap can't be caught, so refuse overlay exports
on the iOS Simulator with KadrError.exportFailed pointing to the Known
Platform Issues article.

Tests that export with overlays are skipped on the iOS Simulator; a
Simulator-only test checks the refusal.
@SteliyanH
SteliyanH merged commit 6a5d60b into develop Oct 29, 2026
2 checks passed
@SteliyanH
SteliyanH deleted the fix/simulator-overlay-export-error branch October 29, 2026 08:05
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant