superwall / Superwall-iOS

Remotely configure every aspect of your paywall and double your revenue.
https://superwall.com
MIT License
89 stars 24 forks source link

[BUG] Crash in StoreKitManager:90 #105

Closed quanganhdo closed 1 year ago

quanganhdo commented 1 year ago

New issue checklist

General information

Describe the bug

When the app launches, sometimes it will crash at StoreKitManager.swift - line 90

Thread 6: "-[_NSCoreDataTaggedObjectID count]: unrecognized selector sent to instance 0x8000000000000000"

Steps to reproduce

Please also include a description of expected vs. actual behaviour

Other Information

e.g. stacktraces, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.

yusuftor commented 1 year ago

This error message is usually due to race conditions between threads but haven’t come across this one yet. I also haven't been able to reproduce this. Do you have any more info in terms of stack trace and how you’re configuring the app?

quanganhdo commented 1 year ago

I set up the library inside scene:willConnectTo:options with Superwall.configure method. After doing some preps, I run Superwall.shared.logIn and Superwall.shared.setUserAttributes. Finally the paywall is triggered manually via Superwall.shared.track.

The crash happens frequently at launch. I'll try to get a stack trace and post back when I have one.

yusuftor commented 1 year ago

Thanks for the extra context. Do you run any of these operations on a background thread? I have tried to produce a fix for this but will be good if I can get it to reproduce.

yusuftor commented 1 year ago

By the way, you should be calling Superwall.configure in application(:_didFinishLaunchingWithOptions:), not in the scene delegate method.

quanganhdo commented 1 year ago

Thanks for the replies.

By the way, you should be calling Superwall.configure in application(:_didFinishLaunchingWithOptions:), not in the scene delegate method.

Good point. I'd move this to the AppDelegate.

Do you run any of these operations on a background thread?

I've made sure they are on the main thread with precondition(Thread.isMainThread)

yusuftor commented 1 year ago

Okay, one more thing is if you can get it to crash, can you try it on the develop thread. I believe that has a fix so I’d be interested to know if this still occurs on that branch

quanganhdo commented 1 year ago

After I moved the init code to AppDelegate, it seems to happen much less often. Had one crash today; I'd try the fix on develop.

Thread 0 - (TH_STATE_WAITING)
0  libsystem_kernel.dylib +0xda4   _mach_msg2_trap
1  libsystem_kernel.dylib +0x13a18 _mach_msg2_internal
2  libsystem_kernel.dylib +0x13c58 _mach_msg_overwrite
3  libsystem_kernel.dylib +0x12e8  _mach_msg
4  CoreFoundation +0x7aac0         ___CFRunLoopServiceMachPort
5  CoreFoundation +0x7bd04         ___CFRunLoopRun
6  CoreFoundation +0x80eac         _CFRunLoopRunSpecific
7  GraphicsServices +0x1364        _GSEventRunModal
8  UIKitCore +0x3a1664             -[UIApplication _run]
9  UIKitCore +0x3a12c8             _UIApplicationMain
10 libswiftUIKit.dylib +0x35304    UIApplicationMain(_:_:_:_:)
11 App +0x1636b8             static UIApplicationDelegate.main()
12 App +0x163640             static AppDelegate.$main()
13 App +0x1645f4             main
14 dyld +0x1595c                   start

