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

Break temporary retain cycle in system presentation style #40

Merged
merged 1 commit into from
Jun 23, 2021

Conversation

erichoracek
Copy link
Collaborator

Change summary

By retaining the entire context in the captured observer closure, we're implicitly capturing the context.presenting UIViewController for the duration of the transition until the DismissalTransitionDidEndNotification notification is fired.

If the DismissalTransitionDidEndNotification is never triggered, e.g. in the case of early deallocation following presentation, this could lead to the presenting view controller being retained indefinitely.

How was it tested?

How did you verify that this change accomplished what you expected? Add more detail as needed.

  • Wrote automated tests
  • Built and ran on the iOS simulator
  • Built and ran on a device

Pull request checklist

All items in this checklist must be completed before a pull request will be reviewed.

  • Risky changes have been put behind a feature flag, e.g. CollectionViewConfiguration
  • Added a CHANGELOG.md entry in the "Unreleased" section for any library changes

By retaining the entire `context` in the captured observer closure, we're implicitly capturing the `context.presenting` `UIViewController` for the duration of the transition until the `DismissalTransitionDidEndNotification` notification is fired.

If the `DismissalTransitionDidEndNotification` is never triggered, e.g. in the case of early deallocation following presentation, this could lead to the presenting view controller being retained indefinitely.
@erichoracek erichoracek requested a review from thedrick June 23, 2021 17:07
Copy link
Contributor

@thedrick thedrick left a comment

Choose a reason for hiding this comment

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

wow, very subtle. Good catch @erichoracek LGTM

@erichoracek erichoracek merged commit 77aad4d into master Jun 23, 2021
@erichoracek erichoracek deleted the eh--fix-system-retain-cycle branch June 23, 2021 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants