I've found this issue from several reports from users. Sometimes it also occurs on my phone too, though I don't know the exact method to replicate it.
It seems that while sleeping, not only my app but other background apps also get suspended together. Investigating users' screenshots of system settings-battery page, every 'Screen Idle' app gets suspended at some point (mostly while sleeping) and audio stops after that.
The app is using mixable audio mode since some users want to listen to music simultaneously. Therefore, I am not going to use 'Now playing' as you mentioned.
@DTS Engineer
Post
Replies
Boosts
Views
Activity
@DTS Engineer I'm worried that the notification hasn't sent to you. would you please answer again?
I didn't used any custom property wrapper.
I just want to know why this code freezes when navigating to page2.
Oh the code seem to have broken while copy & paste.
Here's the code for 100% reproduction
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
Page1()
.environmentObject(Foo())
}
}
}
class Foo: ObservableObject {
init() {}
}
struct Page1: View {
@EnvironmentObject
private var viewModel: Foo
@Binding
var value: Int
init() {
self._value = .init(get: { 0 }, set: { _ in })
}
@State
private var id: UUID? = nil
var body: some View {
NavigationLink(value: 0) {
Text("Go to page2")
.padding()
.foregroundStyle(.white)
.background(.black)
.cornerRadius(12)
}
.navigationDestination(for: Int.self) { _ in
Page2(
onComplete: {
print("value", value)
}
)
}
}
}
struct Page2: View {
public init(onComplete _: @escaping() -> Void) {}
public var body: some View {
Text("This is Page2")
.task {
print("hi")
}
}
}