Thread 1 - (TH_STATE_RUNNING)
0  CoreFoundation +0x83dc0        ___CFStringHash
1  CoreFoundation +0x16140        -[__NSDictionaryM __setObject:forKey:]
2  CoreFoundation +0x140e0        -[__NSFrozenDictionaryM __apply:context:]
3  CoreFoundation +0x5af64        ____CFPrefsDeliverPendingKVONotificationsGuts_block_invoke
4  CoreFoundation +0x5e310        ___CFDictionaryApplyFunction_block_invoke
5  CoreFoundation +0x862ec        _CFBasicHashApply
6  CoreFoundation +0x86f1c        _CFDictionaryApplyFunction
7  CoreFoundation +0x2cfa0        __CFPrefsDeliverPendingKVONotificationsGuts
8  CoreFoundation +0x85328        -[_CFXPreferences _deliverPendingKVONotifications]
9  CoreFoundation +0x45794        -[_CFXPreferences withNamedVolatileSourceForIdentifier:perform:]
10 CoreFoundation +0xf96cc        ___41-[_CFXPreferences registerDefaultValues:]_block_invoke
11 CoreFoundation +0x3b0dc        _withKeysAndValues
12 CoreFoundation +0x2b5bc        -[_CFXPreferences registerDefaultValues:]
13 CoreFoundation +0x2b50c        __CFXPreferencesRegisterDefaultValues
14 Metal +0x2e3c0                 ____ZL15initWrapperTypev_block_invoke
15 libdispatch.dylib +0x3f84      __dispatch_client_callout
16 libdispatch.dylib +0x57d0      __dispatch_once_callout
17 Metal +0x20130                 ____ZL24MTLDeviceArrayInitializev_block_invoke
18 libdispatch.dylib +0x3f84      __dispatch_client_callout
19 libdispatch.dylib +0x57d0      __dispatch_once_callout
20 Metal +0x23674                 _MTLCreateSystemDefaultDevice
21 PencilKit +0x144080            +[PKMetalUtility defaultDevice]
22 PencilKit +0x65b7c             +[PKTiledCanvasView prewarmFutureCanvasesIfNecessarySecureRendering:prewarmSharedResourceHandler:]
23 PencilKit +0x12394c            +[PKTextInputCanvasController prewarmFutureCanvasesIfNecessarySecureRendering:]
24 PencilKit +0x9a4b0             ___40-[PKTextInputInteraction didMoveToView:]_block_invoke.28
25 libdispatch.dylib +0x245c      __dispatch_call_block_and_release
26 libdispatch.dylib +0x3f84      __dispatch_client_callout
27 libdispatch.dylib +0x15b88     __dispatch_root_queue_drain
28 libdispatch.dylib +0x16280     __dispatch_worker_thread2
29 libsystem_pthread.dylib +0xdb8 __pthread_wqthread

Thread 2 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x12ac ___workq_kernreturn
1 libsystem_pthread.dylib +0xe40 __pthread_wqthread

Thread 3 - (TH_STATE_WAITING)
0 libsystem_pthread.dylib +0xb8c _start_wqthread

Thread 4 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x12ac ___workq_kernreturn
1 libsystem_pthread.dylib +0xe40 __pthread_wqthread

Thread 5 - (TH_STATE_WAITING)
0  libsystem_kernel.dylib +0xda4   _mach_msg2_trap
1  libsystem_kernel.dylib +0x13a18 _mach_msg2_internal
2  libsystem_kernel.dylib +0x13c58 _mach_msg_overwrite
3  libsystem_kernel.dylib +0x12e8  _mach_msg
4  CoreFoundation +0x7aac0         ___CFRunLoopServiceMachPort
5  CoreFoundation +0x7bd04         ___CFRunLoopRun
6  CoreFoundation +0x80eac         _CFRunLoopRunSpecific
7  Foundation +0x42050             -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
8  Foundation +0x41f38             -[NSRunLoop(NSRunLoop) runUntilDate:]
9  UIKitCore +0x4d66a0             -[UIEventFetcher threadMain]
10 Foundation +0x5b514             ___NSThread__start__
11 libsystem_pthread.dylib +0x16c8 __pthread_start

Thread 6 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x12ac ___workq_kernreturn
1 libsystem_pthread.dylib +0xe40 __pthread_wqthread

Thread 7 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x12ac ___workq_kernreturn
1 libsystem_pthread.dylib +0xe40 __pthread_wqthread

Thread 8 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0xda4   _mach_msg2_trap
1 libsystem_kernel.dylib +0x13a18 _mach_msg2_internal
2 libsystem_kernel.dylib +0xd984  _thread_suspend
3 App +0x1758068            ksmachexc_i_handleExceptions
4 libsystem_pthread.dylib +0x16c8 __pthread_start

Thread 9 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0xda4   _mach_msg2_trap
1 libsystem_kernel.dylib +0x13a18 _mach_msg2_internal
2 libsystem_kernel.dylib +0x13c58 _mach_msg_overwrite
3 libsystem_kernel.dylib +0x12e8  _mach_msg
4 App +0x17580a4            ksmachexc_i_handleExceptions
5 libsystem_pthread.dylib +0x16c8 __pthread_start

