Skip to content

Camera Capture Diagnostics

Systematic troubleshooting for AVFoundation camera issues including frozen previews, wrong rotation, slow capture, session interruptions, and permission problems.

Overview

When camera doesn't work, the problem is usually threading (35%), session lifecycle (25%), rotation (20%), permissions (15%), or configuration (5%). This diagnostic enforces environment checks before code debugging.

Symptoms This Diagnoses

Use when you're experiencing:

  • Black or frozen camera preview
  • UI freezes for 1-3 seconds when opening camera
  • Camera freezes during a phone call or in Split View
  • Preview or captured photo rotated 90 degrees wrong
  • Front camera photo doesn't match mirrored preview
  • Photo capture takes 2+ seconds
  • "Camera in use by another app" errors
  • Camera stops working after prolonged use (thermal)
  • Crash on older iOS versions using iOS 17+ APIs
  • Permission denied or not requested

Example Prompts

  • "My camera preview is just a black screen"
  • "The UI freezes when I open the camera"
  • "Camera freezes when I get a phone call"
  • "Why is the captured photo rotated wrong?"
  • "The front camera photo doesn't match the preview"
  • "Photo capture is really slow, takes 2+ seconds"
  • "Camera crashes on iOS 16 devices"
  • "User says camera permission is denied but they never saw a prompt"

Diagnostic Workflow

1. Check Session State (2 min)
   ├─ Verify session.isRunning = true
   ├─ Verify inputs.count >= 1
   ├─ Verify outputs.count >= 1
   └─ Check preview layer connection

2. Check Threading (2 min)
   ├─ Verify startRunning() is on background queue
   ├─ Verify all session work on sessionQueue
   └─ Verify UI updates on main thread

3. Check Permissions (1 min)
   ├─ Print authorizationStatus
   ├─ Handle .notDetermined (request)
   └─ Handle .denied (settings prompt)

4. Check Interruptions (2 min)
   ├─ Add interruption observer
   ├─ Reproduce with phone call
   └─ Verify UI feedback shown

Diagnostic Patterns

This skill covers 15 diagnostic patterns:

SymptomCheck FirstLikely Fix
Black previewSession stateStart session, add input, connect preview layer
UI freezesThreadingMove startRunning() to background queue
Freezes on callInterruptionsAdd interruption observer with UI feedback
Wrong rotationRotation angleUse RotationCoordinator (iOS 17+)
Slow captureQuality settingSet photoQualityPrioritization to .speed or .balanced
Denied accessPermissionsShow settings prompt
Crash on old iOS@available checkGuard iOS 17+ APIs
Random stopsThermal stateReduce quality, show cooling message
iPad Split ViewMultitaskingShow "unavailable in Split View" message
Front camera "bug"MirroringExplain: preview mirrors, photo does not (Apple standard)

Documentation Scope

This is a diagnostic skill -- it enforces systematic troubleshooting workflows before diving into code. Each of the 15 patterns includes specific symptoms, diagnostic steps, and fixes with estimated time to resolve.

For implementation patterns: See camera-capture for building camera features from scratch.

For API reference: See camera-capture-ref for complete API documentation.

Resources

WWDC: 2021-10247, 2023-10105

Docs: /avfoundation/avcapturesession, /avfoundation/avcapturesessionwasinterruptednotification

Released under the MIT License