Skip to content

Commit

Permalink
Break temporary retain cycle in system presentation style (#40)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
erichoracek authored Jun 23, 2021
1 parent 8c361d4 commit 77aad4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
in specific scenarios.
- Fixed an issue where the `accessibilityAlignment` property of `HGroup` was not being respected.
- Fixed an issue where `accessibilityAlignment` and `horizontalAlignment` would overwrite one another
- Break a temporary retain cycle in `.system` presentation style

### Changed
- `CollectionViewConfiguration.usesBatchUpdatesForAllReloads` now defaults to `true`.
Expand Down
4 changes: 2 additions & 2 deletions Sources/EpoxyPresentations/PresentationModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ extension PresentationModel.Presentation {
forName: .init("\(UIPresentationController.self)DismissalTransitionDidEndNotification"),
object: presented,
queue: .main,
using: { _ in
using: { [didDismiss = context.didDismiss] _ in
guard token != nil else { return }
token = nil
context.didDismiss()
didDismiss()
})

context.presenting.present(
Expand Down

0 comments on commit 77aad4d

Please sign in to comment.