Thread 10 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0xd20   _semaphore_wait_trap
1 libdispatch.dylib +0x4520       __dispatch_sema4_wait
2 libdispatch.dylib +0x4bd4       __dispatch_semaphore_wait_slow
3 App +0x1746438            -[BSGAppHangDetector detectAppHangs]
4 App +0x1746390            DetectAppHangs
5 libsystem_pthread.dylib +0x16c8 __pthread_start

Thread 11 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0xda4   _mach_msg2_trap
1 libsystem_kernel.dylib +0x13a18 _mach_msg2_internal
2 libsystem_kernel.dylib +0x13c58 _mach_msg_overwrite
3 libsystem_kernel.dylib +0x12e8  _mach_msg
4 CoreFoundation +0x7aac0         ___CFRunLoopServiceMachPort
5 CoreFoundation +0x7bd04         ___CFRunLoopRun
6 CoreFoundation +0x80eac         _CFRunLoopRunSpecific
7 CFNetwork +0x257fec             0x1882a7fec (0x1882a7e68 + 388)
8 Foundation +0x5b514             ___NSThread__start__
9 libsystem_pthread.dylib +0x16c8 __pthread_start

Thread 12 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x1678  ___psynch_cvwait
1 libsystem_pthread.dylib +0x8068 __pthread_cond_wait
2 JavaScriptCore +0xf7048         _scavenger_thread_main
3 libsystem_pthread.dylib +0x16c8 __pthread_start

