SwiftUI runtime crash ONLY IN IOS15 when using compositional layout with a uiviewrepresentable of collectionview

Viewed 366

Getting a runtime crash when removing uiviewrepresentable of a collection view using compositional layout and a diffable data source from the screen. The view is currently in an if statement, if no data is found it uses a empty data view instead of showing the collection.

if collectionViewModel.showEmptyDataView{
        EmptyDataSetViewWithBuilder(title: collectionViewModel.errorDataTilte, description: collectionViewModel.errorDataDescription, image: Constants.EmptyDataSetImages.errorIcon, addButton: false, cartStyle: Themes.CartViewTheme) {
  //ViewBuilder
        }
      }else{
        HomeScreenCollectionView(ShopViewModel: collectionViewModel) { itemClicked in
//handle item clicked
        }
      }

The quick fix I found was to remove the if statements and use an opacity modifier instead.

       EmptyDataSetViewWithBuilder(title: collectionViewModel.errorDataTilte, description: collectionViewModel.errorDataDescription, image: Constants.EmptyDataSetImages.errorIcon, addButton: false, cartStyle: Themes.CartViewTheme) {
  //ViewBuilder
        }.opacity(collectionViewModel.showEmptyDataView ? 1 : 0).zIndex(collectionViewModel.showEmptyDataView ? 1 : 0)

        HomeScreenCollectionView(ShopViewModel: collectionViewModel) { itemClicked in
//handle item clicked
        }.opacity(!collectionViewModel.showEmptyDataView ? 1 : 0).zIndex(!collectionViewModel.showEmptyDataView ? 1 : 0)

This only occurs in IOS 15, I am also seeing this log within console [UICollectionViewRecursion] cv == 0x106131c00 Disabling recursion trigger logging i haven't seen this log in previous OS's. Another thing i noticed was this runtime crash occurs more often on the release build configuration. Really like compositional layouts and diffable data source so id to continue to use this throughout ios 15. But would like to make sure that this bug doesn't keep occurring. It crashes the app especially in test flight/ appstore

The crash report is saying its crashing on _AppearanceActionModifier.MergedBox.disappear+ 3049112

Heres full crash report:

Hardware Model:      iPhone13,4
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]

Date/Time:           2021-10-12 17:48:13.6141 -0400
Launch Time:         2021-10-12 17:48:13.2125 -0400
OS Version:          iPhone OS 15.0.1 (19A348)
Release Type:        User
Baseband Version:    2.09.10
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000018923f698
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL; [5]
Terminating Process: exc handler [7627]

Terminating Process: exc handler [7627]
Triggered by Thread:  0

Thread 0 name:   Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   SwiftUI                                0x18923f698 _AppearanceActionModifier.MergedBox.disappear+ 3049112 () + 28
1   SwiftUI                                0x1894f9ea4 implicit closure #4 in implicit closure #3 in _AppearanceActionModifier.MergedCallbacks.value.getter + 24
2   SwiftUI                                0x189068720 thunk for @escaping @callee_guaranteed () -> + 1120032 () + 28
3   SwiftUI                                0x188f8e8fc thunk for @escaping @callee_guaranteed () -> (@out + 227580 ()) + 28
4   SwiftUI                                0x189068720 thunk for @escaping @callee_guaranteed () -> + 1120032 () + 28
5   SwiftUI                                0x188f6ce68 closure #1 in ViewRendererHost.render+ 89704 (interval:updateDisplayList:) + 2596
6   SwiftUI                                0x189033f78 ViewRendererHost.render+ 905080 (interval:updateDisplayList:) + 336
7   SwiftUI                                0x188f7fe18 _UIHostingView.layoutSubviews+ 167448 () + 312
8   SwiftUI                                0x188f83b24 @objc _UIHostingView.layoutSubviews+ 183076 () + 28
9   UIKitCore                              0x183b5ecc8 -[UIView+ 1629384 (CALayerDelegate) layoutSublayersOfLayer:] + 2620
10  QuartzCore                             0x1852b8280 CA::Layer::layout_if_needed+ 258688 (CA::Transaction*) + 536
11  QuartzCore                             0x1852aaaa8 CA::Layer::layout_and_display_if_needed+ 203432 (CA::Transaction*) + 144
12  QuartzCore                             0x1852bf0b0 CA::Context::commit_transaction+ 286896 (CA::Transaction*, double, double*) + 500
13  QuartzCore                             0x1852c8174 CA::Transaction::commit+ 323956 () + 680
14  QuartzCore                             0x1852aa210 CA::Transaction::flush_as_runloop_observer+ 201232 (bool) + 88
15  UIKitCore                              0x183f15c28 _UIApplicationFlushCATransaction + 76
16  UIKitCore                              0x1841afad8 _UIUpdateSequenceRun + 84
17  UIKitCore                              0x184827294 schedulerStepScheduledMainSection + 144
18  UIKitCore                              0x184826760 runloopSourceCallback + 60
19  CoreFoundation                         0x1815e2030 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
20  CoreFoundation                         0x1815f2cf0 __CFRunLoopDoSource0 + 208
21  CoreFoundation                         0x18152cff8 __CFRunLoopDoSources0 + 268
22  CoreFoundation                         0x181532804 __CFRunLoopRun + 820
23  CoreFoundation                         0x1815463c8 CFRunLoopRunSpecific + 600
24  GraphicsServices                       0x19cd5738c GSEventRunModal + 164
25  UIKitCore                              0x183eec0bc -[UIApplication _run] + 1100
26  UIKitCore                              0x183c69be8 UIApplicationMain + 2124
27  SwiftUI                                0x189195d90 closure #1 in KitRendererCommon+ 2354576 (_:) + 164
28  SwiftUI                                0x1890c2ebc runApp<A>+ 1490620 (_:) + 252
29  SwiftUI                                0x1890a4278 static App.main+ 1364600 () + 128
30   Development                       0x102bddb90 main + 23440 (<compiler-generated>:0)
31  dyld                                   0x1060eda24 start + 520

