aws-amplify / amplify-swift

A declarative library for application development using cloud services.
Apache License 2.0
454 stars 196 forks source link

Crash in AppSyncRealTimeClient.subscribeToWebSocketEvent() #3834

Closed amruth-movano closed 1 month ago

amruth-movano commented 2 months ago

Describe the bug

          Crashed: com.apple.root.default-qos.cooperative
0  libobjc.A.dylib                0x3020 objc_msgSend + 32
1  libswiftCore.dylib             0x1d69f4 __CocoaSet.member(for:) + 36
2  Combine                        0x23df0 specialized Set._Variant.insert(_:) + 92
3  Combine                        0x23d70 AnyCancellable.store(in:) + 48
4  Evie Ring                      0x1452f1c closure #2 in AppSyncRealTimeClient.subscribeToWebSocketEvent() + 244 (AppSyncRealTimeClient.swift:244)
5  Combine                        0xaecc Subscribers.Sink.receive(_:) + 92
6  Combine                        0xae60 protocol witness for Subscriber.receive(_:) in conformance Subscribers.Sink<A, B> + 24
7  Combine                        0x13714 PassthroughSubject.Conduit.offer(_:) + 744
8  Combine                        0x1341c partial apply for closure #1 in PassthroughSubject.send(_:) + 68
9  Combine                        0x3d5b0 partial apply for thunk for @callee_guaranteed (@guaranteed ConduitBase<A, B>) -> (@error @owned Error) + 32
10 libswiftCore.dylib             0xdee70 Sequence.forEach(_:) + 756
11 Combine                        0x12f30 ConduitList.forEach(_:) + 244
12 Combine                        0x12dcc PassthroughSubject.send(_:) + 268
13 Evie Ring                      0x96e9c8 WebSocketClient.onNetworkStateChange(_:) + 287 (WebSocketClient.swift:287)
14 libswift_Concurrency.dylib     0x4d764 swift::runJobInEstablishedExecutorContext(swift::Job*) + 436
15 libswift_Concurrency.dylib     0x4e9c8 swift_job_runImpl(swift::Job*, swift::ExecutorRef) + 72
16 libdispatch.dylib              0x15894 _dispatch_root_queue_drain + 392
17 libdispatch.dylib              0x1609c _dispatch_worker_thread2 + 156
18 libsystem_pthread.dylib        0x48f8 _pthread_wqthread + 228
19 libsystem_pthread.dylib        0x10cc start_wqthread + 8

Expected behavior

App should not crash

Amplify Framework Version

2.33.6

Amplify Categories

API

Dependency manager

Swift PM

Swift version

5.9.2

CLI version

12.11.1

Xcode version

15.0

Relevant log output

-

Is this a regression?

Yes

Regression additional context

No response

Platforms

iOS

OS Version

iOS 17.5.1

Device

iPhone 13 :Pro

Specific to simulators

No response

Additional context

-

amruth-movano commented 2 months ago

@harsh62 @lawmicha @5d @thisisabhash Can you please take this as priority, we have a major release in this week

amruth-movano commented 2 months ago

This is another crash log - Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0x83f20 exceptionPreprocess 1 libobjc.A.dylib 0x16018 objc_exception_throw 2 CoreFoundation 0x18d480 +[NSObject(NSObject) copyDescription] 3 CoreFoundation 0x20fb4 forwarding_ 4 CoreFoundation 0x208d0 _CF_forwarding_prep_0 5 libswiftCore.dylib 0x1d69f4 CocoaSet.member(for:) 6 Combine 0x23df0 specialized Set.Variant.insert(:) 7 Combine 0x23d70 AnyCancellable.store(in:) 8 Evie Ring 0x1452f1c closure #2 in AppSyncRealTimeClient.subscribeToWebSocketEvent() + 244 (AppSyncRealTimeClient.swift:244) 9 Combine 0xaecc Subscribers.Sink.receive(:) 10 Combine 0xae60 protocol witness for Subscriber.receive(:) in conformance Subscribers.Sink<A, B> 11 Combine 0x13714 PassthroughSubject.Conduit.offer(:) 12 Combine 0x1341c partial apply for closure #1 in PassthroughSubject.send(:) 13 Combine 0x3d5b0 partial apply for thunk for @calleeguaranteed (@guaranteed ConduitBase<A, B>) -> (@error @owned Error) 14 libswiftCore.dylib 0xdee70 Sequence.forEach(:) 15 Combine 0x12f30 ConduitList.forEach(:) 16 Combine 0x12dcc PassthroughSubject.send(:) 17 Evie Ring 0x97059c specialized WebSocketClient.urlSession(:webSocketTask:didCloseWith:reason:) + 232 (WebSocketClient.swift:232) 18 Evie Ring 0x96e17c @objc WebSocketClient.urlSession(:webSocketTask:didCloseWith:reason:) () 19 libdispatch.dylib 0x213c _dispatch_call_block_and_release 20 libdispatch.dylib 0x3dd4 _dispatch_client_callout 21 libdispatch.dylib 0xb400 _dispatch_lane_serial_drain 22 libdispatch.dylib 0xbf64 _dispatch_lane_invoke 23 libdispatch.dylib 0x16cb4 _dispatch_root_queue_drain_deferred_wlh 24 libdispatch.dylib 0x16528 _dispatch_workloop_worker_thread 25 libsystem_pthread.dylib 0x4934 _pthread_wqthread 26 libsystem_pthread.dylib 0x10cc start_wqthread

