Closed aykutuludag closed 9 months ago
Fatal Exception: FlutterError
0 ??? 0x0 IOSAlarm.setAlarm + 59 (ios_alarm.dart:59)
1 ??? 0x0 (null).createAlarm + 73 (alarm_utils.dart:73)
Here is AlarmUtils.createAlarm:
Future<void> createAlarm(int alarmId, DateTime dateTime, String title, String body) async {
final alarmSettings = AlarmSettings(
id: alarmId,
dateTime: dateTime,
assetAudioPath: 'assets/notification.mp3',
loopAudio: false,
vibrate: true,
volume: 1,
//fadeDuration: 3.0,
notificationTitle: title,
notificationBody: body,
enableNotificationOnKill: false,
);
await Alarm.set(alarmSettings: alarmSettings);
}
Crashed: com.apple.root.default-qos
0 libswiftCore.dylib 0x400034 swift_isUniquelyReferenced_nonNull_native + 38
1 alarm 0x9b8c $s5alarm16SwiftAlarmPluginC03setC033_6E2EED5D4137BAF8EC3EC9399D6BB069LL4call6resultySo17FlutterMethodCallC_yypSgXEtF + 5620
2 alarm 0x10af4 $s5alarm16SwiftAlarmPluginC6handle_6resultySo17FlutterMethodCallC_yypSgctFyyYbcfU_TA + 428
3 alarm 0xa4ac $sIegh_IeyBh_TRTm + 28
4 libdispatch.dylib 0x26a8 _dispatch_call_block_and_release + 32
5 libdispatch.dylib 0x4300 _dispatch_client_callout + 20
6 libdispatch.dylib 0x744c _dispatch_queue_override_invoke + 928
7 libdispatch.dylib 0x15be4 _dispatch_root_queue_drain + 392
8 libdispatch.dylib 0x163ec _dispatch_worker_thread2 + 156
9 libsystem_pthread.dylib 0x1928 _pthread_wqthread + 228
10 libsystem_pthread.dylib 0x1a04 start_wqthread + 8
I guess this error is triggering when alarm plugin create/send notification request.
Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x4820 objc_msgSend + 32
1 CoreFoundation 0x2f4c8 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
2 CoreFoundation 0x2ee90 ___CFXRegistrationPost_block_invoke + 88
3 CoreFoundation 0x2edd8 _CFXRegistrationPost + 440
4 CoreFoundation 0x2e328 _CFXNotificationPost + 724
5 Foundation 0x2a864 -[NSNotificationCenter postNotificationName:object:userInfo:] + 92
6 AudioSession 0x169fc __63-[AVAudioSession privatePostNotificationForType:name:userInfo:]_block_invoke + 72
7 libdispatch.dylib 0x26a8 _dispatch_call_block_and_release + 32
8 libdispatch.dylib 0x4300 _dispatch_client_callout + 20
9 libdispatch.dylib 0x12998 _dispatch_main_queue_drain + 984
10 libdispatch.dylib 0x125b0 _dispatch_main_queue_callback_4CF + 44
11 CoreFoundation 0x3720c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
12 CoreFoundation 0x33f18 __CFRunLoopRun + 1996
13 CoreFoundation 0x33668 CFRunLoopRunSpecific + 608
14 GraphicsServices 0x35ec GSEventRunModal + 164
15 UIKitCore 0x22c2b4 -[UIApplication _run] + 888
16 UIKitCore 0x22b8f0 UIApplicationMain + 340
17 Runner 0x46d4 main + 7 (AppDelegate.swift:7)
18 ??? 0x1c0ad2dcc (Missing)
Hi @aykutuludag
Thanks for your feedback.
Just one question before I start to investigate about these issues. Do you use await
when you call Alarm.set
? Because these look like thread issues.
Of course. I am setting Alarm.init with await like following:
Future<void> main() async {
try {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
await Alarm.init();
} catch (error) {
print(error);
}
runApp(const MyApp());
}
And alarms are setting somewhere in MyApp. Based on code it should await until alarm initialized.
Crashed: com.apple.root.default-qos
0 CoreFoundation 0x245b0 CFGetTypeID + 100
1 CoreFoundation 0x24290 __CFPropertyListIsValidAux + 60
2 CoreFoundation 0x622b8 CFPropertyListCreateData + 220
3 libAudioToolboxUtility.dylib 0x2c864 CASerializer::WritePlist(void const*) + 44
4 AudioToolbox 0xe5668 <redacted> + 40
5 AudioToolbox 0xe5774 <redacted> + 64
6 libAudioToolboxUtility.dylib 0x1c02c PropertyMarshaller::Serialize(unsigned int, void const*, unsigned int, PropertyMarshaller::EClientServer) + 232
7 AudioToolbox 0xe0afc <redacted> + 568
8 AVFAudio 0x851e4 AVAudioPlayerCpp::prepareToPlayQueue() + 272
9 AVFAudio 0x84fac AVAudioPlayerCpp::playQueue(AudioTimeStamp const*) + 116
10 AVFAudio 0x84b38 AVAudioPlayerCpp::DoAction(unsigned int, unsigned long, void const*) + 164
11 AVFAudio 0x35468 -[AVAudioPlayer play] + 40
12 alarm 0xa944 $s5alarm16SwiftAlarmPluginC16startSilentSound33_6E2EED5D4137BAF8EC3EC9399D6BB069LLyyF + 824
13 alarm 0x9f6c $s5alarm16SwiftAlarmPluginC03setC033_6E2EED5D4137BAF8EC3EC9399D6BB069LL4call6resultySo17FlutterMethodCallC_yypSgXEtF + 6612
14 alarm 0x10af4 $s5alarm16SwiftAlarmPluginC6handle_6resultySo17FlutterMethodCallC_yypSgctFyyYbcfU_TA + 428
15 alarm 0xa4ac $sIegh_IeyBh_TRTm + 28
16 libdispatch.dylib 0x26a8 _dispatch_call_block_and_release + 32
17 libdispatch.dylib 0x4300 _dispatch_client_callout + 20
18 libdispatch.dylib 0x744c _dispatch_queue_override_invoke + 928
19 libdispatch.dylib 0x15be4 _dispatch_root_queue_drain + 392
20 libdispatch.dylib 0x163ec _dispatch_worker_thread2 + 156
21 libsystem_pthread.dylib 0x1928 _pthread_wqthread + 228
22 libsystem_pthread.dylib 0x1a04 start_wqthread + 8
Crashed: com.apple.root.default-qos
0 libswiftCore.dylib 0x400034 swift_isUniquelyReferenced_nonNull_native + 38
1 alarm 0x9b8c $s5alarm16SwiftAlarmPluginC03setC033_6E2EED5D4137BAF8EC3EC9399D6BB069LL4call6resultySo17FlutterMethodCallC_yypSgXEtF + 5620
2 alarm 0x10ad0 $s5alarm16SwiftAlarmPluginC6handle_6resultySo17FlutterMethodCallC_yypSgctFyyYbcfU_TA + 428
3 alarm 0xa4ac $sIegh_IeyBh_TRTm + 28
4 libdispatch.dylib 0x26a8 _dispatch_call_block_and_release + 32
5 libdispatch.dylib 0x4300 _dispatch_client_callout + 20
6 libdispatch.dylib 0x744c _dispatch_queue_override_invoke + 928
7 libdispatch.dylib 0x15be4 _dispatch_root_queue_drain + 392
8 libdispatch.dylib 0x163ec _dispatch_worker_thread2 + 156
9 libsystem_pthread.dylib 0x1928 _pthread_wqthread + 228
10 libsystem_pthread.dylib 0x1a04 start_wqthread + 8
Crashed: com.apple.root.default-qos
0 libswiftCore.dylib 0x400034 swift_isUniquelyReferenced_nonNull_native + 38 1 alarm 0x9b8c $s5alarm16SwiftAlarmPluginC03setC033_6E2EED5D4137BAF8EC3EC9399D6BB069LL4call6resultySo17FlutterMethodCallC_yypSgXEtF + 5620 2 alarm 0x10ad0 $s5alarm16SwiftAlarmPluginC6handle_6resultySo17FlutterMethodCallC_yypSgctFyyYbcfU_TA + 428 3 alarm 0xa4ac $sIegh_IeyBh_TRTm + 28 4 libdispatch.dylib 0x26a8 _dispatch_call_block_and_release + 32 5 libdispatch.dylib 0x4300 _dispatch_client_callout + 20 6 libdispatch.dylib 0x744c _dispatch_queue_override_invoke + 928 7 libdispatch.dylib 0x15be4 _dispatch_root_queue_drain + 392 8 libdispatch.dylib 0x163ec _dispatch_worker_thread2 + 156 9 libsystem_pthread.dylib 0x1928 _pthread_wqthread + 228 10 libsystem_pthread.dylib 0x1a04 start_wqthread + 8
I believe that I fixed this bug. I am not sure, I debugged your app but I couldn't find any error. However I researched the issue and they suggested that issue is about AVAudioSession. Following code may fix the issue.
In SwiftAlarmPlugin.swift
private func mixOtherAudios() {
do {
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(.playback, mode: .default, options: [.mixWithOthers])
try audioSession.setActive(true)
} catch {
NSLog("SwiftAlarmPlugin: Error setting up audio session with option mixWithOthers: \(error.localizedDescription)")
}
}
private func duckOtherAudios() {
do {
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(.playback, mode: .default, options: [.duckOthers])
try audioSession.setActive(true)
} catch {
NSLog("SwiftAlarmPlugin: Error setting up audio session with option duckOthers: \(error.localizedDescription)")
}
}
This issue is probably about this crash. https://github.com/gdelataillade/alarm/issues/140
Hi @aykutuludag
I'm not able to see your image you provided in your last message.
OK, I'll try to apply your fix. For the next release.
Huge thanks for your effort. I'm applying v3.0.7 and sending new release. I will share if any bug encounters. Best regards.
Alarm plugin version v3.0.3-3.0.4-3.0.5
Describe the bug Native crash in Android
To Reproduce Nothing. Plugin implemented regularly.
Expected behavior Working without crash.
Screenshots In the comments