17

Whenever I load my SpriteKit app, it logs this error: <CAMetalLayer: 0x15f57fa70>: calling -display has no effect., and it doesn't properly display many objects. I have tried recreating the scene and removing my code, both of which have done nothing. For a while I thought this might have been a bug with the new Xcode 7 and iOS 9 beta, but now that I have tried it with the GM version of both and the problem persists, that probably isn't the case.

mhillsman
  • 770
  • 1
  • 8
  • 26
  • According to the first response on [this](https://forums.developer.apple.com/thread/21386) page, the metal error is harmless. As for improper display of objects, the answer below is likely correct. – mredig Nov 08 '15 at 03:38
  • As of Xcode 7.x/iOS 9.x, the message seems to have evolved into `: calling -display has no effect.` – Nicolas Miari Apr 05 '16 at 07:43

2 Answers2

11

Check the zPosition of all your SKNodes. As it turns out, something changed in SpriteKit's implementation, and SKNode objects are no longer always rendered in the order they were added to their parent nodes. After I made sure all my SKNodes had the correct zPosition, everything went back to normal.

If that doesn't help, check this post from the dev forums.

Bruno Philipe
  • 1,091
  • 11
  • 20
  • Thank you so much! That's been driving me crazy. Changing the Z position completely solved the problem. – mhillsman Sep 11 '15 at 22:01
  • What do you mean by check the zPosition? All of mine have the same values I first assigned them. By check you mean...? Reassign them? I get the same error but it only started after I started using xCode 7. My game seems to run just fine though but I still get the error. – Hedylove Oct 09 '15 at 23:48
  • @JozemiteApps No. The problem is that, apparently, many programmers (including myself) never cared for the `zPosition` variable in the past. And now that Apple changed the SpriteKit behavior, it became evident. What I mean by "checking" is actually setting them in the first place. – Bruno Philipe Oct 10 '15 at 10:03
  • @BrunoPhilipe oh okay; well no wonder mine have shown no errors. Mine have always had them. – Hedylove Oct 11 '15 at 02:20
  • Aha, so it's necessary to set zPosition also for SKNodes? I've only set it for SKSpriteNodes, and I've run into problems with flickering sprites. I've set skView.ignoresSiblingOrder = YES BTW. So it's necessary to set zPosition for ALL nodes in the hierarchy? – Fredrik Johansson Oct 14 '15 at 19:16
  • @FredrikJohansson Yes. `zPosition` is a property of `SKNode`. Regarding `skView.ignoresSiblingOrder`, I have no idea as I have never used that. – Bruno Philipe Oct 16 '15 at 21:31
  • 1
    The documentation states "The default value is 0.0." You shouldn't need to set the `zPosition` just for the sake of setting it. It's gotta be a (super tiny) bug in SpriteKit. – Andrew Nov 04 '15 at 01:07
  • 1
    When you set `ignoresSiblingOrder` to `YES` you must set the `zPosition`. If you don't it's set as 0. Setting `ignoresSiblingOrder` gives you a performance boost because there's no need for SpriteKit to calculate the `zPosition`s. – fpg1503 Nov 30 '15 at 18:50
8

As someone suggested in this Apple Developer thread, adding the following key/value pair to your app's Info.plist seems to solve this issue for now.

Info.plist containing PrefersOpenGL key/value. Xcode 7.0.1

Make sure you choose Editor > Show Raw Keys & Values before entering the key name above.

As "MacMacMac" says in the forum post, this isn't an ideal fix, since using Metal is presumably better than using OpenGL, but at least OpenGL works.

T Blank
  • 1,408
  • 1
  • 16
  • 21
  • 1
    What if I'm not using metal at all and I get the error? – Hedylove Oct 09 '15 at 23:51
  • 1
    @JozemiteApps In iOS 9 you are automatically using Metal if you are using either SpriteKit or SceneKit, as they're both implemented in Metal now. – Bruno Philipe Oct 10 '15 at 10:04
  • 1
    What if I'd rather have SpriteKit backed by Metal (not OpenGL) and still want to get rid of the warning? – Nicolas Miari Apr 05 '16 at 07:42
  • Just tried this on device running iOS 9.3.5 and it does not work. The error msg in question seems to appear whenever the device is rotated from portrait to landscape & vice versa – rockhammer Sep 11 '16 at 03:04
  • This warning also shows with OpenGL (SpriteKit on an old phone): `: calling -display has no effect.` This is iOS 9 though. – bcattle Aug 29 '17 at 16:10