I experienced a frustrating problem today wither with Xcode 13 and Xcode 13.1 rc that I have downloaded to test if the problem was presente also in the new version With a certain file Xcode sourcekitservice daemon went to a staggering 60-70 gb of memory causing the MacBook Pro m1 to freeze after a memory warning. After some investigation I found a weird problem (already signaled to apple bug reporting) with GeometryReader and frame.
//////
////// SwiftUIView.swift
////// ArteIncisa Evolution
//////
////// Created by Lorenzo Malaguti on 16/06/21.
////// Copyright © 2021 Nas-Tech. All rights reserved.
//////
////
import SwiftUI
//
struct BugTitolo: View {
@State var title:String
var body: some View {
Text(title)
//.font(.custom("INCIMAR Latino 221D1 v.3.0", size: 30))
.foregroundColor(.white)
.shadow(color: .black, radius: 2, x: /*@START_MENU_TOKEN@*/0.0/*@END_MENU_TOKEN@*/, y: /*@START_MENU_TOKEN@*/0.0/*@END_MENU_TOKEN@*/)
.padding(.horizontal, 25)
.modifier(containerRow(backTexture: "ardesia"))
}
}
struct BugView: View {
@Binding var isPresented:Bool
@State var cfg_Account:Bool = false
@State var cfg_Elements:Bool = false
//
let btnHeight:CGFloat = 50
let btnWidthMultiplier = 0.47
func GetColumnWitdh(screenwidth:CGFloat)->CGFloat
{
return screenwidth*btnWidthMultiplier
}
var body: some View {
GeometryReader{geom in
ZStack{
Image("back.003")
.resizable()
.blur(radius: 3)
.edgesIgnoringSafeArea(/*@START_MENU_TOKEN@*/.all/*@END_MENU_TOKEN@*/)
VStack{
NavigationLink("account",
destination: cfgAccountView(isPresented: $cfg_Account),
isActive: $cfg_Account)
NavigationLink("account",
destination: cfgElementiView(isPresented: $cfg_Elements),
isActive: $cfg_Elements)
}
.hidden()
// pulsante di ritorno e testo titolo-----------------------
VStack{
HStack{
Button(action: {
isPresented=false
}, label: {
Image(systemName: "chevron.backward.circle")
.resizable()
.modifier(iconModifier())
})
Spacer()
//Text( "Configurazione Arte Incisa")
BugTitolo(title: "Configurazione Arte Incisa")
Spacer()
}
// pulsante di ritorno e testo titolo-----------------------
Spacer()
HStack{
VStack{
Button(action: {
}, label: {
Text("Account Utente")
.foregroundColor(Color.black)
// ***** THIS LINE DOES NOT GENERATE THE MEMORY OVERFLOW
.frame(width: geom.size.width*0.47, height: btnHeight, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
// ***** IF YOU COMMENT THE PREVIOUS LINE AND UNCOMMENT THIS ONE A MEMORY PROBLEM WILL ARISE
//.frame(width: geom.size.width*btnWidthMultiplier, height: btnHeight, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
// ***** IF YOU COMMENT THE PREVIOUS LINE AND UNCOMMENT THIS ONE THERE WILL BE NO PROBLEM
//.frame(width: GetColumnWitdh(screenwidth: geom.size.width), height: btnHeight, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.contentShape(Rectangle())
})
}
}
}
.navigationBarTitle("", displayMode:.inline)
.navigationBarBackButtonHidden(true)
.navigationBarHidden(true)
.navigationViewStyle(.stack)
}
}
}
}
@available(iOS 15.0, *)
struct BugView_Previews: PreviewProvider {
static var previews: some View {
Group{
NavigationView{
BugView(isPresented: .constant(true))
}
.navigationViewStyle(.stack)
.previewDevice("iPad Pro (9.7-inch)")
.previewInterfaceOrientation(.landscapeLeft)
}
}
}
you will see in this code three .frame commands. if you comment and uncomment these leaving only one active you will see that sourcekitservice will grow exponentially (beware, you could be obliged to restart your Mac by keeping pressed the power button) This behavior is really strange, and based on how you do the multiplication the system became unstable. Does it happen also to other? Could you try to load this in Xcode and test it?