The package crashes at random times after starting a recording.
Code:
EdScreenRecorder screenRecorder = EdScreenRecorder();
Map<String, dynamic>? _response;
DateTime? _time;
int _seconds = 0;
int _minutes = 0;
Timer _timer = Timer(const Duration(seconds: 1), () {});
Future<void> _startRecord() async {
try {
var status = await Permission.microphone.request();
if (status != PermissionStatus.granted) {
throw RecordingPermissionException('Microphone permission not granted');
}
var startResponse = await screenRecorder.startRecordScreen(
fileName: "snap_video_memo",
audioEnable: true,
);
setState(() {
_response = startResponse;
});
final DateTime startTime = DateTime.now();
_timer = Timer.periodic(const Duration(seconds: 1), (_) {
final DateTime now = DateTime.now();
_seconds = now.second - startTime.second;
_minutes = now.minute - startTime.minute;
setState(() => _time = DateFormat("hh:mm:ss").parse("00:0$_minutes:0$_seconds"));
});
try {
screenRecorder.watcher?.events.listen(
(event) {
log(event.type.toString(), name: "Event: ");
},
onError: (e) => kDebugMode ? debugPrint('ERROR ON STREAM: $e') : null,
onDone: () => kDebugMode ? debugPrint('Watcher closed!') : null,
);
} catch (e) {
kDebugMode ? debugPrint('ERROR WAITING FOR READY: $e') : null;
}
} on PlatformException {
kDebugMode ? debugPrint("Error: An error occurred while starting the recording!") : null;
}
}
Future<void> _stopRecord() async {
try {
_timer.cancel();
var status = await Permission.storage.request();
if (status != PermissionStatus.granted) {
throw RecordingPermissionException('Storage permission not granted');
}
var stopResponse = await screenRecorder.stopRecord();
setState(() {
_response = stopResponse;
_uploading = true;
});
if (_response?['file'] != null && _response?['enddate'] != null && _response?['startdate'] != null) {
int length = DateTime.fromMicrosecondsSinceEpoch(_response!['enddate']).difference(DateTime.fromMicrosecondsSinceEpoch(_response!['startdate'])).inSeconds;
print('completeMemo(video: _response!['file'], answeredDate: DateTime.now(), videoLength: length);');
Navigator.of(context).pop();
} else {
setState(() {
_uploading = false;
});
}
//await LatexGenerator.showDialog(context);
} on PlatformException {
kDebugMode ? debugPrint("Error: An error occurred while stopping recording.") : null;
}
}
flutter doctor:
Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 3.1.0-0.0.pre.1354, on macOS 12.3.1 21E258 darwin-arm, locale en-ZA)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] Android Studio (version 2021.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.1.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.1.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.1.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
IDE Error log:
flutter: >>> Stop Record Response Output:
flutter: File: File: '/var/mobile/Containers/Data/Application/8443B0C4-9D50-4B1D-97C6-2DE7625475CF/Documents/snap_video_memo.mp4'
flutter: Event Name: stopRecordScreen
flutter: Progressing: false
flutter: Message: Started Video
flutter: Success: true
flutter: Video Hash: 6ee1fef0f2c011ecbaf8f721e3f4105d
flutter: Start Date: 1655966884976
flutter: End Date: 1655966889487
flutter:
flutter: VideoCompress: You can try to subscribe to the
flutter: compressProgress$ stream to know the compressing state.
video_compress/SwiftVideoCompressPlugin.swift:202: Fatal error: Unexpectedly found nil while unwrapping an Optional value
video_compress/SwiftVideoCompressPlugin.swift:202: Fatal error: Unexpectedly found nil while unwrapping an Optional value
* thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: Unexpectedly found nil while unwrapping an Optional value
frame #0: 0x0000000185773458 libswiftCore.dylib`_swift_runtime_on_report
libswiftCore.dylib`_swift_runtime_on_report:
-> 0x185773458 <+0>: ret
libswiftCore.dylib`_swift_reportToDebugger:
0x18577345c <+0>: b 0x185773458 ; _swift_runtime_on_report
libswiftCore.dylib`_swift_shouldReportFatalErrorsToDebugger:
0x185773460 <+0>: adrp x8, 335343
0x185773464 <+4>: ldrb w0, [x8, #0x45c]
Target 0: (Runner) stopped.
Xcode Error log:
2022-06-23 08:54:18.831277+0200 Runner[9122:504772] flutter: >>> Stop Record Response Output:
2022-06-23 08:54:18.831387+0200 Runner[9122:504772] flutter: File: File: '/var/mobile/Containers/Data/Application/56E6DF0B-A826-4342-AFE2-9B2A564E2EC5/Documents/snap_video_memo.mp4'
2022-06-23 08:54:18.831461+0200 Runner[9122:504772] flutter: Event Name: stopRecordScreen
2022-06-23 08:54:18.831524+0200 Runner[9122:504772] flutter: Progressing: false
2022-06-23 08:54:18.831592+0200 Runner[9122:504772] flutter: Message: Started Video
2022-06-23 08:54:18.831658+0200 Runner[9122:504772] flutter: Success: true
2022-06-23 08:54:18.831722+0200 Runner[9122:504772] flutter: Video Hash: 483ba0c0f2c111ec93106b66d096339b
2022-06-23 08:54:18.831788+0200 Runner[9122:504772] flutter: Start Date: 1655967249633
2022-06-23 08:54:18.831976+0200 Runner[9122:504772] flutter: End Date: 1655967258830
2022-06-23 08:54:18.832207+0200 Runner[9122:504772] flutter:
2022-06-23 08:54:18.832743+0200 Runner[9122:504772] flutter: VideoCompress: You can try to subscribe to the
2022-06-23 08:54:18.832812+0200 Runner[9122:504772] flutter: compressProgress$ stream to know the compressing state.
video_compress/SwiftVideoCompressPlugin.swift:202: Fatal error: Unexpectedly found nil while unwrapping an Optional value
2022-06-23 08:54:18.849100+0200 Runner[9122:504496] video_compress/SwiftVideoCompressPlugin.swift:202: Fatal error: Unexpectedly found nil while unwrapping an Optional value
The package crashes at random times after starting a recording.
Code:
flutter doctor:
IDE Error log:
Xcode Error log: