xamarin-macios
xamarin-macios copied to clipboard
CALayer APIs handling CGColorRef can crash due to GC timing
Steps to Reproduce
- See the discussion here https://github.com/xamarin/Xamarin.PropertyEditing/pull/821#discussion_r927049949
CALayer's APIs that useCGColorshould be used in high allocation rate conditions (i.e.backgroundColor)- Create a lot of them, set them.
Expected Behavior
No crash
Actual Behavior
The native API might CFRetain the CGColorRef way too late, and dotnet precise GC scanning will mark it eligible for collection as soon as the PInvoke interop boundary is crossed.
Environment
Version information
dotnet workload list
macos SDK 6.0.300
FYI @rolfbjarne maybe we should look at this when you or both of us get back?
This seems to be a variation of #10146.