aptabase-swift icon indicating copy to clipboard operation
aptabase-swift copied to clipboard

closure #1 in AptabaseClient.stopPolling() + 1 (AptabaseClient.swift:64)

Open kunalzigma opened this issue 1 year ago • 5 comments

Am seeing one crash after adding this sdk after 4-5 days in my app running on user's device, after ~3k sessions

Thread 3:
0   libsystem_pthread.dylib       	0x00000001f66040c4 start_wqthread + 0 (:-1)

Thread 4 Crashed:
0   libswiftCore.dylib            	0x00000001983ff354 _swift_release_dealloc + 32 (HeapObject.cpp:832)
1   libswiftCore.dylib            	0x0000000198400488 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136 (RefCount.h:0)
2   MyApp                       	0x0000000100986c88 destroy for Event + 68 (<compiler-generated>:0)
3   libswiftCore.dylib            	0x00000001983e493c swift_arrayDestroy + 196 (Array.cpp:223)
4   libswiftCore.dylib            	0x00000001980f09f4 _ContiguousArrayStorage.__deallocating_deinit + 96 (ContiguousArrayBuffer.swift:81)
5   libswiftCore.dylib            	0x00000001983ff36c _swift_release_dealloc + 56 (HeapObject.cpp:832)
6   libswiftCore.dylib            	0x0000000198400488 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136 (RefCount.h:0)
7   MyApp                                0x0000000100985530 EventDispatcher.flush() + 52 (<compiler-generated>:0)
8   MyApp                                0x0000000100981c71 closure #1 in AptabaseClient.stopPolling() + 1 (AptabaseClient.swift:64)
9   MyApp                                0x0000000100982395 partial apply for closure #1 in AptabaseClient.stopPolling() + 1 (<compiler-generated>:0)
10  MyApp                                0x0000000100982241 specialized thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out A) + 1 (<compiler-generated>:0)
11  MyApp                                0x000000010098245d thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out A)specialized partial apply + 1 (<compiler-generated>:0)
12  libswift_Concurrency.dylib    	0x00000001a4afa775 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1 (Task.cpp:463)

kunalzigma avatar Jul 11 '24 04:07 kunalzigma

Attaching the crash report. Very strange as the crash report is not telling if this crash is foreground or background. and am calling events in applicationDidEnterBackground and applicationWillEnterForeground. This happens after like 11k such events. 2024-07-10_01-01-33.4355_+0300-60b4e27f86a27790a8803c64c308168f1fafc81d.crash.zip

kunalzigma avatar Jul 11 '24 05:07 kunalzigma

@Claeysson @dalenjohnson any hints into why would this be happening?

cristipufu avatar Jul 11 '24 07:07 cristipufu

@kunalzigma

  • which library version are you using?
  • are you manually calling flush()?

cristipufu avatar Jul 11 '24 12:07 cristipufu

  • 0.3.9
  • no. only Aptabase.shared.trackEvent("eventnames") and Aptabase.shared.initialize(appKey: "appkey"). nothing else.

Aptabase.shared.initialize(appKey: "appkey") in didFinishLaunchingWithOptions in AppDelegate

Aptabase.shared.trackEvent("eventnames") in applicationDidEnterBackground and applicationWillEnterForeground to track if users have minimized the app and come back or not.

kunalzigma avatar Jul 11 '24 12:07 kunalzigma

Same here. We recently rolled out Aptabase in a macOS app and now started to see crashes with stack traces along the lines of this:

Thread 10 Crashed:: tid_1a037
0   RoyalTSXNativeUI              	       0x10bb8c740 specialized closure #1 in ConcurrentQueue.dequeue(count:) + 576
1   RoyalTSXNativeUI              	       0x10b82b248 partial apply for thunk for @callee_guaranteed (@guaranteed NSDraggingItem, @unowned Int, @unowned UnsafeMutablePointer<ObjCBool>) -> () + 20
2   RoyalTSXNativeUI              	       0x10b82b268 thunk for @escaping @callee_guaranteed () -> () + 20
3   libdispatch.dylib             	       0x1983b0658 _dispatch_client_callout + 20
4   libdispatch.dylib             	       0x1983c0308 _dispatch_sync_invoke_and_complete + 56
5   RoyalTSXNativeUI              	       0x10bb8dee8 EventDispatcher.flush() + 1056
6   RoyalTSXNativeUI              	       0x10bb8a979 closure #1 in AptabaseClient.stopPolling() + 1
7   RoyalTSXNativeUI              	       0x10bb8a345 partial apply for specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1
8   RoyalTSXNativeUI              	       0x10bb89025 specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1
9   RoyalTSXNativeUI              	       0x10bb8a4c1 partial apply for closure #1 in Aptabase.flush() + 1
10  libswift_Concurrency.dylib    	       0x2730a5035 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1

Note that this happens NOT on the main thread.

lemonmojo avatar Feb 04 '25 08:02 lemonmojo