Resolve remaining iOS widget memory leaks. #2853
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A follow up to #2850; this resolves the remaining widget memory leaks on iOS.
The underlying issue is one that has been previously solved on macOS, but the fix wasn't ported to iOS. Constraint objects are ObjC instances that are referenced by ObjC widgets; however, if the underlying widget is garbage collected before the constraint, the widget reference no longer exists, and so it can't be removed from the constraint. This causes a segfault when the constraint is disposed.
macOS added a fix for this some time ago; but the same fix wasn't applied to iOS. This ports the fix over to iOS, which then in turn allows the remaining iOS memory leaks to be resolved.
Refs #2849.
PR Checklist: