Skip to content
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

fix(ios): explicitly invalidate session after completion #48

Merged
merged 3 commits into from Mar 26, 2019

Conversation

janvennemann
Copy link
Contributor

JIRA: https://jira.appcelerator.org/browse/TIMOB-26811

According to the docs for the delegate property, it holds a strong reference to the object. This creates a retain circle since we set the delegate to the request itself so neither the session nor the request will be properly released, creating a memory leak.

@vijaysingh-axway
Copy link
Contributor

@janvennemann Inside error section of this function should we add
[self.session finishTasksAndInvalidate]; ? Because it is returning if error happens and responseFinished is not called.

`- (void)URLSession:(nonnull NSURLSession *)session task:(nonnull NSURLSessionTask *)task didCompleteWithError:(nullable NSError *)error
{
if (error != NULL) {
DebugLog(@"%s", PRETTY_FUNCTION);
self.response.readyState = APSHTTPResponseStateDone;
[self invokeCallbackWithState:APSHTTPCallbackStateReadyState];

self.response.connected = NO;
self.response.error = error;
[self invokeCallbackWithState:APSHTTPCallbackStateError];
[[self postForm] destroyTemporaryData];
return;

}
DebugLog(@"%s", PRETTY_FUNCTION);
self.response.downloadProgress = 1.f;
self.response.uploadProgress = 1.f;
self.response.readyState = APSHTTPResponseStateDone;
self.response.connected = NO;

[self responseFinished];
}`

Copy link
Contributor

@vijaysingh-axway vijaysingh-axway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the issue as mentioned in comment.

@janvennemann
Copy link
Contributor Author

@vijaysingh-axway added invalidation to the error handler too!

Copy link
Contributor

@vijaysingh-axway vijaysingh-axway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR passed.

@vijaysingh-axway
Copy link
Contributor

@janvennemann Please update the library in SDK. Thanks!

@tristankenney
Copy link

Is this included in a preview build?

@janvennemann
Copy link
Contributor Author

@tristankenney Unfortunately, this didn't make it into 8.0.0. It will be included in 8.0.1.

@sgtcoolguy sgtcoolguy merged commit 598e903 into master Mar 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants