Hi team, I've meet this issue when using swiftUI to present a sheet for some cases under visionPro project. Looks like the object inside sheet's view never get released which cause the memory leak. Somehow it looks like:
class ViewModel: ObservableObject {
@Published var title: String = "Title"
init() {
print("init")
}
deinit {
print("deinit")
}
}
struct SheetView: View {
@ObservedObject var viewModel: ViewModel
var body: some View {
Text(viewModel.title)
}
}
struct Content: View {
@State var isPresentedSheet = false
@StateObject var viewModel = ViewModel()
var body: some View {
Button {
isPresentedSheet.toggle()
} label: {
Text("Click to Present")
}
.sheet(isPresented: $isPresentedSheet) {
SheetView(viewModel: viewModel)
}
}
}
I've tried with .popover, seems it's not happening.
I've seen a similar one in https://developer.apple.com/forums/thread/737967?answerId=767599022#767599022, not sure apple plans to do some fix for vision in the future build releases.