Instabug / Instabug-iOS

In-app feedback and bug reporting tool for apps.
https://instabug.com/
Other
290 stars 67 forks source link

Rare crash on launch: Cannot load NSManagedObjectModel. nil is an illegal URL parameter #484

Closed xmollv closed 6 months ago

xmollv commented 7 months ago

I've been observing a very rare crash on launch triggered by (apparently) Instabug.

Screenshot 2024-02-28 at 13 30 38 Screenshot 2024-02-28 at 13 30 56

The error:

Screenshot 2024-02-28 at 13 29 53

The printed exception in text format:

CoreData: error:  Cannot load NSManagedObjectModel.  nil is an illegal URL parameter

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'CoreData: Cannot load NSManagedObjectModel.  nil is an illegal URL parameter'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000180491128 __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x000000018008412c objc_exception_throw + 56
    2   CoreData                            0x0000000186383c08 -[NSManagedObjectModel(_NSInternalMethods) _initWithContentsOfURL:options:] + 1016
    3   Instabug                            0x0000000107cff974 ibg_total_memory + 13744
    4   Instabug                            0x0000000107cff5bc ibg_total_memory + 12792
    5   Instabug                            0x0000000107cff4e0 ibg_total_memory + 12572
    6   Instabug                            0x0000000107d00f50 ibg_total_memory + 19340
    7   Instabug                            0x0000000107d00cac ibg_total_memory + 18664
    8   libdispatch.dylib                   0x000000010586993c _dispatch_client_callout + 16
    9   libdispatch.dylib                   0x000000010586b3dc _dispatch_once_callout + 84
    10  Instabug                            0x0000000107d00c90 ibg_total_memory + 18636
    11  Instabug                            0x0000000107c71684 ibg_saveLogsToDisk + 441948
    12  Instabug                            0x0000000107c71574 ibg_saveLogsToDisk + 441676
    13  libdispatch.dylib                   0x000000010586993c _dispatch_client_callout + 16
    14  libdispatch.dylib                   0x000000010586b3dc _dispatch_once_callout + 84
    15  Instabug                            0x0000000107c71760 ibg_saveLogsToDisk + 442168
    16  Instabug                            0x0000000107da08f0 ibg_assertion_failure + 191192
    17  Dumps                               0x00000001048fdfa8 $s5Dumps15InstabugManagerCACycfc + 416
    18  Dumps                               0x00000001048fddfc $s5Dumps15InstabugManagerCACycfC + 44
    19  Dumps                               0x00000001048bd008 $s5Dumps11AppDelegateCACycfc + 128
    20  Dumps                               0x00000001048bd0b0 $s5Dumps11AppDelegateCACycfcTo + 20
    21  UIKitCore                           0x00000001852f447c _UIApplicationMainPreparations + 1300
    22  UIKitCore                           0x00000001852f3f48 UIApplicationMain + 104
    23  UIKitCore                           0x00000001847a33a8 __swift_destroy_boxed_opaque_existential_1Tm + 10284
    24  Dumps                               0x00000001048bd170 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 120
    25  Dumps                               0x00000001048bd0e8 $s5Dumps11AppDelegateC5$mainyyFZ + 44
    26  Dumps                               0x00000001048bf230 main + 28
    27  dyld                                0x00000001057e1544 start_sim + 20
    28  ???                                 0x000000010592a0e0 0x0 + 4388462816
    29  ???                                 0x7856000000000000 0x0 + 8671118132548468736
)

Steps to Reproduce the Problem

Expected Behavior

Actual Behavior

Instabug integration code

final class InstabugManager {

