Skip to content

[camera] Calling setFocusMode() on iOS front-facing camera crashes app: [AVCaptureDevice setFocusMode:] Unsupported focusMode - use -isFocusModeSupported: to discover valid focus modes #76498

@acoutts

Description

@acoutts

Steps to Reproduce

  1. Run the example camera app on any iOS device
  2. Switch to the front facing selfie camera
  3. Tap the focus mode button and change it to "Locked"
  4. App will crash.

Expected results:
If a focus mode is not supported, it should handle the exception and not crash the app.

Actual results:
App immediately crashes (exits) with the following native exception:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureDevice setFocusMode:] Unsupported focusMode - use -isFocusModeSupported: to discover valid focus modes'
*** First throw call stack:
(0x18c12186c 0x1a113cc50 0x1a648d3c0 0x1056459fc 0x1056456a8 0x10564a718 0x105648714 0x18bd1424c 0x18bd15db0 0x18bd1d10c 0x18bd1dc5c 0x18bd27d78 0x1d7bd1814 0x1d7bd876c)
libc++abi.dylib: terminating with uncaught exception of type NSException
* thread #42, queue = 'io.flutter.camera.dispatchqueue', stop reason = signal SIGABRT
    frame #0: 0x00000001ba076414 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x1ba076414 <+8>:  b.lo   0x1ba076434               ; <+40>
    0x1ba076418 <+12>: pacibsp
    0x1ba07641c <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1ba076420 <+20>: mov    x29, sp
Target 0: (Runner) stopped.
Lost connection to device.
Exited (sigterm)

Logs
[✓] Flutter (Channel dev, 1.27.0-4.0.pre, on macOS 11.1 20C69 darwin-arm, locale en-US)
    • Flutter version 1.27.0-4.0.pre at /Users/andrewcoutts/Projects/flutter
    • Framework revision f8cd24de95 (5 days ago), 2021-02-16 11:24:17 -0800
    • Engine revision 1d537824d6
    • Dart version 2.13.0 (build 2.13.0-30.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/andrewcoutts/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /Users/andrewcoutts/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

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

[✓] Android Studio (version 4.1)
    • 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 1.8.0_242-release-1644-b3-6915495)

[✓] Connected device (3 available)
    • Pixel 4 (mobile)   • 9A311FFAZ00C03            • android-arm64  • Android 11 (API 30)
    • xff0c-12p (mobile) • 00008101-00196C340C29003A • ios            • iOS 14.4
    • Chrome (web)       • chrome                    • web-javascript • Google Chrome 88.0.4324.182

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work listc: crashStack traces logged to the consolec: fatal crashCrashes that terminate the processfound in release: 1.22Found to occur in 1.22has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions