SwiftUI App Crashing on Device iOS 16.1 and on rest of the devices its working fine.

iPad 8th (iOS 16.1) Xcode 14.1 MacBookPro M2 (MacOS 12.5)

Implemented the ability to turn the overlay on/off outside the view.

Within the overlay, the picker view is displayed (View the list in ForEach).

When tested with iOS16.1, a crash occurs (iOS14, 15, Simulation do not crash).

  1. Execute Project
  2. Click "OVERLAY ON OFF BUTTON" to display the overlay when the app is launched
  3. Click "OVERLAY ON OFF BUTTON" to hide it
  4. Repeat items 2 and 3 quickly

Link to Download Project https://drive.google.com/file/d/1QtYavcsf2B-NmFBMil7DfYe9jtaUerv_/view?usp=share_link

Code:

import SwiftUI

struct ContentView: View {
  @State var isExpanded: Bool = false
  @State var selected: Int = 0
   
  var body: some View {
    VStack {
      Button("OVERLAY ON OFF BUTTON",action: {
        isExpanded.toggle()
      })
      .overlay(selectCameraSizeView(), alignment: .topLeading)
    }
  }
   
  func selectCameraSizeView() -> some View {
    VStack {
      if isExpanded {
        Spacer(minLength: 45)
        Picker(selection: $selected, label: EmptyView()) {
          ForEach(0 ..< 15) { index in
            Text("Picker Test" + "\(index)")
          }
        }
        .pickerStyle(.wheel)
        .scaledToFill()
      }
    }
  }
}
CrashReporter Key:   bf55dbc5c1181437195c3d73992de7242326f630
Hardware Model:      iPad11,6
Process:             test [552]
Path:                /private/var/containers/Bundle/Application/E4707D28-D4CA-43C6-AAD0-B529101F1F67/test.app/test
Identifier:          com.ydh.t1.test
Version:             1.0 (1)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.ydh.t1.test [462]

Date/Time:           2022-11-24 11:24:09.9006 +0900
Launch Time:         2022-11-24 11:24:08.6685 +0900
OS Version:          iPhone OS 16.1 (20B82)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000189199ac4
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [552]

Triggered by Thread:  0

Kernel Triage:
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage


Thread 0 name:   Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libswiftCore.dylib                       0x189199ac4 closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 360
1   libswiftCore.dylib                       0x189199ac4 closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 360
2   libswiftCore.dylib                       0x189199828 closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 196
3   libswiftCore.dylib                       0x189199630 closure #1 in _assertionFailure(_:_:file:line:flags:) + 208
4   libswiftCore.dylib                       0x189199188 _assertionFailure(_:_:file:line:flags:) + 232
5   libswiftCore.dylib                       0x189174584 _ArrayBuffer._checkInoutAndNativeTypeCheckedBounds(_:wasNativeTypeChecked:) + 280
6   libswiftCore.dylib                       0x18917be58 Array.subscript.read + 180
7   libswiftCore.dylib                       0x18917bd74 protocol witness for Collection.subscript.read in conformance [A] + 68
8   SwiftUI                                  0x193fcb4a4 0x192c33000 + 20546724
9   SwiftUI                                  0x193fcbb58 0x192c33000 + 20548440
10  UIKitCore                                0x19150791c -[UIPickerView tableView:cellForRowAtIndexPath:] + 392
11  UIKitCore                                0x1915a2dd0 -[UIPickerColumnView tableView:cellForRowAtIndexPath:] + 136
12  UIKitCore                                0x1915a0eec -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 1256
13  UIKitCore                                0x191574844 -[UITableView _updateVisibleCellsForRanges:createIfNecessary:] + 596
14  UIKitCore                                0x1914ae350 -[UITableView _updateVisibleCellsNow:] + 1088
15  UIKitCore                                0x1914ade44 -[UITableView layoutSubviews] + 148
16  UIKitCore                                0x1914788c8 __35-[UIPickerTableView layoutSubviews]_block_invoke + 88
17  UIKitCore                                0x191486564 +[UIView(Animation) performWithoutAnimation:] + 76
18  UIKitCore                                0x19145f24c -[UIPickerTableView layoutSubviews] + 108
19  UIKitCore                                0x19145a020 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1980
20  QuartzCore                               0x19092f9ec CA::Layer::layout_if_needed(CA::Transaction*) + 500
21  QuartzCore                               0x1909430a0 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 148
22  QuartzCore                               0x1909545b0 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 456
23  QuartzCore                               0x1909895ec CA::Transaction::commit() + 652
24  QuartzCore                               0x1909728cc CA::Transaction::flush_as_runloop_

NAME AND APPLE ID OF APP
SwiftUI App Crashing on Device iOS 16.1 and on rest of the devices its working fine.
 
 
Q