twitter-archive / twitter-kit-ios

Twitter Kit is a native SDK to include Twitter content inside mobile apps.
Apache License 2.0
690 stars 448 forks source link

View Controller that shows the login never released (never deallocated) #54

Closed ripldev closed 6 years ago

ripldev commented 6 years ago

Something in the sdk appears to hold on to a reference to the view controller that was topmost when the twitter login is shown.

Expected behavior

When an app's view controller is displayed and a call made to - (void)logInWithCompletion:(TWTRLogInCompletion)completion; it shows the twitter login view controller. Then when the user cancels (or completes) the login, there should not be any references holding on to the app's view controller that would prevent the app's view controller from being deallocated when the app's view controller is dismissed.

Actual behavior

the app's view controller is never deallocated even after being dismissed and continues to exist.

Steps to reproduce the behavior

  1. from the app's main view controller, present a simple view controller (let's call it "VC1") with a button that is setup to call logInWithCompletion when the button it tapped and a button to dismiss the view controller and a simple log in the dealloc.
  2. when VC1 appears, tap the button and see that the twitter login is presented on VC1
  3. tap "Cancel" button on the twitter login view controller
  4. tap the dismiss button on VC1
  5. observe that the log in VC1's dealloc is never called
JacobJT commented 6 years ago

Do you reference self within the completion handler? It's possible you have a strong retain cycle going on. Does this occur with a nil completion handler?

ripldev commented 6 years ago

It happens with zero references to self in the completion handler. It appears to be related to showing the webview although I am not sure why

rajul-arora commented 6 years ago

This should be fixed in the next TwitterKit release. I believe (this)[https://github.com/twitter/twitter-kit-ios/pull/12] pull request fixes the issue.