  private var isRunningLive: Bool {
    #if targetEnvironment(simulator)
    return false
    #else
    let isRunningTestFlightBeta  = (Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt")
    let hasEmbeddedMobileProvision = Bundle.main.path(forResource: "embedded", ofType: "mobileprovision") != nil
    if (isRunningTestFlightBeta || hasEmbeddedMobileProvision) {
      return false
    } else {
      return true
    }
    #endif
  }

  init() {
    if isRunningLive {
      Instabug.start(withToken: "REMOVED_TOKEN", invocationEvents: [.shake])
    } else {
      Instabug.start(withToken: "REMOVED_TOKEN", invocationEvents: [.shake])
    }
    Instabug.sdkDebugLogsLevel = .none
    Instabug.welcomeMessageMode = .disabled

  }
}

SDK Version

12.7.0

iOS Version

iOS 17.2 and iOS 17.3.1 (that's where I saw it happening)

Device Model

iPhone 15 Pro and Simulator

[Optional] Project That Reproduces the Issue

xmollv commented 7 months ago

I do see this as an 'App Hang' on Instabug's developer portal:

Screenshot 2024-02-28 at 14 03 34 Screenshot 2024-02-28 at 14 03 40

Here's the full crash log as reported on the portal:

data:text/text;charset=utf-8,
# Cause: Hang for more than 5000 milliseconds on app launch
# Reported at: 2024-02-25 04:47:29 UTC

Thread 0 Queue 1: com.apple.main-thread (serial) [Crashed]:

0    libsystem_kernel.dylib                   0x1ded79bf8     __ulock_wait + 8
1    libobjc.A.dylib                          0x18f979900     lookUpImpOrForward + 163
2    libobjc.A.dylib                          0x18f9783b0     class_getInstanceMethod + 63
3    Foundation                               0x1965dccdc     -[NSKeyValueContainerClass initWithOriginalClass:] + 139
4    Foundation                               0x1965dbdcc     _NSKeyValueContainerClassForIsa + 135
5    Foundation                               0x1965da9f4     NSKeyValuePropertyForIsaAndKeyPath + 51
6    Foundation                               0x19663becc     _NSKeyValueCreateImplicitObservationInfo + 195
7    Foundation                               0x19663bd08     -[NSOperation init] + 295
8    Instabug                                 0x105dd5a2c     -[IBGOperation initWithBlock:] + 63
9    Instabug                                 0x105cfec64     -[IBGCacheManager initializationOperation] + 135
10   Instabug                                 0x105eae840     +[Instabug intializeSDKStack] + 179
11   Instabug                                 0x105eae1a8     +[Instabug intializeInstabugWithToken:invocationEvents:] + 751
12   Dumps                                    0x104fb34b8     AppDelegate.init() (AppDelegate.swift:23)
13   Dumps                                    0x104fb3598     @objc AppDelegate.init() (<compiler-generated>:0)
14   UIKitCore                                0x199a711ac     _UIApplicationMainPreparations + 1311
15   UIKitCore                                0x199a70c54     UIApplicationMain + 319
16   UIKitCore                                0x199c9b3d0     __swift_destroy_boxed_opaque_existential_1Tm + 12219
17   Dumps                                    0x104fb3a9c     main (AppDelegate.swift:0)

Thread 1 Queue 130: SQLQueue 0x10780a0e0 for InstabugDataModel (serial):

0    libsystem_kernel.dylib                   0x1ded869b8     ftruncate + 8
1    libsqlite3.dylib                         0x1c0a00ed8     sqlite3_finalize + 15699
2    libsqlite3.dylib                         0x1c0a83760     sqlite3_sourceid + 46091
3    libsqlite3.dylib                         0x1c09ff904     sqlite3_finalize + 10111
4    libsqlite3.dylib                         0x1c09ff170     sqlite3_finalize + 8171
5    libsqlite3.dylib                         0x1c09fdf10     sqlite3_finalize + 3467
6    libsqlite3.dylib                         0x1c0a8558c     sqlite3_sourceid + 53815
7    libsqlite3.dylib                         0x1c09f9d00     sqlite3_exec + 38987
8    libsqlite3.dylib                         0x1c09f9a40     sqlite3_exec + 38283
9    libsqlite3.dylib                         0x1c0a22aac     sqlite3_value_text + 11379
10   libsqlite3.dylib                         0x1c0a08780     sqlite3_log + 28627
11   libsqlite3.dylib                         0x1c0a08304     sqlite3_log + 27479
12   libsqlite3.dylib                         0x1c0aab1ac     sqlite3_sourceid + 208471
13   libsqlite3.dylib                         0x1c0a0337c     sqlite3_log + 7119
14   libsqlite3.dylib                         0x1c09f2b88     sqlite3_exec + 9939
15   libsqlite3.dylib                         0x1c09f1714     sqlite3_exec + 4703
16   libsqlite3.dylib                         0x1c09f0ed8     sqlite3_exec + 2595
17   libsqlite3.dylib                         0x1c09f0a88     sqlite3_exec + 1491
18   CoreData                                 0x19f863ccc     -[NSSQLiteConnection prepareSQLStatement:] + 463
19   CoreData                                 0x19f869030     -[NSSQLiteConnection _hasTableWithName:isTemp:] + 519
20   CoreData                                 0x19f8676f0     -[NSSQLiteConnection connect] + 1735
21   CoreData                                 0x19f88dbb0     __32-[NSSQLCore _loadAndSetMetadata]_block_invoke + 95
22   CoreData                                 0x19f86696c     __37-[NSSQLiteConnection performAndWait:]_block_invoke + 47
23   libdispatch.dylib                        0x19f611300     _dispatch_client_callout + 19
24   libdispatch.dylib                        0x19f6206b4     _dispatch_lane_barrier_sync_invoke_and_complete + 55
25   CoreData                                 0x19f87d02c     -[NSSQLiteConnection performAndWait:] + 175
26   CoreData                                 0x19f8bc544     -[NSSQLCore loadMetadata:] + 335
27   CoreData                                 0x19f879f74     __91-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:]_block_invoke + 2347
28   CoreData                                 0x19f878c2c     gutsOfBlockToNSPersistentStoreCoordinatorPerform + 203
29   libdispatch.dylib                        0x19f611300     _dispatch_client_callout + 19
30   libdispatch.dylib                        0x19f6206b4     _dispatch_lane_barrier_sync_invoke_and_complete + 55
31   CoreData                                 0x19f980d74     _perform + 175
32   CoreData                                 0x19f8bf764     -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 423
33   Instabug                                 0x105e0ceb8     __56-[IBGCoreDataManager initializePersistentStoreInMemory:]_block_invoke + 627
34   libdispatch.dylib                        0x19f60f6a8     _dispatch_call_block_and_release + 31
35   libdispatch.dylib                        0x19f611300     _dispatch_client_callout + 19
36   libdispatch.dylib                        0x19f622dbc     _dispatch_root_queue_drain + 863
37   libdispatch.dylib                        0x19f6233ec     _dispatch_worker_thread2 + 155
38   libsystem_pthread.dylib                  0x20163f928     _pthread_wqthread + 227
39   libsystem_pthread.dylib                  0x20163fa04     start_wqthread + 7

Thread 2 Queue 132: com.IBG.preSavedSnapshotStoreQueue (serial):

0    Instabug                                 0x105d3a55c     -[IBGSurveyInteractionRepo initWithDALService:] + 0
1    Instabug                                 0x105cedc54     -[IBGUserController init] + 103
2    Instabug                                 0x105cede00     __35+[IBGUserController sharedInstance]_block_invoke + 23
3    libdispatch.dylib                        0x19f611300     _dispatch_client_callout + 19
4    libdispatch.dylib                        0x19f612b3c     _dispatch_once_callout + 31
5    Instabug                                 0x105cedde4     +[IBGUserController sharedInstance] + 107
6    Instabug                                 0x105cfbe4c     -[IBGSnapshotManager takePreSendingSnapshotWithConfiguration:preSavedSnapshot:deviceState:sessionId:] + 1063
7    Instabug                                 0x105cfb9e0     -[IBGSnapshotManager takePreSendingSnapshotWithConfiguration:preSavedSnapshot:sessionId:] + 119
8    Instabug                                 0x105cfb930     -[IBGSnapshotManager takePreSendingSnapshotWithConfiguration:] + 95
9    Instabug                                 0x105cda7e0     -[IBGPreSavedSnapshotStore savePreSavedSnapshot] + 87
10   Instabug                                 0x105cd9bc4     __78-[IBGPreSavedSnapshotStore startRecordingPreSendingSnapshotWithConfiguration:]_block_invoke + 143
11   libdispatch.dylib                        0x19f60f6a8     _dispatch_call_block_and_release + 31
12   libdispatch.dylib                        0x19f611300     _dispatch_client_callout + 19
13   libdispatch.dylib                        0x19f618894     _dispatch_lane_serial_drain + 747
14   libdispatch.dylib                        0x19f6193c4     _dispatch_lane_invoke + 379
15   libdispatch.dylib                        0x19f624004     _dispatch_root_queue_drain_deferred_wlh + 287
16   libdispatch.dylib                        0x19f623878     _dispatch_workloop_worker_thread + 403
17   libsystem_pthread.dylib                  0x20163f964     _pthread_wqthread + 287
18   libsystem_pthread.dylib                  0x20163fa04     start_wqthread + 7

Thread 3 Unknown:

0    libsystem_kernel.dylib                   0x1ded816d0     __workq_kernreturn + 8
1    libsystem_pthread.dylib                  0x20163fa04     start_wqthread + 7

Thread 4 Unknown:

0    libsystem_kernel.dylib                   0x1ded816d0     __workq_kernreturn + 8
1    libsystem_pthread.dylib                  0x20163fa04     start_wqthread + 7

Thread 5 Unknown:

0    IBGInvalidFramework                      0x104ee4938     0x104edc000

Thread 6 com.apple.uikit.eventfetch-thread:

0    libsystem_kernel.dylib                   0x1ded79178     mach_msg2_trap + 8
1    libsystem_kernel.dylib                   0x1ded78e28     mach_msg_overwrite + 435
2    libsystem_kernel.dylib                   0x1ded78c68     mach_msg + 23
3    CoreFoundation                           0x19764fb1c     __CFRunLoopServiceMachPort + 159
4    CoreFoundation                           0x19764da14     __CFRunLoopRun + 1207
5    CoreFoundation                           0x19764d478     CFRunLoopRunSpecific + 607
6    Foundation                               0x1965e048c     -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 211
7    Foundation                               0x19660d74c     -[NSRunLoop(NSRunLoop) runUntilDate:] + 63
8    UIKitCore                                0x1999d34a8     -[UIEventFetcher threadMain] + 419
9    Foundation                               0x196663de0     __NSThread__start__ + 731
10   libsystem_pthread.dylib                  0x2016404d4     _pthread_start + 135
11   libsystem_pthread.dylib                  0x20163fa10     thread_start + 7

Thread 7 Unknown:

0    libsystem_kernel.dylib                   0x1ded79178     mach_msg2_trap + 8
1    libsystem_kernel.dylib                   0x1ded78e28     mach_msg_overwrite + 435
2    libsystem_kernel.dylib                   0x1ded78c68     mach_msg + 23
3    Instabug                                 0x1060369d4     exception_server_thread + 187
4    libsystem_pthread.dylib                  0x2016404d4     _pthread_start + 135
5    libsystem_pthread.dylib                  0x20163fa10     thread_start + 7

Binary Images:

0x1ded78000     libsystem_kernel.dylib                       arm64e     55F2CC41-2488-37BD-BB95-EA2FFD7611AE 
0x18f970000     libobjc.A.dylib                              arm64e     98C1E5B8-C56E-3B9C-9783-B0FEF8F999EE 
0x1965b4000     Foundation                                   arm64e     C52A9630-60F1-3D48-A6C3-50A20DE78C6A 
0x105c9c000     Instabug                                     arm64e     F0C62716-2709-3A78-86DA-3A187B8F7020 
0x104f28000     Dumps                                        arm64e     40A4C037-F560-3F78-8AFC-2BD06376290C 
0x199845000     UIKitCore                                    arm64e     99AD2A31-9360-369F-9C0B-A7A0AF33E2E7 
0x1c09e8000     libsqlite3.dylib                             arm64e     9275A6EC-A2AD-33A7-A94F-6D528FD9F9FB 
0x19f827000     CoreData                                     arm64e     906D68F4-4D51-3C8D-8ED3-20C2086555F3 
0x19f60d000     libdispatch.dylib                            arm64e     D023C07E-DCBD-3728-8E6F-5DDC6D3BEE25 
0x20163e000     libsystem_pthread.dylib                      arm64e     E9AE8DCF-C2B6-35D7-AF24-E008B8034E31 
0x104edc000     IBGInvalidFramework                          arm64e     9D5E9F49-7546-4736-A63D-F3C6F643B984 
0x19761a000     CoreFoundation                               arm64e     BE405D8A-5464-37A3-A17E-1068DB404B23 
stale[bot] commented 6 months ago

This issue has been automatically marked as stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions.

ahmedsalah196 commented 6 months ago

Hello @xmollv, Can you please reach out to support@instabug.com?

xmollv commented 6 months ago

Hello @xmollv, Can you please reach out to support@instabug.com?

@ahmedsalah196 sure I can, what should I ask though? Or just point them to this GitHub issue?

ahmedsalah196 commented 6 months ago

@ahmedsalah196 sure I can, what should I ask though? Or just point them to this GitHub issue?

@xmollv Yes 🙏

xmollv commented 6 months ago

@ahmedsalah196 sure I can, what should I ask though? Or just point them to this GitHub issue?

@xmollv Yes 🙏

Done! ✅

xmollv commented 6 months ago

@ahmedsalah196 When chatting with your support team, I realized that this issue stopped happening a month or so ago (maybe an unrelated code change fixed this?), so we've decided that it's best to close this ticket for now.

While checking that, I've found other hangs that seem also caused by the instantiation of Instabug, I'll open other tickets for those later this week!