Change in behavior in maxOS High Sierra w.r.t. WantsLayer?

intvsteveintvsteve Steve OrthUSMember ✭✭
edited October 4 in Xamarin.Mac

Customers of my app experience a crash now in High Sierra. It happens in this code:

/// <inheritdoc/>
public override void AwakeFromNib()
{
base.AwakeFromNib();
View.Hidden = true;
View.WantsLayer = true;
var colorSpace = CGColorSpace.CreateDeviceRGB();
var colorComponents = new nfloat[4];
NSColor.LightGray.UsingColorSpace(NSColorSpace.DeviceRGB).GetComponents(out colorComponents);
colorComponents[3] = 0.18f;
View.Layer.BackgroundColor = new CGColor(colorSpace, colorComponents);
NSColor.ControlBackground.UsingColorSpace(NSColorSpace.DeviceRGBColorSpace).GetComponents(out colorComponents);
//FeedbackArea.WantsLayer = true;
FeedbackArea.Layer.BackgroundColor = new CGColor(colorSpace, colorComponents);
FeedbackArea.Layer.BorderWidth = 1;
}

Note the commented out 'FeedbackArea.WantsLayer=true;' line.

The thing is, FeedbackArea is a child of 'View'. On macOS Sierra, and all versions back to 10.7.5, this exact code runs without issue. According to the documentation:

Setting the value of this property to true turns the view into a layer-backed view—that is, the view uses a CALayer object to manage its rendered content. Creating a layer-backed view implicitly causes the entire view hierarchy under that view to become layer-backed. Thus, the view and all of its subviews (including subviews of subviews) become layer-backed. The default value of this property is false.

This is exactly the behavior observed in older OSs. Namely, when setting wantsLayer to True on View.WantsLayer, one notes that FeedbackArea.Layer is also immediately created.

It does not make a difference if View.Hidden = true is removed from this code.

Anyone else see this? I've not found anything indicating a change in behavior, but then, sometimes search-fu is bad.

Thanks!

Posts

  • ChrisHamonsChrisHamons Chris Hamons USXamarin Team Xamurai

    Internally we have seen this as well (with WebKit).

    If you link against the 10.13 sdk you get a behavior change vs 10.12 (Xcode 8.3 vs 9)

    They have a subclass of NSTabView with layer behavior disabled and had to set TransitionOptions to none on their NSTabViewController subclass that corresponded to prevent startup crashes.

    This is a frustrating Cocoa behavior change that I did not find documented.

  • RogisterAlainRogisterAlain Rogister Alain BEBeta ✭✭✭

    Hi,

    I also had this problem with the layers under High Sierra. My application crashed directly to launch because I had used the layers on some components.

    I had XCode enabled the layer for the components and there it worked normally.

    I have been using High Sierra for 1 week and I am experiencing many problems with my application.

    1) When I do a search that lasts several seconds, I have implemented a timer and I run a popup window with progress. Since High Sierra, the progress is blocked but the function is executed well.

    2) I have many crash with object memory has already been deallocated. it becomes impossible and I do not understand why ?

    Alain

Sign In or Register to comment.