xamarin / mac-samples

Sample programs showing how to use Xamarin.Mac on OSX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MacControls unsafely handling controlers in ReplaceViewSeque

chamons opened this issue · comments

As noted here: https://forums.xamarin.com/discussion/comment/327038 our MacControls sample behaves poorly after a garbage collection.

The root of the problem appears to be ReplaceViewSeque.Perform which grabs out the DestinationController's view and shoves that into the visual tree without holding onto the controller.

When the GC happens, possibly caused by GC.Collect (2) the controller is eligible for collection, as the NSView doesn't force it to be around.

The sample needs to be updated to have the SourceController hold onto the DestinationController if we're going to use this structure.

Microsoft support for Xamarin will end on May 1, 2024 for all Xamarin SDKs. In preparation for this, all issues and PRs in this repository are being closed.