Thread 1:
0   libsystem_pthread.dylib                0x1f19fcf48 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib                0x1f19fcf48 start_wqthread + 0

Thread 3:
0   libsystem_pthread.dylib                0x1f19fcf48 start_wqthread + 0

Thread 4:
0   libsystem_pthread.dylib                0x1f19fcf48 start_wqthread + 0

Thread 5 name:  com.apple.uikit.eventfetch-thread
Thread 5:
0   libsystem_kernel.dylib                 0x1b800a564 mach_msg_trap + 8
1   libsystem_kernel.dylib                 0x1b800abfc mach_msg + 76
2   CoreFoundation                         0x18152e698 __CFRunLoopServiceMachPort + 372
3   CoreFoundation                         0x18153298c __CFRunLoopRun + 1212
4   CoreFoundation                         0x1815463c8 CFRunLoopRunSpecific + 600
5   Foundation                             0x182d69d54 -[NSRunLoop+ 101716 (NSRunLoop) runMode:beforeDate:] + 236
6   Foundation                             0x182dab6a8 -[NSRunLoop+ 370344 (NSRunLoop) runUntilDate:] + 92
7   UIKitCore                              0x183e6507c -[UIEventFetcher threadMain] + 524
8   Foundation                             0x182db995c __NSThread__start__ + 792
9   libsystem_pthread.dylib                0x1f19fda60 _pthread_start + 148
10  libsystem_pthread.dylib                0x1f19fcf5c thread_start + 8

Thread 6:
0   libsystem_pthread.dylib                0x1f19fcf48 start_wqthread + 0

Thread 7:
0   libsystem_pthread.dylib                0x1f19fcf48 start_wqthread + 0

Thread 8 name:  com.google.firebase.crashlytics.MachExceptionServer
Thread 8:
0   libsystem_kernel.dylib                 0x1b800bf78 write + 8
1   Development                        0x10333156c FIRCLSSDKFileLog + 7705964 (FIRCLSInternalLogging.c:63)
2   Development                        0x10332cbc8 FIRCLSMachExceptionReply + 7687112 (FIRCLSMachException.c:267)
3  Development                         0x10332c6cc FIRCLSMachExceptionServer + 7685836 (FIRCLSMachException.c:178)
4   libsystem_pthread.dylib                0x1f19fda60 _pthread_start + 148
5   libsystem_pthread.dylib                0x1f19fcf5c thread_start + 8

Thread 9:
0   libsystem_pthread.dylib                0x1f19fcf48 start_wqthread + 0

Thread 10 name:  com.apple.NSURLConnectionLoader
Thread 10:
0   libsystem_kernel.dylib                 0x1b800a564 mach_msg_trap + 8
1   libsystem_kernel.dylib                 0x1b800abfc mach_msg + 76
2   CoreFoundation                         0x18152e698 __CFRunLoopServiceMachPort + 372
3   CoreFoundation                         0x18153298c __CFRunLoopRun + 1212
4   CoreFoundation                         0x1815463c8 CFRunLoopRunSpecific + 600
5   CFNetwork                              0x181fb78d0 0x181d3d000 + 2599120
6   Foundation                             0x182db995c __NSThread__start__ + 792
7   libsystem_pthread.dylib                0x1f19fda60 _pthread_start + 148
8   libsystem_pthread.dylib                0x1f19fcf5c thread_start + 8

