Skip to content

[camera_avfoundation] Crash when taking a photo after switching cameras during recording #168134

@RobertOdrowaz

Description

@RobertOdrowaz

Steps to reproduce

  1. Run the camera example app
  2. Select a camera
  3. Start recording
  4. Switch to a different camera (this currently doesn't work because of this issue, but I will merge a fix for it shortly)
  5. Stop recording
  6. Take a picture

Expected results

Picture is taken and saved

Actual results

Crash with an exception

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] No active and enabled video connection'
*** First throw call stack:
(0x18a50d2ec 0x187991a7c 0x1a967fcf4 0x100e57514 0x100e4c9c4 0x100e465f0 0x101aa4584 0x101abe064 0x101aac91c 0x101aad5a4 0x101ab9894 0x101ab8eb0 0x214971660 0x21496e9f8)
libc++abi: terminating due to uncaught exception of type NSException

Code sample

The issue can be reproduced on the current (hash: 8d01cd9a48399d52821e35212644037bdbe8eab7) camera example app (not the camera_avfoundation example app because IIRC it blocks switching cameras during recording)

Screenshots or Video

No response

Logs

Logs
flutter: The Dart VM service is listening on http://127.0.0.1:51345/vxD_e8S6l28=/
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] No active and enabled video connection'
*** First throw call stack:
(0x18a50d2ec 0x187991a7c 0x1a967fcf4 0x100e57514 0x100e4c9c4 0x100e465f0 0x101aa4584 0x101abe064 0x101aac91c 0x101aad5a4 0x101ab9894 0x101ab8eb0 0x214971660 0x21496e9f8)
libc++abi: terminating due to uncaught exception of type NSException

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.27.4, on macOS 14.1.1 23B81 darwin-arm64, locale en-PL)
    • Flutter version 3.27.4 on channel stable at /Users/robert/fvm/versions/3.27.4
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d8a9f9a52e (3 months ago), 2025-01-31 16:07:18 -0500
    • Engine revision 82bd5b7209
    • Dart version 3.6.2
    • DevTools version 2.40.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/robert/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/robert/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)

[✓] VS Code (version 1.99.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.108.0

[✓] Connected device (5 available)
    • Robert’s iPhone (mobile)        • 00008110-000275E03ABA401E            • ios            • iOS 18.4.1 22E252
    • iPhone 15 Pro (mobile)          • 249E15C2-6A2F-418A-9F17-E49B20537775 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0
      (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 14.1.1 23B81 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 14.1.1 23B81 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 135.0.7049.115
    ! Error: Browsing on the local area network for Anna’s iPad. Ensure the device is unlocked and attached with a cable or associated with
      the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: crashStack traces logged to the consolep: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions