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

Crash on AppSyncRealTimeClient.monitorHeartBeats(_:) + 428

Open amruth-movano opened this issue 1 year ago • 24 comments

Describe the bug

Our production users are getting crash in AppSyncRealTimeClient.monitorHeartBeats(_:) + 428 Below is the crash log

          Crashed: com.apple.root.default-qos
0  libswiftCore.dylib             0x4065b4 swift_isUniquelyReferenced_nonNull_native + 38
1  Combine                        0x23d70 AnyCancellable.store(in:) + 48
2  Evie Ring                      0x13e4024 closure #1 in AppSyncRealTimeClient.monitorHeartBeats(_:) + 428 (AppSyncRealTimeClient.swift:428)
3  Evie Ring                      0x13e5998 partial apply for thunk for @escaping @callee_guaranteed () -> () + 4355873176 (<compiler-generated>:4355873176)
4  Combine                        0xaecc Subscribers.Sink.receive(_:) + 92
5  Combine                        0xae60 protocol witness for Subscriber.receive(_:) in conformance Subscribers.Sink<A, B> + 24
6  Combine                        0x3322c ReduceProducer.receive(_:) + 2312
7  Combine                        0x1a304 protocol witness for Subscriber.receive(_:) in conformance ReduceProducer<A, B, C, D, E> + 24
8  Combine                        0x651bc closure #1 in Publishers.Debounce.Inner.receive(_:) + 2780
9  libswiftDispatch.dylib         0x2c84 thunk for @escaping @callee_guaranteed () -> () + 36
10 libdispatch.dylib              0x3dd4 _dispatch_client_callout + 20
11 libdispatch.dylib              0x72d8 _dispatch_continuation_pop + 600
12 libdispatch.dylib              0x1b1c8 _dispatch_source_latch_and_call + 420
13 libdispatch.dylib              0x19d8c _dispatch_source_invoke + 832
14 libdispatch.dylib              0x15894 _dispatch_root_queue_drain + 392
15 libdispatch.dylib              0x1609c _dispatch_worker_thread2 + 156
16 libsystem_pthread.dylib        0x48f8 _pthread_wqthread + 228
17 libsystem_pthread.dylib        0x10cc start_wqthread + 8

Steps To Reproduce

-

Expected behavior

It should not crash

Amplify Framework Version

2.33.6

Amplify Categories

API, DataStore

Dependency manager

Swift PM

Swift version

5.9.2

CLI version

12.11.1

Xcode version

15.0

Relevant log output

No response

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

No response

amruth-movano avatar Jun 14 '24 16:06 amruth-movano

Hello, Thank you for posting this.

  • Could you please post reproduction steps and the verbose logs for the issue with sensitive info redacted?
  • We have shipped a number of fixes in Datastore and API category since the version being used in this (2.33.6). Could you please update the version to latest (2.35.3)?

thisisabhash avatar Jun 14 '24 16:06 thisisabhash

It is not reproducible but there are almost more than 50 crash in same file for our production users

amruth-movano avatar Jun 17 '24 18:06 amruth-movano

@amruth-movano Thank you for providing the crash reports. I'll investigate to see if I can reproduce the issue.

5d avatar Jun 18 '24 22:06 5d

@5d Did you get any hint in this, as many users are seeing this crash?

amruth-movano avatar Jul 09 '24 02:07 amruth-movano

@amruth-movano Our team is still trying to reproduce this issue in our local environment. You said its not reproducible, but are you able to deduce from the usage of Amplify on what are the most likely possible steps?

harsh62 avatar Jul 11 '24 10:07 harsh62

Thank you for your patience - we will investigate and post updates.

thisisabhash avatar Jul 22 '24 21:07 thisisabhash

Hi @amruth-movano ,

Unfortunately, I couldn't reproduce the issue. Based on the stack traces, one potential cause could be that the actor-guarded property cancellables is not running in an isolated context with Apple's AnyCancellable.store(in:). I've made a potential fix on the branch 5d/fix-3748. I will discuss this with the team to see if this could mitigate the issue.

5d avatar Jul 29 '24 23:07 5d

Hi @5d,

I am also facing this issue on version 2.29.1. There are lots of Crashes due to this. What measures can I take to prevent this? I have looked over the release notes of all the recent Amplify Versions, but none of them mentioned this issue being fixed.

minaamaw-sl avatar Aug 20 '24 05:08 minaamaw-sl

Hi @minaamaw-sl, were you able to try out the 5d/fix-3748 branch in your app to resolve the issue?

lawmicha avatar Aug 20 '24 18:08 lawmicha

@lawmicha, I have not tried it as I am unable to reproduce it, however Analytics show that it does Crash for some users.

minaamaw-sl avatar Aug 21 '24 04:08 minaamaw-sl

@minaamaw-sl Our team will review the attached PR and provide an update once it gets merged.

harsh62 avatar Aug 23 '24 17:08 harsh62

@harsh62 @lawmicha @5d @thisisabhash Could you let me know if the solution has yet been released to users? We have lots of users facing this?

amruth-movano avatar Aug 26 '24 09:08 amruth-movano

Possibly related: #3834 , #3835

harsh62 avatar Aug 27 '24 01:08 harsh62

@harsh62 Thanks for checking. Can you let us know when are we going to release it in new version?

amruth-movano avatar Aug 27 '24 04:08 amruth-movano

https://github.com/aws-amplify/amplify-swift/pull/3824 has been released in 2.39.0. Please let us know if you are still seeing the crash after upgrading to that version.

tylerjroach avatar Aug 29 '24 13:08 tylerjroach

Hi, i am still getting this crash after updating the library to 2.39.0 Screenshot 2024-09-18 at 9 18 23 AM Screenshot 2024-09-18 at 9 21 00 AM

tenaz92 avatar Sep 18 '24 03:09 tenaz92

Hi @tenaz92 ,

Could you please share the complete crash log? I see that you're using version 2.39.0. However, based on the screeshot, AppSyncRealTimeClient.swift#L428 in version 2.39.0 doesn't seem to be associated with the monitorHeartBeats function.

5d avatar Sep 18 '24 17:09 5d

Confirming I am also still having the same issue. It appears to happen when the app has been left open for a while on a user's device.

zachfields avatar Oct 04 '24 12:10 zachfields

Hi @zachfields , We appreciate your confirmation. Our team will attempt to replicate the issue. To assist us further, would you be able to provide the symbolicated crash logs for the most recent crash that occurred after updating to version 2.39.0?

5d avatar Oct 04 '24 16:10 5d

Hi @zachfields , We appreciate your confirmation. Our team will attempt to replicate the issue. To assist us further, would you be able to provide the symbolicated crash logs for the most recent crash that occurred after updating to version 2.39.0?

We see a very high occurrence of this crash in the application, please find the stack trace attached. We are on 2.35.4 version of amplify

com.appbundleid_issue_1c32bbe4b45e1a0fbe6d5e50a6792814_crash_session_0c31b523e1904cfab79b550fa631fbbf_DNE_1_v2_stacktrace.txt

allab avatar Feb 25 '25 15:02 allab

This appears to have been resolved in an update over the last couple of months for me, thanks!

zachfields avatar Feb 25 '25 15:02 zachfields

That's great to hear. @allab Have you tried updating as well?

tylerjroach avatar Feb 25 '25 18:02 tylerjroach