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

ReactiveCocoa 5.0 and UIKit leaks in the iOS 10.0 SDK #3251

Closed
andersio opened this issue Oct 19, 2016 · 0 comments · Fixed by #3344
Closed

ReactiveCocoa 5.0 and UIKit leaks in the iOS 10.0 SDK #3251

andersio opened this issue Oct 19, 2016 · 0 comments · Fixed by #3344
Labels

Comments

@andersio
Copy link
Member

andersio commented Oct 19, 2016

What's it about?

Several components are leaking in the iOS SDK. There is no competent workaround viable at the framework level to this.

  1. Cocoa extensions from Rex. #3210 (comment)
  2. https://github.com/ReactiveX/RxSwift/blob/master/RxCocoa/iOS/UISwitch%2BRx.swift#L22
  3. Reporting UIKit iOS 10 issue: Why isn't UISwitch being deallocated ... ever, help wanted. ReactiveX/RxSwift#842

Known Leaking Components

  1. UISwitch

Suspected

  1. UITextField
  2. UITextView

Recommended Workaround

Whenever you use the reactive extensions in Signals or BindingTargets for these components, assume they would never deinitialize.

Limit the lifetime of your bindings using a third source, e.g. the superview, whenever:

  1. the bindings must be teared down when the affected view hierarchy is removed; and
  2. the source of the bindings would outlive the affected view hierarchy.

Example

This WOULD LEAK if the lifetime of your view model outlives view hierarchy, e.g. you reuse them.

mySwitch.isOn.isEnabled <~ viewModel.isEnabled

Therefore, the binding should be constrained with a lifetime from some others that are not affected by the issue. In the following snippet, it is the ancestor of mySwitch in the view hierarchy.

mySwitch.isOn.isEnabled <~ viewModel.isEnabled.take(during: reactive.lifetime)

Note

This is an iOS specific issue. tvOS is not affected.

@andersio andersio added the bug label Oct 19, 2016
@andersio andersio changed the title UIKit leaks in the iOS 10.0 SDK ReactiveCocoa 5.0 and UIKit leaks in the iOS 10.0 SDK Oct 19, 2016
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 a pull request may close this issue.

1 participant