Repository navigation
[camera_avfoundation] Crash when opening camera stream starting from 0.9.19+2 #170240
Copy link
Copy link
Closed
flutter/packages
#9418Labels
c: crashStack traces logged to the consoleStack traces logged to the consolec: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginThe camera pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamOwned by iOS platform team
Description
Steps to reproduce
- Run the camera example app on physical device (reproduced on iPhone 12, 15 Pro Max, 16 Pro)
- Select a camera
- Start stream
- Camera crashes with "Unsupported value: (Function) of type __SwiftValue" error
Expected results
Stream opens normally
Actual results
Unsupported value: (Function) of type __SwiftValue
0.9.19+1 version works as expected
Code sample
Code sample
import 'package:camera/camera.dart';
import 'package:flutter/foundation.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
final scanController = StateNotifierProvider.autoDispose<ScanController, CameraStatus>(
(ref) => ScanController(),
);
class ScanController extends StateNotifier<CameraStatus> {
CameraController? _cameraController;
CameraDescription? _camera;
CameraController? get cameraController => _cameraController;
ScanController() : super(CameraStatus.off); // Estado inicial de la cámara
Future initCamera() async {
try {
_camera = (await availableCameras()).firstOrNull;
if (_camera == null) {
debugPrint('No camera available');
return;
}
_cameraController = CameraController(_camera!, ResolutionPreset.high, enableAudio: false);
// Inicializar cámara
_cameraController!.initialize().then((_) async {
if (!mounted) return;
await _cameraController!.startImageStream((image) {});
}).catchError((_) {
_cameraController?.dispose();
});
} on CameraException catch (e) {
debugPrint('Error iniciando cámara: ${e.description}');
} catch (e) {
debugPrint('Error iniciando cámara: $e');
}
}
}
enum CameraStatus {
off, // Estado inicial. La cámara no está preparada para capturar imagen.
ready, // La cámara está lista para capturar imagen y a la espera.
}
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
class ScanScreen extends ConsumerWidget {
const ScanScreen({super.key});
static String get routeName => 'scan';
@override
Widget build(BuildContext context, WidgetRef ref) {
final controller = ref.watch(scanController.notifier);
WidgetsBinding.instance.addPostFrameCallback((_) => controller.initCamera());
final cameraController = controller.cameraController;
final isCameraInitialized = cameraController?.value.isInitialized == true;
if (!isCameraInitialized) {
return const Center(child: CircularProgressIndicator());
}
return Scaffold(body: Center(child: CameraPreview(cameraController!)));
}
}
Screenshots or Video
Logs
Logs
<<<< FigCaptureSessionRemote >>>> Fig assert: "err == 0 " at bail (FigCaptureSessionRemote.m:855) - (err=-12784)
Unsupported value: (Function) of type __SwiftValue
*** Assertion failure in void WriteValueOfType(CFTypeRef, CFMutableDataRef, FlutterStandardCodecObjcType, CFTypeRef)(), FlutterStandardCodec.mm:341
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unsupported value for standard codec'
*** First throw call stack:
(0x19ca792ec 0x199efda7c 0x19bd76040 0x10e977ad4 0x10e97775c 0x19b332c5c 0x19b0b7c4c 0x19c9d984c 0x10e977be8 0x10e97775c 0x10e9789a4 0x10e9742a8 0x10481fa78 0x10481fadc 0x10481a184 0x105448584 0x105462064 0x105482f38 0x105458548 0x105458484 0x19c9d22b4 0x19c9d00b0 0x19c9f4700 0x1e9535190 0x19f612240 0x19f610470 0x19fa6ea30 0x1079a5188 0x1079a50f8 0x1079a5204 0x1c33f7ad8)
libc++abi: terminating due to uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unsupported value for standard codec'
*** First throw call stack:
(0x19ca792ec 0x199efda7c 0x19bd76040 0x10e977ad4 0x10e97775c 0x19b332c5c 0x19b0b7c4c 0x19c9d984c 0x10e977be8 0x10e97775c 0x10e9789a4 0x10e9742a8 0x10481fa78 0x10481fadc 0x10481a184 0x105448584 0x105462064 0x105482f38 0x105458548 0x105458484 0x19c9d22b4 0x19c9d00b0 0x19c9f4700 0x1e9535190 0x19f612240 0x19f610470 0x19fa6ea30 0x1079a5188 0x1079a50f8 0x1079a5204 0x1c33f7ad8)
terminating due to uncaught exception of type NSExceptionFlutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.32.2, on macOS 15.5 24F74 darwin-arm64, locale es-ES) [252ms]
• Flutter version 3.32.2 on channel stable at /Users/miguel/bin/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 8defaa71a7 (5 days ago), 2025-06-04 11:02:51 -0700
• Engine revision 1091508939
• Dart version 3.8.1
• DevTools version 2.45.1
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [1.117ms]
• Android SDK at /Users/miguel/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [694ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16F6
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [10ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.2) [9ms]
• 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+-12932927-b750.29)
[✓] VS Code (version 1.100.3) [9ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.56.0
[✓] Connected device (3 available) [5,8s]
[✓] Network resources [284ms]
• All expected network resources are available.
• No issues found!Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
c: crashStack traces logged to the consoleStack traces logged to the consolec: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.32Found to occur in 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginThe camera pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamOwned by iOS platform team

Activity
[-][camera_avfoundation] Crash when opening camera stream from 0.9.19+2[/-][+][camera_avfoundation] Crash when opening camera stream starting from 0.9.19+2[/+]darshankawar commentedon Jun 10, 2025
@SherpaMiguel Thanks for the report. I am unable to replicate this after running the camera example on iPhone 15 device. What device does it throw the error on ? Also, can you provide the complete error log ?
SherpaMiguel commentedon Jun 10, 2025
@darshankawar I have updated the description with some logs and a screenshot in Xcode. Also added an example (sorry, I use riverpod). Also note that issue occurs on iPhone 12, 15 Pro Max, 16 Pro.
Thank you in advance.
Deehodry-dhj commentedon Jun 10, 2025
Deehodry-dhj commentedon Jun 11, 2025
darshankawar commentedon Jun 11, 2025
Thanks for the update. This error is replicable without using riverpod as well, which throws below error log:
Verified upto
camera: ^0.11.0which throws the same error as above. Per OP, this worked in0.9.19+1so labeling this as regression.16 remaining items
knottx commentedon Jun 16, 2025
ethicnology commentedon Jun 16, 2025
You can also override the dependency version directly in your
pubspec.yamlfile usingdependency_overrides:knottx commentedon Jun 18, 2025
hellohuanlin commentedon Jun 18, 2025
This should be resolved after flutter/packages#9418 is landed.
[camera_avfoundation] Fix incorrect types in image stream events (flu…
Osmosis311 commentedon Jun 18, 2025
Thanks! What version will this end up in?
RobertOdrowaz commentedon Jun 20, 2025
@Osmosis311 It is in the
camera_avfoundation0.9.20. If you want to ensure you're using the fixed version, you can either explicitly add a constraint forcamera_avfoundationto yourpubspec.yamlor make sure you depend on the0.9.20version inpubspec.lock[camera_avfoundation] Fix incorrect types in image stream events (flu…
github-actions commentedon Jul 4, 2025
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.[camera_avfoundation] Fix incorrect types in image stream events (flu…
[camera_avfoundation] Fix incorrect types in image stream events (flu…
[camera_avfoundation] Fix incorrect types in image stream events (flu…