One of the most common ways to provide a window size in visionOS is to use the defaultSize
scene modifier.
WindowGroup(id: "someID") {
SomeView()
}
.defaultSize(CGSize(width: 600, height: 600))
Starting in visionOS 26, using this has a side effect. visionOS 26 will restore windows that have been locked in place or snapped to surfaces. If a user has manually adjusted the size of a locked/snapped window, the users size is only restore in some cases.
Manual resize respected
- Leaving a room and returning later
- Taking the headset off and putting it back on later
Manual resize NOT respected
- Device restart. In this case, the window is reopened where it was locked, but the size is set back to the values passed to
defaultSize
. The manual resizing adjustments the user has made are lost. This is counter to how all other windows and widgets work.
I reported this last month (FB18429638), but haven't heard back if this is a bug or intended behavior.
Questions
- What is the best way to provide a default window size that will only be used when opening new windows–and not used during scene restoration?
- Should we try to keep track of window size after users adjust them and save that somewhere?
- If this is intended behavior, can someone please update the docs accordingly?