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

Weak Parent #22561

Merged
merged 2 commits into from
May 27, 2024
Merged

Weak Parent #22561

merged 2 commits into from
May 27, 2024

Conversation

PureWeen
Copy link
Member

@PureWeen PureWeen commented May 21, 2024

Description of Change

iOS doesn't have the ability to garbage collect if there's a circular reference of NSObjects. In order for the GC to work, it's important for platform views to only reference down the tree and never up the tree.

This PR makes it so the Parent property on our xplat element is just using a WeakReference so that there isn't a strong reference from the children back up to the parents.

This shouldn't cause any issues with the Parent or Child being collected prematurely for a couple of reasons.

  1. There should really never be a scenario where a child has parent set but the parent doesn't have the child added as a logical child.
  2. If for some reason one isn't true, then, the parent should have a reference to the child at the platform level. For example, if you add a button to a layout, the underlying UIView will have a reference to the UIButton which means the UIButton won't get collected.

@Eilon Eilon added the area-controls-general General issues that span multiple controls, or common base classes such as View or Element label May 21, 2024
@jsuarezruiz jsuarezruiz added the t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf) label May 22, 2024
@PureWeen
Copy link
Member Author

/rebase

@PureWeen PureWeen marked this pull request as ready for review May 24, 2024 21:27
@PureWeen PureWeen requested a review from a team as a code owner May 24, 2024 21:27
@mattleibow mattleibow merged commit 10e3fc4 into main May 27, 2024
49 checks passed
@mattleibow mattleibow deleted the weak_parent branch May 27, 2024 15:38
@github-actions github-actions bot locked and limited conversation to collaborators Jun 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-general General issues that span multiple controls, or common base classes such as View or Element fixed-in-8.0.60 fixed-in-9.0.0-preview.5.24307.10 t/perf The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants