Repository navigation
[camera_avfoundation] Use of improperly initialised _lastVideoSampleTime in captureOutput #132014
Copy link
Copy link
Closed
flutter/packages
#6897Labels
⏳Bot is counting down the days until it unassigns the issueBot is counting down the days until it unassigns the issueP2Important issues not at the top of the work listImportant issues not at the top of the work listc: fatal crashCrashes that terminate the processCrashes that terminate the processfound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13has 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 teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
Run test code.
Expected results
No crash.
Actual results
Property _lastVideoSampleTime (and also _lastAudioSampleTime) may be improperly initialised when used in CMTimeSubtract which can lead to this exception:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer:withPresentationTime:] invalid parameter not satisfying: CMTIME_IS_NUMERIC(presentationTime)'
libc++abi: terminating with uncaught exception of type NSException
* thread #9, queue = 'io.flutter.camera.captureSessionQueue', stop reason = signal SIGABRT
Code sample
Code sample
import "dart:io";
import "package:flutter/material.dart";
import "package:camera/camera.dart";
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override Widget build(BuildContext context) => const MaterialApp(home: MyHomePage());
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool loading = true;
int counter = 0;
late CameraController camera_cont;
@override void dispose() {
camera_cont.dispose();
super.dispose();
}
@override void initState() {
super.initState();
init_camera();
}
init_camera() async {
final cameras = await availableCameras();
camera_cont = CameraController(cameras.firstWhere((camera) => camera.lensDirection == CameraLensDirection.back), ResolutionPreset.ultraHigh);
await camera_cont.initialize();
setState(() => loading = false);
await camera_cont.prepareForVideoRecording();
for(int i = 0; i < 100; i++)
{
setState(() => counter = i);
await camera_cont.startVideoRecording();
await camera_cont.pauseVideoRecording();
await camera_cont.resumeVideoRecording();
await Future.delayed(const Duration(milliseconds: 100));
final file = await camera_cont.stopVideoRecording();
await File(file.path).delete();
}
}
@override Widget build(BuildContext context)
{
if(loading)return const Center(child: CircularProgressIndicator());
else return Stack(
alignment: Alignment.center,
children: [
CameraPreview(camera_cont),
Text("$counter"),
],
);
}
}Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.10.6, on macOS 13.5 22G74 darwin-x64)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
⏳Bot is counting down the days until it unassigns the issueBot is counting down the days until it unassigns the issueP2Important issues not at the top of the work listImportant issues not at the top of the work listc: fatal crashCrashes that terminate the processCrashes that terminate the processfound in release: 3.10Found to occur in 3.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13Found to occur in 3.13has 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 teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Activity
danagbemava-nc commentedon Aug 7, 2023
I can reproduce the crash using the code sample provided above.
The crash didn't always reproduce for me. It took a few re-runs of the app to reproduce the crash.
flutter doctor -v
misos1 commentedon Aug 7, 2023
It can sometimes trigger #132016 or even #69874. Or did it actually count to 99?
danagbemava-nc commentedon Aug 7, 2023
It counted to 99 in some cases
7 remaining items
flutter-triage-bot commentedon Jul 3, 2024
This issue is assigned to @hellohuanlin but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!
[camera_avfoundation] fix sample times not being numeric after pause/…
github-actions commentedon Jul 24, 2024
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 sample times not being numeric after pause/…
[camera_avfoundation] fix sample times not being numeric after pause/…