Thread 13 - (TH_STATE_WAITING)
0  libsystem_kernel.dylib +0x26dc  _kevent
1  App +0xfb7af8             realm::util::network::Service::IoReactor::wait_and_activate(std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >)
2  App +0xfb8b2c             realm::util::network::Service::IoReactor::wait_and_advance(std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, bool&, realm::util::network::Service::OperQueue<realm::util::network::Service::AsyncOper>&)
3  App +0xfbe6bc             realm::util::network::Service::Impl::wait_and_process_io(std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >, bool&)
4  App +0xfb9ba8             realm::util::network::Service::Impl::run()
5  App +0xfb995c             realm::util::network::Service::run()
6  App +0xd6b66c             realm::sync::ClientImpl::run()
7  App +0xd741d8             realm::sync::Client::run()
8  App +0xb7d6b8             realm::_impl::SyncClient::SyncClient(std::__1::unique_ptr<realm::util::Logger, std::__1::default_delete<realm::util::Logger> >, realm::SyncClientConfig const&, std::__1::weak_ptr<realm::SyncManager const>)::{lambda()#2}::operator()() const
9  App +0xb7d570             decltype ((static_cast<realm::_impl::SyncClient::SyncClient(std::__1::unique_ptr<realm::util::Logger, std::__1::default_delete<realm::util::Logger> >, realm::SyncClientConfig const&, std::__1::weak_ptr<realm::SyncManager const>)::{lambda()#2}>({parm#1}))()) std::__1::__invoke<realm::_impl::SyncClient::SyncClient(std::__1::unique_ptr<realm::util::Logger, std::__1::default_delete<realm::util::Logger> >, realm::SyncClientConfig const&, std::__1::weak_ptr<realm::SyncManager const>)::{lambda()#2}>(realm::_impl::SyncClient::SyncClient(std::__1::unique_ptr<realm::util::Logger, std::__1::default_delete<realm::util::Logger> >, realm::SyncClientConfig const&, std::__1::weak_ptr<realm::SyncManager const>)::{lambda()#2}&&, (realm::_impl::SyncClient::SyncClient(std::__1::unique_ptr<realm::util::Logger, std::__1::default_delete<realm::util::Logger> >, realm::SyncClientConfig const&, std::__1::weak_ptr<realm::SyncManager const>)::{lambda()#2}&&)...)
10 App +0xb7d538             void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::SyncClient::SyncClient(std::__1::unique_ptr<realm::util::Logger, std::__1::default_delete<realm::util::Logger> >, realm::SyncClientConfig const&, std::__1::weak_ptr<realm::SyncManager const>)::{lambda()#2}>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::SyncClient::SyncClient(std::__1::unique_ptr<realm::util::Logger, std::__1::default_delete<realm::util::Logger> >, realm::SyncClientConfig const&, std::__1::weak_ptr<realm::SyncManager const>)::{lambda()#2}>&, std::__1::__tuple_indices<>)
11 App +0xb7cd5c             void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::SyncClient::SyncClient(std::__1::unique_ptr<realm::util::Logger, std::__1::default_delete<realm::util::Logger> >, realm::SyncClientConfig const&, std::__1::weak_ptr<realm::SyncManager const>)::{lambda()#2}> >(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::SyncClient::SyncClient(std::__1::unique_ptr<realm::util::Logger, std::__1::default_delete<realm::util::Logger> >, realm::SyncClientConfig const&, std::__1::weak_ptr<realm::SyncManager const>)::{lambda()#2}>)
12 libsystem_pthread.dylib +0x16c8 __pthread_start

Thread 14 - (TH_STATE_RUNNING)
0  App +0x9f9744             std::__1::__hash_table<std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::__unordered_map_hasher<realm::ObjKey, std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::hash<realm::ObjKey>, std::__1::equal_to<realm::ObjKey>, true>, std::__1::__unordered_map_equal<realm::ObjKey, std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::equal_to<realm::ObjKey>, std::__1::hash<realm::ObjKey>, true>, std::__1::allocator<std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > > > >::end() const
1  App +0x9f9744             std::__1::__hash_table<std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::__unordered_map_hasher<realm::ObjKey, std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::hash<realm::ObjKey>, std::__1::equal_to<realm::ObjKey>, true>, std::__1::__unordered_map_equal<realm::ObjKey, std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::equal_to<realm::ObjKey>, std::__1::hash<realm::ObjKey>, true>, std::__1::allocator<std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > > > >::end() const
2  App +0x9f9710             std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, void*>*> std::__1::__hash_table<std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::__unordered_map_hasher<realm::ObjKey, std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::hash<realm::ObjKey>, std::__1::equal_to<realm::ObjKey>, true>, std::__1::__unordered_map_equal<realm::ObjKey, std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::equal_to<realm::ObjKey>, std::__1::hash<realm::ObjKey>, true>, std::__1::allocator<std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > > > >::find<realm::ObjKey>(realm::ObjKey const&) const
3  App +0x9f951c             unsigned long std::__1::__hash_table<std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::__unordered_map_hasher<realm::ObjKey, std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::hash<realm::ObjKey>, std::__1::equal_to<realm::ObjKey>, true>, std::__1::__unordered_map_equal<realm::ObjKey, std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > >, std::__1::equal_to<realm::ObjKey>, std::__1::hash<realm::ObjKey>, true>, std::__1::allocator<std::__1::__hash_value_type<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > > > >::__count_unique<realm::ObjKey>(realm::ObjKey const&) const
4  App +0x9f387c             std::__1::unordered_map<realm::ObjKey, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> >, std::__1::hash<realm::ObjKey>, std::__1::equal_to<realm::ObjKey>, std::__1::allocator<std::__1::pair<realm::ObjKey const, std::__1::unordered_set<realm::ColKey, std::__1::hash<realm::ColKey>, std::__1::equal_to<realm::ColKey>, std::__1::allocator<realm::ColKey> > > > >::count(realm::ObjKey const&) const
5  App +0x9f3738             realm::ObjectChangeSet::modifications_contains(realm::ObjKey, std::__1::vector<realm::ColKey, std::__1::allocator<realm::ColKey> > const&) const
6  App +0x972708             realm::_impl::DeepChangeChecker::operator()(realm::ObjKey)
7  App +0x968750             bool realm::util::UniqueFunction<bool (realm::ObjKey)>::call_regular_void<realm::_impl::DeepChangeChecker>(std::__1::integral_constant<bool, false>, realm::_impl::DeepChangeChecker&, realm::ObjKey&&)
8  App +0x9686bc             realm::util::UniqueFunction<bool (realm::ObjKey)>::SpecificImpl<realm::_impl::DeepChangeChecker>::call(realm::ObjKey&&)
9  App +0x984990             realm::util::UniqueFunction<bool (realm::ObjKey)>::operator()(realm::ObjKey) const
10 App +0x9c1e68             realm::util::FunctionRef<bool (realm::ObjKey)>::FunctionRef<realm::util::UniqueFunction<bool (realm::ObjKey)> >(realm::util::UniqueFunction<bool (realm::ObjKey)>&&)::{lambda(void*, realm::ObjKey)#1}::operator()(void*, realm::ObjKey) const
11 App +0x9c1e14             realm::util::FunctionRef<bool (realm::ObjKey)>::FunctionRef<realm::util::UniqueFunction<bool (realm::ObjKey)> >(realm::util::UniqueFunction<bool (realm::ObjKey)>&&)::{lambda(void*, realm::ObjKey)#1}::__invoke(void*, realm::ObjKey)
12 App +0x9540b8             realm::util::FunctionRef<bool (realm::ObjKey)>::operator()(realm::ObjKey) const
13 App +0x954058             realm::_impl::CollectionChangeBuilder::calculate(realm::ObjKeys const&, realm::ObjKeys const&, realm::util::FunctionRef<bool (realm::ObjKey)>, bool)::$_9::operator()(long long) const
14 App +0x954010             realm::util::FunctionRef<bool (long long)>::FunctionRef<realm::_impl::CollectionChangeBuilder::calculate(realm::ObjKeys const&, realm::ObjKeys const&, realm::util::FunctionRef<bool (realm::ObjKey)>, bool)::$_9>(realm::_impl::CollectionChangeBuilder::calculate(realm::ObjKeys const&, realm::ObjKeys const&, realm::util::FunctionRef<bool (realm::ObjKey)>, bool)::$_9&&)::{lambda(void*, long long)#1}::operator()(void*, long long) const
15 App +0x953fc8             realm::util::FunctionRef<bool (long long)>::FunctionRef<realm::_impl::CollectionChangeBuilder::calculate(realm::ObjKeys const&, realm::ObjKeys const&, realm::util::FunctionRef<bool (realm::ObjKey)>, bool)::$_9>(realm::_impl::CollectionChangeBuilder::calculate(realm::ObjKeys const&, realm::ObjKeys const&, realm::util::FunctionRef<bool (realm::ObjKey)>, bool)::$_9&&)::{lambda(void*, long long)#1}::__invoke(void*, long long)
16 App +0x949e6c             realm::util::FunctionRef<bool (long long)>::operator()(long long) const
17 App +0x945758             (anonymous namespace)::calculate(realm::_impl::CollectionChangeBuilder&, std::__1::vector<(anonymous namespace)::RowInfo, std::__1::allocator<(anonymous namespace)::RowInfo> >, std::__1::vector<(anonymous namespace)::RowInfo, std::__1::allocator<(anonymous namespace)::RowInfo> >, realm::util::FunctionRef<bool (long long)>, bool)
18 App +0x945350             realm::_impl::CollectionChangeBuilder::calculate(realm::ObjKeys const&, realm::ObjKeys const&, realm::util::FunctionRef<bool (realm::ObjKey)>, bool)
19 App +0x9bc56c             realm::_impl::ResultsNotifier::calculate_changes()
20 App +0x9bcebc             realm::_impl::ResultsNotifier::run()
21 App +0x991908             realm::_impl::RealmCoordinator::run_async_notifiers()
22 App +0x990d04             realm::_impl::RealmCoordinator::on_change()
23 App +0x93e4ac             realm::_impl::ExternalCommitHelper::listen()
24 App +0x93fd18             realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0::operator()() const
25 App +0x93fcb4             decltype ((static_cast<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0>({parm#1}))()) std::__1::__invoke<realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0>(realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0&&)
26 App +0x93fc7c             void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0>&, std::__1::__tuple_indices<>)
27 App +0x93f4a0             void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0> >(void*)
28 libsystem_pthread.dylib +0x16c8 __pthread_start

Thread 15 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x1678  ___psynch_cvwait
1 libsystem_pthread.dylib +0x8068 __pthread_cond_wait
2 App +0xd6b4ec             realm::util::CondVar::wait(realm::util::LockGuard&)
3 App +0xfc1450             realm::util::network::Service::Impl::resolver_thread()
4 App +0xfc1360             realm::util::network::Service::Impl::add_resolve_oper(std::__1::unique_ptr<realm::util::network::Service::ResolveOperBase, realm::util::network::Service::LendersOperDeleter>)::{lambda()#1}::operator()() const
5 App +0xfc1310             decltype ((static_cast<realm::util::network::Service::Impl::add_resolve_oper(std::__1::unique_ptr<realm::util::network::Service::ResolveOperBase, realm::util::network::Service::LendersOperDeleter>)::{lambda()#1}>({parm#1}))()) std::__1::__invoke<realm::util::network::Service::Impl::add_resolve_oper(std::__1::unique_ptr<realm::util::network::Service::ResolveOperBase, realm::util::network::Service::LendersOperDeleter>)::{lambda()#1}>(realm::util::network::Service::Impl::add_resolve_oper(std::__1::unique_ptr<realm::util::network::Service::ResolveOperBase, realm::util::network::Service::LendersOperDeleter>)::{lambda()#1}&&, (realm::util::network::Service::Impl::add_resolve_oper(std::__1::unique_ptr<realm::util::network::Service::ResolveOperBase, realm::util::network::Service::LendersOperDeleter>)::{lambda()#1}&&)...)
6 App +0xfc12d8             void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::util::network::Service::Impl::add_resolve_oper(std::__1::unique_ptr<realm::util::network::Service::ResolveOperBase, realm::util::network::Service::LendersOperDeleter>)::{lambda()#1}>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::util::network::Service::Impl::add_resolve_oper(std::__1::unique_ptr<realm::util::network::Service::ResolveOperBase, realm::util::network::Service::LendersOperDeleter>)::{lambda()#1}>&, std::__1::__tuple_indices<>)
7 App +0xfc0afc             void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::util::network::Service::Impl::add_resolve_oper(std::__1::unique_ptr<realm::util::network::Service::ResolveOperBase, realm::util::network::Service::LendersOperDeleter>)::{lambda()#1}> >(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, realm::util::network::Service::Impl::add_resolve_oper(std::__1::unique_ptr<realm::util::network::Service::ResolveOperBase, realm::util::network::Service::LendersOperDeleter>)::{lambda()#1}>)
8 libsystem_pthread.dylib +0x16c8 __pthread_start

Thread 16 - (TH_STATE_WAITING)
0  libsystem_kernel.dylib +0xd20    _semaphore_wait_trap
1  libdispatch.dylib +0x4520        __dispatch_sema4_wait
2  libdispatch.dylib +0x4bd4        __dispatch_semaphore_wait_slow
3  CFNetwork +0x6b100               _CFURLConnectionSendSynchronousRequest
4  CFNetwork +0x108bb0              0x188158bb0 (0x188158a8c + 292)
5  Foundation +0x18c04              -[NSData(NSData) initWithContentsOfURL:options:maxLength:error:]
6  Foundation +0x1ffb64             @nonobjc NSData.init(contentsOf:options:)
7  Foundation +0x412904             Data.init(contentsOf:options:)
8  App +0x1c50d8              OpenGraphImageDecoder.decode(_:)
9  App +0x1c6eac              protocol witness for ImageDecoding.decode(_:) in conformance OpenGraphImageDecoder
10 App +0x1498780             _decode #1 <A>() in ImageDecoding.decode(_:urlResponse:isCompleted:cacheType:)
11 App +0x14988c8             thunk for @callee_guaranteed () -> (@owned ImageContainer?, @error @owned Error)
12 App +0x149892c             partial apply for thunk for @callee_guaranteed () -> (@owned ImageContainer?, @error @owned Error)
13 libswiftObjectiveC.dylib +0x1304 autoreleasepool<A>(invoking:)
14 App +0x1498324             ImageDecoding.decode(_:urlResponse:isCompleted:cacheType:)
15 App +0x14e05b4             closure #1 in closure #1 in TaskLoadImage.didReceiveCachedData(_:)
16 App +0x14f1da0             signpost<A>(_:_:_:)
17 App +0x14e04b0             closure #1 in TaskLoadImage.didReceiveCachedData(_:)
18 App +0x14e0724             closure #2 in TaskLoadImage.didReceiveCachedData(_:)
19 App +0x147a534             thunk for @escaping @callee_guaranteed () -> ()
20 Foundation +0xa705c              ___NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
21 Foundation +0x7b1ac              -[NSBlockOperation main]
22 Foundation +0x7b13c              ___NSOPERATION_IS_INVOKING_MAIN__
23 Foundation +0x3c4f0              -[NSOperation start]
24 Foundation +0x3c224              ___NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__
25 Foundation +0x4193c              ___NSOQSchedule_f
26 libdispatch.dylib +0x13110       __dispatch_block_async_invoke2
27 libdispatch.dylib +0x3f84        __dispatch_client_callout
28 libdispatch.dylib +0x7414        __dispatch_continuation_pop
29 libdispatch.dylib +0x6a7c        __dispatch_async_redirect_invoke
30 libdispatch.dylib +0x15a68       __dispatch_root_queue_drain
31 libdispatch.dylib +0x16280       __dispatch_worker_thread2
32 libsystem_pthread.dylib +0xdb8   __pthread_wqthread

Thread 17 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x12ac ___workq_kernreturn
1 libsystem_pthread.dylib +0xe40 __pthread_wqthread

Thread 18 - (TH_STATE_UNINTERRUPTIBLE)
0  libsystem_kernel.dylib +0x2a80 _guarded_pwrite_np
1  libsqlite3.dylib +0xb7b34      0x1ab00eb34 (0x1ab00e970 + 452)
2  libsqlite3.dylib +0x6dc8c      0x1aafc4c8c (0x1aafc4bdc + 176)
3  libsqlite3.dylib +0x761b0      0x1aafcd1b0 (0x1aafcd060 + 336)
4  libsqlite3.dylib +0x697d4      0x1aafc07d4 (0x1aafc04a8 + 812)
5  libsqlite3.dylib +0x69030      0x1aafc0030 (0x1aafbfbd0 + 1120)
6  libsqlite3.dylib +0x49c30      0x1aafa0c30 (0x1aaf9c1b4 + 19068)
7  libsqlite3.dylib +0x4468c      _sqlite3_step
8  App +0x1785394           __62-[AMPDatabaseHelper insertOrReplaceKeyValueToTable:key:value:]_block_invoke
9  App +0x17831a8           __51-[AMPDatabaseHelper inDatabaseWithStatement:block:]_block_invoke
10 libdispatch.dylib +0x3f84      __dispatch_client_callout
11 libdispatch.dylib +0x13570     __dispatch_lane_barrier_sync_invoke_and_complete
12 App +0x1783034           -[AMPDatabaseHelper inDatabaseWithStatement:block:]
13 App +0x17850e8           -[AMPDatabaseHelper insertOrReplaceKeyValueToTable:key:value:]
14 App +0x1784f28           -[AMPDatabaseHelper insertOrReplaceKeyLongValue:value:]
15 App +0x17934d0           -[Amplitude getNextSequenceNumber]
16 App +0x1792138           -[Amplitude annotateEvent:]
17 App +0x17910c4           __157-[Amplitude logEvent:withEventProperties:withApiProperties:withUserProperties:withGroups:withGroupProperties:withTimestamp:outOfSession:withMiddlewareExtra:]_block_invoke
18 Foundation +0xa705c            ___NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
19 Foundation +0x7b1ac            -[NSBlockOperation main]
20 Foundation +0x7b13c            ___NSOPERATION_IS_INVOKING_MAIN__
21 Foundation +0x3c4f0            -[NSOperation start]
22 Foundation +0x3c224            ___NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__
23 Foundation +0x4193c            ___NSOQSchedule_f
24 libdispatch.dylib +0x13110     __dispatch_block_async_invoke2
25 libdispatch.dylib +0x3f84      __dispatch_client_callout
26 libdispatch.dylib +0x7414      __dispatch_continuation_pop
27 libdispatch.dylib +0x6a7c      __dispatch_async_redirect_invoke
28 libdispatch.dylib +0x15a68     __dispatch_root_queue_drain
29 libdispatch.dylib +0x16280     __dispatch_worker_thread2
30 libsystem_pthread.dylib +0xdb8 __pthread_wqthread

Thread 19 - (TH_STATE_WAITING)
0 libsystem_pthread.dylib +0xb8c _start_wqthread

Thread 20 - (TH_STATE_RUNNING)
0  libsystem_malloc.dylib +0x16aa0 __nanov2_free
1  <unknown> +0x531f0001b87a7b88   0x531f0001b87a7b88
2  libicucore.A.dylib +0x9db88     0x18fb3bb88 (0x18fb3b2f4 + 2196)
3  libicucore.A.dylib +0x9cf2c     0x18fb3af2c (0x18fb3aee8 + 68)
4  libicucore.A.dylib +0x9ceb4     0x18fb3aeb4 (0x18fb3aea0 + 20)
5  libicucore.A.dylib +0x9cbf0     _uloc_toUnicodeLocaleKey
6  Foundation +0x1680ec            closure #2 in Locale.Components.init(identifier:)
7  Foundation +0x218ae8            partial apply for thunk for @callee_guaranteed (@unowned UnsafePointer<Int8>, @unowned UnsafePointer<Int8>?) -> ()
8  Foundation +0x2102f4            thunk for @escaping @callee_guaranteed (@unowned UnsafePointer<Int8>, @unowned UnsafePointer<Int8>?) -> ()
9  Foundation +0x56195c            _getLocaleKeywordValue
10 Foundation +0x561adc            ___enumerateLocaleKeywordValuesInIdentifier_block_invoke
11 Foundation +0x560e4c            _getAllEnumValues
12 Foundation +0x561a2c            _enumerateLocaleKeywordValuesInIdentifier
13 Foundation +0x2140bc            static Locale._unconditionallyBridgeFromObjectiveC(_:)
14 App +0x11d457c            SWProduct.init(product:)
15 App +0x13dfc28            SK1StoreProduct.swProduct.getter
16 App +0x13e8c04            protocol witness for StoreProductType.swProduct.getter in conformance SK1StoreProduct
17 App +0x13ebe40            StoreProduct.swProduct.getter
18 App +0x1357d70            static PaywallLogic.getVariablesAndFreeTrial(fromProducts:productsById:isFreeTrialAvailableOverride:isFreeTrialAvailable:)
19 App +0x135030c            closure #1 in AnyPublisher<>.getProducts(_:)

Thread 21 - (TH_STATE_RUNNING)
0  CoreFoundation +0x9e34              ___exceptionPreprocess
1  libobjc.A.dylib +0x178d4            _objc_exception_throw
2  CoreFoundation +0x17e818            -[NSObject(NSObject) doesNotRecognizeSelector:]
3  CoreFoundation +0x1ff4c             ____forwarding___
4  CoreFoundation +0x8831c             ___forwarding_prep_0___
5  libswiftCore.dylib +0xb1b78         Dictionary._Variant.setValue(_:forKey:)
6  libswiftCore.dylib +0x5a250         Dictionary.subscript.setter
7  App +0x1426bb4                StoreKitManager.getProducts(withIds:responseProducts:substituting:)
8  App +0x134fe3a                closure #1 in AnyPublisher<>.getProducts(_:)
9  App +0x1351dfe                partial apply for closure #1 in AnyPublisher<>.getProducts(_:)
10 App +0x1178836                closure #1 in closure #1 in Future<>.init(operation:)
11 App +0x117945a                partial apply for closure #1 in closure #1 in Future<>.init(operation:)
12 App +0x1064982                thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out A)
13 App +0x1064e36                $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTA.27
14 libswift_Concurrency.dylib +0x4839e completeTask(swift::AsyncContext*, swift::SwiftError*)
yusuftor commented 1 year ago

Thanks, just to be clear is the above crash still happening when you use the develop branch? And if you are using that branch can you just double check that StoreKitManager is an actor in the Superwall code? Sometimes changing the branch doesn't always update the package in SwiftPM

quanganhdo commented 1 year ago

I haven't used the develop branch when encountering the crash above. Just switched to it, I'd let you know if it comes back.

yusuftor commented 1 year ago

Great, thank you! The develop branch and master are now the same btw, I released beta 4 :)

yusuftor commented 1 year ago

How did you get on with this? I'm closing this now but feel free to reopen if the issue still occurs.

quanganhdo commented 1 year ago

No crashes lately. I'd reopen this if it comes back.