For people who want to show an alert as soon as possible after the FamilyActivityPicker has crashed, I'll share my workaround !
Workaround
struct MyView : View {
let stateUpdateTimer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
@State private var updateFlag: Bool = false
var body : some View {
ZStack {
Text(verbatim: "A") // This should not be empty.
.foregroundStyle(.clear)
.accessibilityHidden(true)
.opacity(updateFlag ? 1 : 0)
ContentUnavailableView(...)
FamilyActivityPicker(...)
}
.onReceive(stateUpdateTimer) { _ in
updateFlag.toggle()
}
}
}
Description
At first glance, it looks like the FamilyActivityPicker has frozen, but I realized that it simply doesn’t redraw. Therefore, if there is an event that triggers a redraw, it will quickly transition to a transparent after the crash.
The above code forces a view update every second by toggling the opacity of a view that is completely irrelevant to the user.
This let the FamilyActivityPicker transition to a transparent and immediately show an alert in ZStack.
Good Points
This workaround doesn't touch any private API and private class. It relies only on public APIs and minimal code, therefore It will continue to work without issues even if the internal implementation is changed in the future.