1

I noticed that since iOS15 beta 5 my App crashes when I display two pickers in one list and try to select value from the second one. All works fine in latest iOS14. There is no StackTrace on crash, the app just closes on both simulator and on real device.

Sometimes this appears in the console: === AttributeGraph: cycle detected through attribute 196632 ===

Any idea why?

View to reproduce in latest Xcode 13 RC:

struct ContentView: View {
    @State private var selected1 = 0
    @State private var selected2 = 0
    @State private var showPicker1 = false
    @State private var showPicker2 = false

    var body: some View {
        NavigationView {
            List {
                HStack {
                Text("Picker 1")
                Spacer()
                Text("\(selected1)").foregroundColor(.secondary)
                }
                .onTapGesture {
                    withAnimation {
                    self.showPicker1.toggle()
                    }
                }

                if showPicker1 {
                Picker("", selection: $selected1) {
                    ForEach(1..<5) { idx in
                        Text("\(idx)").tag(idx)
                    }
                }
                .pickerStyle(.wheel)
                .clipped()
                }

                HStack {
                Text("Picker 2")
                Spacer()
                    Text("\(selected2)").foregroundColor(.secondary)
                }
                .onTapGesture {
                    withAnimation {
                    self.showPicker2.toggle()
                    }
                }

                if showPicker2 {
                Picker("", selection: $selected2) {
                    ForEach(1..<15) { idx in
                        Text("\(idx)").tag(idx)
                    }
                }
                .pickerStyle(.wheel)
                .clipped()
                }
            }
            .listStyle(.inset)
            .navigationTitle("Picker")
        }
    }
}
SupaBasti
  • 11
  • 2
  • 1
    I think you found a bug. I can confirm with testing that it does not matter the order. It does have something to do with the conditional nature of showing the blocks. If they both have to be shown, the second picker used, regardless of screen order, will cause the crash. I eliminated all of the modifiers, and started with one or the other shown, and the crash does not occur. If you file a radar, please post the number. If you don't plan to, please let me know and I will. – Yrb Sep 22 '21 at 15:26
  • I have an app with 3 pickers using the same delegate method (but each declared with a delegate seperately). With IOS it detects movement on the picker moving + the picker on the left of it. It does not with IOS 14 and earlier. That means that when I want the color to change on the picker that's being scrolled, color changes on the other pickers as well. – TinaDitte Sep 24 '21 at 06:11

0 Answers0