Modal with topBar title component crashes app when dismissed (iOS debug build)

🐛 Bug Report

If a modal has a custom title component, the app crashes when the modal is dismissed. I’m only seeing this crash so far in debug builds, not release builds.

stack trace:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x00007fff2017689f libobjc.A.dylib`object_isClass + 8
    frame #1: 0x00007fff207c2844 Foundation`KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED + 50
    frame #2: 0x00007fff207be9b3 Foundation`NSKeyValueWillChangeWithPerThreadPendingNotifications + 240
    frame #3: 0x00007fff27b1d8c9 QuartzCore`CA::Layer::begin_change(CA::Transaction*, unsigned int, objc_object*, objc_object*&) + 211
    frame #4: 0x00007fff27b25857 QuartzCore`CA::Layer::remove_sublayer(CA::Transaction*, CALayer*) + 85
    frame #5: 0x00007fff27b261b6 QuartzCore`CA::Layer::remove_from_superlayer() + 134
    frame #6: 0x00007fff24bdfc1b UIKitCore`-[UIView(Hierarchy) removeFromSuperview] + 142
    frame #7: 0x00007fff24bc764f UIKitCore`-[UIView dealloc] + 446
  * frame #8: 0x000000010fe208e3 playground`-[RCTView dealloc](self=0x00007f9aed65ee00, _cmd="dealloc") at RCTView.m:968:1
    frame #9: 0x00007fff20321ea0 CoreFoundation`__RELEASE_OBJECTS_IN_THE_ARRAY__ + 119
    frame #10: 0x00007fff20321de2 CoreFoundation`-[__NSArrayM dealloc] + 278
    frame #11: 0x00007fff2018f834 libobjc.A.dylib`objc_object::sidetable_release(bool, bool) + 174
    frame #12: 0x00007fff2019101b libobjc.A.dylib`AutoreleasePoolPage::releaseUntil(objc_object**) + 175
    frame #13: 0x00007fff20190f0a libobjc.A.dylib`objc_autoreleasePoolPop + 185
    frame #14: 0x00007fff20430a07 CoreFoundation`_CFAutoreleasePoolPop + 22
    frame #15: 0x00007fff2038f223 CoreFoundation`__CFRunLoopPerCalloutARPEnd + 41
    frame #16: 0x00007fff2038a677 CoreFoundation`__CFRunLoopRun + 2742
    frame #17: 0x00007fff203896d6 CoreFoundation`CFRunLoopRunSpecific + 567
    frame #18: 0x00007fff2c257db3 GraphicsServices`GSEventRunModal + 139
    frame #19: 0x00007fff24696cf7 UIKitCore`-[UIApplication _run] + 912
    frame #20: 0x00007fff2469bba8 UIKitCore`UIApplicationMain + 101
    frame #21: 0x000000010fba4a8f playground`main(argc=1, argv=0x00007ffee005f258) at main.m:27:20
    frame #22: 0x00007fff2025a3e9 libdyld.dylib`start + 1
    frame #23: 0x00007fff2025a3e9 libdyld.dylib`start + 1

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Configure a modal with topBar.title.component
  2. Call showModal()
  3. Call dismissModal()

Expected behavior

App should not crash

Actual Behavior

App crashes

Your Environment

  • React Native Navigation version: 7.11.2
  • React Native version: 0.63.2
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): iOS Simulator, iOS 14.4, debug build

Reproducible Demo

demo in playground app: brsaylor2@7043503

  1. Go to Navigation tab
  2. Tap “Modal”
  3. Dismiss modal

1 possible answer(s) on “Modal with topBar title component crashes app when dismissed (iOS debug build)