content .onPreferenceChange(SizeKey.self, perform: { sizes in // this is not always called }) .overlayPreferenceValue(SizeKey.self) { sizes in EmptyView().onAppear { // this is called more reliably // the view's id controls for which changes this is called }.id(sizes.map { $0.width*1000+$0.height }) }