Skip to content

Weak Parent#22561

Merged
mattleibow merged 2 commits into
mainfrom
weak_parent
May 27, 2024
Merged

Weak Parent#22561
mattleibow merged 2 commits into
mainfrom
weak_parent

Conversation

@PureWeen
Copy link
Copy Markdown
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 perf/general The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf) label May 22, 2024
@PureWeen
Copy link
Copy Markdown
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
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 perf/general 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