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

[ios] fix memory leak in RadioButton #21151

Merged
merged 3 commits into from
Mar 18, 2024

Commits on Mar 12, 2024

  1. [ios] fix memory leak in RadioButton

    Context: https://github.com/heyThorsten/GCTest
    Fixes: dotnet#20023
    
    In testing the above sample, a page with a `RadioButton` has a memory
    leak due to the usage of `Border.StrokeShape`.
    
    There was also a slight "rabbit" hole, where we thought there was also
    an issue with `GestureRecognizers`. But this was not the case in a real
    app (just unit tests):
    
    * dotnet#21089
    
    It turns out that when `GestureRecognizers` are used in `MemoryTests`,
    they will leak if there is no `Window` involved.
    
    Instead of using `MemoryTests` like I would traditionally, we should
    instead use `NavigationPageTests.DoesNotLeak()`. I can reproduce the
    problem with `RadioButton` *and* a `Window` exists in the test.
    
    ~~ Underlying issue ~~
    
    It appears that `Border.StrokeShape` does not use the same pattern as
    other properties like `Border.Stroke`:
    
    * On set: `SetInheritedBindingContext(visualElement, BindingContext);`
    * On unset: `SetInheritedBindingContext(visualElement, null);`
    
    It instead used:
    
    * On set: `AddLogicalChild(visualElement);`
    * On unset: `RemoveLogicalChild(visualElement);`
    
    6136a8a that introduced these does not mention why one was used over
    another. I am unsure if this will cause a problem, but it fixes the leak.
    jonathanpeppers committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    2a7abf4 View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2024

  1. Add code from OnParentResourcesChanged

    This makes `Border.StrokeShape` closer to existing code in `Border.Stroke`.
    jonathanpeppers committed Mar 14, 2024
    Configuration menu
    Copy the full SHA
    e3a38e2 View commit details
    Browse the repository at this point in the history

Commits on Mar 18, 2024

  1. Configuration menu
    Copy the full SHA
    045abb0 View commit details
    Browse the repository at this point in the history