Skip to content

Conversation

phausler
Copy link
Contributor

@phausler phausler commented Jul 2, 2025

Explanation:
This ensures a potential leak with SwiftUI and other systems using Observation do not leak observation closures when the potential Observable instances used are only weakly referenced inside the tracking closure.

Scope:
This is limited to the runtime behavior of Observable types and has no ABI or language level interactions.

Issues:
rdar://112167556

Original PRs:
#79823
#82307

Risk:
Low - This is very targeted to just Observation, however it is a behavioral change which does not make this a zero risk change.

Testing:
New unit tests were added to catch at least some of the potential cases this issue can occur with.

phausler added 3 commits July 2, 2025 15:18
…all properties that are being observed have changed (for weak storage) (swiftlang#79823)

* [Observation] ensure event triggers on deinitialziation passes as if all properties that are being observed have changed (for weak storage)

* Add missing deinitialize method for synthetically triggering willSet

* Correct the weak location for tests

* Correct the test to actually test the deinitialization willSet trigger instead of testing weak value deinitialization time

* Refine the tests for deinit triggers to more tightly trigger deinitialization and weak references

* Correct missing trailing closure on deinit replacement

* Ensure all potential ids are triggered at the deinitialization edge trigger
… one per registrar and send a \Self.self as the keypath to avoid property confusions
@phausler phausler requested a review from a team as a code owner July 2, 2025 23:09
@phausler phausler requested a review from stephentyrone July 3, 2025 15:36
@stephentyrone
Copy link
Contributor

@swift-ci test

@stephentyrone stephentyrone merged commit a349e64 into swiftlang:release/6.2 Jul 10, 2025
5 checks passed
phausler added a commit to phausler/swift that referenced this pull request Aug 1, 2025
…ve active observations in memory (swiftlang#82752)"

This reverts commit a349e64.
phausler added a commit that referenced this pull request Aug 9, 2025
…ve active observations in memory (#82752)" (#83492)

This reverts commit a349e64.

This is in concert of #83436

<!--
If this pull request is targeting a release branch, please fill out the
following form:

https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1

Otherwise, replace this comment with a description of your changes and
rationale. Provide links to external references/discussions if
appropriate.
If this pull request resolves any GitHub issues, link them like so:

  Resolves <link to issue>, resolves <link to another issue>.

For more information about linking a pull request to an issue, see:

https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->

<!--
Before merging this pull request, you must run the Swift continuous
integration tests.
For information about triggering CI builds via @swift-ci, see:

https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci

Thank you for your contribution to Swift!
-->
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