Copy of Feedback: FB15969432
Improve window management with immersive spaces.
It is hard to manage windows from code when entering immersive space. Look for instance at the sample: https://developer.apple.com/documentation/visionos/displaying-a-3d-environment-through-a-portal
The window displayed before entering the virtual space stays there once the virtual space is entered : this window is too big but can't be resized by the program. One could say this big window could be closed and a smaller window opened by the program with the "exit" button, but then this small window should be closed and the main window reopened when leaving te immersive space.
In the immersive space closing the "Exit" window with the X does not allow to leave the immersive space. If the crown button is then used we go back to the Vision Pro main menu. If the app is chosen again we can see that it wasn't closed : the "Exit" window is now displayed but we are not in the immersive space!
Don't say "this is just a sample app", because all developers face those issues. Please try to find the right solutions with your team to enhance this sample and share the right way to solve those issues. You could find that the specifications need to be enhanced. You can also see that there is no way to exit a program from a program even if this is something that could be useful for some apps (you end a SharePlay game for instance)
Thank you very much for your time and consideration.
Hey @lAppliEnRose,
This is great feedback on the sample project. There is API to resize the window and to track when the user is in the immersive space.
The window resizability API allows you to resize the window. Add .windowResizability(.contentSize)
to your window group and, when needed, set a specific size on any views. If you add this to the sample app, you'll want to add a specific size like .frame(width: 1200, height: 800)
to the GeometryReader3D
.
The template project for an application that has an immersive space is a great starting point for keeping track of the immersive space state. Create a new project in Xcode for visionOS and choose RealityKit as the Immersive Space Renderer. This will create a project that includes an AppModel
that stores the immersiveSpaceState
and a ToggleImmersiveSpaceButton
that will open or close the immersive space based on the state.
As you've noticed, there are multiple paths to close the immersive space and the sample app doesn't account for this. The template project updates this state in the onAppear(perform:)
and onDisappear(perform:)
on the root view of the immersive space:
ImmersiveSpace(id: appModel.immersiveSpaceID) {
ImmersiveView()
.onAppear {
appModel.immersiveSpaceState = .open
}
.onDisappear {
appModel.immersiveSpaceState = .closed
}
}
Let me know if you have any additional questions,
Michael