amruth-movano commented 2 months ago

This is also 1 variant -

      Crashed: com.apple.root.default-qos.cooperative

0 libsystem_kernel.dylib 0xc42c __pthread_kill + 8 1 libsystem_pthread.dylib 0x7c0c pthread_kill + 268 2 libsystem_c.dylib 0x75ba0 abort + 180 3 libswiftCore.dylib 0x3a6690 swift::fatalError(unsigned int, char const, ...) + 134 4 libswiftCore.dylib 0x3a66b0 swift::warningv(unsigned int, char const, char) + 30 5 libswiftCore.dylib 0x3ab4dc swift_deallocPartialClassInstance + 306 6 libswiftCore.dylib 0x3ab36c _swift_release_dealloc + 56 7 libswiftCore.dylib 0x3ac488 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136 8 libswiftCore.dylib 0x39093c swift_arrayDestroy + 196 9 libswiftCore.dylib 0x1d992c _SetStorage.deinit + 240 10 libswiftCore.dylib 0x1d99a0 _SetStorage.__deallocating_deinit + 16 11 libswiftCore.dylib 0x3ab36c _swift_release_dealloc + 56 12 libswiftCore.dylib 0x3ac488 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136 13 Combine 0x23fb4 specialized Set.Variant.insert(:) + 544 14 Combine 0x23d70 AnyCancellable.store(in:) + 48 15 Evie Ring 0x1452f1c closure #2 in AppSyncRealTimeClient.subscribeToWebSocketEvent() + 244 (AppSyncRealTimeClient.swift:244) 16 Combine 0xaecc Subscribers.Sink.receive(:) + 92 17 Combine 0xae60 protocol witness for Subscriber.receive(:) in conformance Subscribers.Sink<A, B> + 24 18 Combine 0x13714 PassthroughSubject.Conduit.offer(:) + 744 19 Combine 0x1341c partial apply for closure #1 in PassthroughSubject.send(:) + 68 20 Combine 0x3d5b0 partial apply for thunk for @calleeguaranteed (@guaranteed ConduitBase<A, B>) -> (@error @owned Error) + 32 21 libswiftCore.dylib 0xdee70 Sequence.forEach(:) + 756 22 Combine 0x12f30 ConduitList.forEach(:) + 244 23 Combine 0x12dcc PassthroughSubject.send(:) + 268 24 Evie Ring 0x96db88 WebSocketClient.startReadMessage() + 204 (WebSocketClient.swift:204) 25 libswift_Concurrency.dylib 0x4d764 swift::runJobInEstablishedExecutorContext(swift::Job) + 436 26 libswift_Concurrency.dylib 0x4e9c8 swift_job_runImpl(swift::Job*, swift::ExecutorRef) + 72 27 libdispatch.dylib 0x15894 _dispatch_root_queue_drain + 392 28 libdispatch.dylib 0x1609c _dispatch_worker_thread2 + 156 29 libsystem_pthread.dylib 0x48f8 _pthread_wqthread + 228 30 libsystem_pthread.dylib 0x10cc start_wqthread + 8

amruth-movano commented 2 months ago

@TechHorizon2003 what is it?

amruth-movano commented 2 months ago

@harsh62 @lawmicha @5d can you please check this crash?

harsh62 commented 2 months ago

@amruth-movano Thanks for raising the issue. Would you be able to provide symbolicated crash logs? Furthermore, would you be able to grab verbose logs from the library with any reproduction steps, so that the team could try to reproduce the issue in a local environment.

amruth-movano commented 2 months ago

@harsh62 We are unable to reproduce this scenario using Xcode and the only stack trace which we have is I have already added

5d commented 2 months ago

Hi @amruth-movano, A potential fix patch has been released with version 2.39.0; Could you please give a try to see if this patch mitigate the issue?

github-actions[bot] commented 1 month ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.