aptabase / aptabase-swift

Swift SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps
https://aptabase.com
MIT License
21 stars 8 forks source link

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

Open kunalzigma opened 2 months ago

kunalzigma commented 2 months ago

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 commented 2 months ago

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-1001-01-33.4355+0300-60b4e27f86a27790a8803c64c308168f1fafc81d.crash.zip

cristipufu commented 2 months ago

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

cristipufu commented 2 months ago

@kunalzigma

kunalzigma commented 2 months ago

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.