-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strong retain cycle of self inside of AppSyncSubscriptionWithSync #342
Comments
Thank you for the PR!! We will review this and try to push the change. |
PR was Merged: #343 |
Hey @royjit , I noticed that calling This also adds some |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When using any of the
AWSAppSyncClient
sync api, they return aAppSyncSubscriptionWithSync
object, polymorphed as aCancellable
object. When callingcancel()
and releasing the reference to this object I noticed that it would not deinitialize and persist to exist and continue its sync behaviour.I discovered that within the
AppSyncSubscriptionWithSync
there are two points whereself
is taken as a strong reference. The first is inperformInitialSync()
:and the second is in
performSync(at:)
:By updating both of these calls to take a weak self (
[weak self] in
), this removes the retain cycle and thus does not cause a memory leak when the returnedCancellable
reference is released.To Reproduce
Steps to reproduce the behavior:
Add the following unit test to existing master branch in
AWSAppSyncUnitTests/AppSyncSubscriptionWithSyncTests.swift
:Expected behavior
The expected behaviour of the previous unit tests is that once the variable
subscriptionWithSync
is set tonil
, the weak reference previously created (weakRef
) should also show asnil
.Screenshots
NA
Environment(please complete the following information):
180dc1cc59f5a5132879087331d1fd3fdfc37c93
)Device Information (please complete the following information):
Additional Information:
I have created a Pull request here which contains both the fix and the unit test with the failure behaviour previous to the fix:
#343
The text was updated successfully, but these errors were encountered: