macossprite-kitnsviewosx-elcapitanskview

Custom SKView inside NSView (macOS) gives GPU problems on certain MacBooks


I'm trying to run a custom SKView inside a NSView.

When the parent NSView is downcasted to an SKView and the SKScene is loaded inside that, then there's no problem. It's like starting a new SpriteKit project for macOS: enter image description here

But when I create a new NSView inside that parent NSView and I downcast that view to an SKView and preset the SKScene in that view, the view is all weird and wrong:

enter image description here

My storyboard setup looks like this: enter image description here

But this is only on my MacbookPro from 2011. On my 2015 Retina MacbookPro, this doesn't happen. My MacbookPro from 2011 has an NVIDIA card, that's the only difference I can spot. I'm running El Capitan on both MacbooksPros.

Does anybody know what's going on?

Thanks! Sam


Solution

  • Damn,

    I just figured out the answer myself.

    The solution is to check the mark at the custom SKView in the "Core Animation Layer" panel:

    enter image description here

    Man, I've been searching for this issue for months. Making a sample project to post the problem on Stackoverlfow made me look for discrepancies between the 2 views. Thanks Stackoverflow :-)

    enter image description here