Thread 11:
0   libsystem_kernel.dylib                 0x1b800a564 mach_msg_trap + 8
1   libsystem_kernel.dylib                 0x1b800abfc mach_msg + 76
2   CoreFoundation                         0x18152e698 __CFRunLoopServiceMachPort + 372
3   CoreFoundation                         0x18153298c __CFRunLoopRun + 1212
4   CoreFoundation                         0x1815463c8 CFRunLoopRunSpecific + 600
5   Foundation                             0x182d69d54 -[NSRunLoop+ 101716 (NSRunLoop) runMode:beforeDate:] + 236
6   Foundation                             0x182d6a510 -[NSRunLoop+ 103696 (NSRunLoop) run] + 92
7   SwiftUI                                0x189014f84 static DisplayLink.asyncThread+ 778116 (arg:) + 836
8   SwiftUI                                0x189012b70 @objc static DisplayLink.asyncThread+ 768880 (arg:) + 100
9   Foundation                             0x182db995c __NSThread__start__ + 792
10  libsystem_pthread.dylib                0x1f19fda60 _pthread_start + 148
11  libsystem_pthread.dylib                0x1f19fcf5c thread_start + 8


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000280b49780   x1: 0x0000000280b49780   x2: 0x0000000000000001   x3: 0x00000001930ae4f4
    x4: 0x00000000000002e0   x5: 0x00000001063ba020   x6: 0x000000000000005e   x7: 0x0000000000000005
    x8: 0x00000000ffffffff   x9: 0x0000000281e6eb80  x10: 0x0000000000000003  x11: 0x0000000200000003
   x12: 0x0000000000000003  x13: 0x000000003a204827  x14: 0x000000003a405000  x15: 0x0000000000005000
   x16: 0x000000003a400000  x17: 0x0000000000000f08  x18: 0x0000000114a31600  x19: 0x0000000000000007
   x20: 0x0000000280b49780  x21: 0x0000000106219aa8  x22: 0x00000001894fa77c  x23: 0x0000000000000002
   x24: 0x00000001db34e000  x25: 0x00000001db9758d8  x26: 0x00000001db34e000  x27: 0x0000000106219a50
   x28: 0x0000000281e6c140   fp: 0x000000016d223790   lr: 0x00000001894f9ea4
    sp: 0x000000016d223780   pc: 0x000000018923f698 cpsr: 0x80000000
   far: 0x000000011c084000  esr: 0xf2000001 (Breakpoint) brk 1

Binary Images:
       0x188f57000 -        0x189f77fff SwiftUI arm64e  <6d99bb3b20803dbbaecf604b49eb822d> /System/Library/Frameworks/SwiftUI.framework/SwiftUI
       0x1839d1000 -        0x185253fff UIKitCore arm64e  <0e2d8679d5f13c0390107f6ce3662789> /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
       0x185279000 -        0x18555cfff QuartzCore arm64e  <8ab30eebfb1536cb9c27918ed68500ee> /System/Library/Frameworks/QuartzCore.framework/QuartzCore
       0x181527000 -        0x18197afff CoreFoundation arm64e  <6174789ae88c3f5cba39de2e9edc0750> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
       0x19cd56000 -        0x19cd5efff GraphicsServices arm64e  <0f7424f6bde5311aa3fac0e0c4c28d72> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
       0x102bd8000 -        0x103983fff Development arm64  <d40c6dc01ef5385687bfe7476ba7240f> /private/var/containers/Bundle/Application/4F3744A5-3BEF-472F-8674-AF6F0414AE5F/Development.app/Development
       0x1060d4000 -        0x10612bfff dyld arm64e  <d48c31ee061f370ba6f78391a1b53ed8> /usr/lib/dyld
       0x1f19fc000 -        0x1f1a07fff libsystem_pthread.dylib arm64e  <bc1ce0c6a9f2396b9afb623d3acd5881> /usr/lib/system/libsystem_pthread.dylib
       0x1b8009000 -        0x1b803cfff libsystem_kernel.dylib arm64e  <d2476f74d204348d8d386165d0485c7c> /usr/lib/system/libsystem_kernel.dylib
       0x182d51000 -        0x183055fff Foundation arm64e  <efbca2ff8b8c3227abbc154ba851d23c> /System/Library/Frameworks/Foundation.framework/Foundation
       0x181d3d000 -        0x182201fff CFNetwork arm64e  <570aad29ce5c3cd9ab01ad21e1440ddb> /System/Library/Frameworks/CFNetwork.framework/CFNetwork

EOF

Let me know if there is anymore info i can provide to help solve this problem.

0 Answers
Related