AlarmKit sometimes creates a blank (empty) Live Activity

Hi!

My users have reported (and I have observed) a blank Live Activity where only a black capsule is shown in the dynamic island. When tapping that capsule, the app opens, but inside the capsule, nothing is shown. The Live Activity is created through the AlarmKit API like this:

let identifier = UUID()
            
Task {
    do {
        _ = try await AlarmManager.shared.schedule(
            id: identifier,
            configuration: .init(
                countdownDuration: countdownDuration,
                attributes: attributes,
                stopIntent: CancelTimerIntent(),
                secondaryIntent: RestartTimerIntent(),
                sound: Settings.shared.systemAlarmToneEnabled ? .default : .named(Settings.shared.alarmTone[.loop].filename)
            )
        )
        Log.debug("Alarm scheduled successfully: \(identifier.uuidString)")
    } catch {
        Log.error("Error scheduling alarm with id \(identifier.uuidString), error: \(error)")
    }
}

I've read some other forum posts where developers reported the same issue:

I assume, it has something to do with state management. However, in my case, this only happens very rarely. I use the app on a daily basis and the issue with the blank live activity only occurs like once a month, so I cannot reproduce it.

I also have some logic to resume an existing alarm or snooze:

do {
    for alarm in try AlarmManager.shared.alarms {
        switch alarm.state {
        case .paused:
            try AlarmManager.shared.resume(id: alarm.id)
        case .alerting:
            try AlarmManager.shared.countdown(id: alarm.id)
        default:
            break
        }
    }
} catch {
    Log.error("Error resuming alarm: \(error)")
}

Is there any way I can debug this issue properly?

I have checked the Device Logs and the Console in Xcode and didn't find any hints. Only one log made me a little suspicious, but I read that this might happen occasionally and may be ignored:

Couldn't read values in CFPrefsPlistSource<0x10ae0d080> (Domain: group.myappgroupidentifier User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd

Any ideas on how I could proceed to find the cause of this empty (apparently crashed) Live Activity?

AlarmKit sometimes creates a blank (empty) Live Activity
 
 
Q