5

We have a code base that was written and released in 2013, but in iOS 9 the app no longer transitions visibly between SKScenes when the presentScene:transition: message is sent to our SKView. The SKScene receives the didMoveToView: message but the scene itself never shows on screen.

Here's what we tried:

  • Disabling Metal via the Info.plist
  • Using [SKTransition transitionWithCIFilter:duration:] instead of the predefined animations
  • Tweaking zPosition
  • Switching to regular UIView animations (this made our SKNodes disappear)
  • Making sure the transition method doesn't get called more than once
  • Explicitly setting pausesOutgoingScene to YES on the SKTransition

None of the above attempts fixed the issue. Note that everything transitions properly in iOS 8

Here is some sample code that doesn't work:

-(BOOL)presentTitle {
    if (!titleSceneLoaded) {
        return NO;
    }
    [skView presentScene:titleScene transition:[SKTransition fadeWithDuration:1.0]];
    return YES;
}

Changing it to this makes it work again (without the transitions):

-(BOOL)presentTitle {
    if (!titleSceneLoaded) {
        return NO;
    }
    [skView presentScene:titleScene];
    return YES;
}

Any suggestions on how to locate/fix/workaround the bug?

Nathan Hillyer
  • 1,959
  • 1
  • 18
  • 22
  • 1
    Can you update your question with a code used for transition? Also, by "not transitioning" , do you mean you are getting errors or nothing happening at all? Are you sure that code is executed at all? – Whirlwind Oct 21 '15 at 12:00
  • @Whirlwind thanks for the comment, I updated the question with those details. The code is definitely executed (verified via a breakpoint). – Nathan Hillyer Oct 21 '15 at 13:59
  • Well its definitely odd because its not happening on iOS8... But it doesn't have to be a bug necessarily... Have you tried to set fadeWithDuration to some higher value, lets say 5 and see if it works like that ? According to this post http://stackoverflow.com/a/24016057/3402095 if scene (TitleScene in your case) is resource heavy, a part of a transition could be skipped... – Whirlwind Oct 21 '15 at 15:33
  • Thanks for the idea @Whirlwind! It still remains on the previous scene even if we increase the `SKTransition` duration, and I tried switching it to some of the other `SKTransition` factory methods (including the custom `CIFilter` one) and it remains on the previous scene. `didMoveToView:` gets called on the new scene (even before your suggestion) so something is definitely happening. – Nathan Hillyer Oct 21 '15 at 17:42

4 Answers4

2

There is a bug in iOS9 with presenting a scene with a transition in a subview.

I had the same issue and in my controller I was able to fix the issue by changing the following code in viewWillLayoutSubviews from this:

        [self.subview presentScene:self.scene];
        [self.view addSubview:self.subview];

to this:

        [((SKView *)self.view) presentScene:self.scene];

Another workaround if the scene has to remain in a subview approach is to use presentScene without the transition, which does work.

painbot
  • 160
  • 9
1

We were unable to get SKTransition to work. We talked to the developer support team, posted on the developer forums, and tried everything posted here.

It is SpriteKit bug exclusive to iOS 9. If anyone else runs into this bug on iOS 9, we switched to custom transitions utilizing UIView animateWithDuration:animations:completion:.

Nathan Hillyer
  • 1,959
  • 1
  • 18
  • 22
0

It is a bit late but my own wrestling with what seems to be this bug may be worth exploring.

As I found out, I had a UIViewController floating around without having being fully deallocated, which had an SKView on it.

The only side-effect from that SKView still being somewhat live was the presentScene(transition) not working, as you have experienced.

Andy Dent
  • 17,578
  • 6
  • 88
  • 115
0

It will work if you drag and drop the SKView in the storyboard instead of creating it manually.enter image description here

Then in the ViewController, create an outlet:

@IBOutlet var skView: SKView!

Then present the scene as:

homeScene = HomeScene(size: self.view.frame.size)
homeScene.scaleMode = .aspectFill
homeScene.backgroundColor = .clear
skView.presentScene(homeScene)

And from this SKScene, you can simply use the navigation with the transition as:

let gameScene = GameScene(size: self.size) 
self.view?.presentScene(gameScene, transition: SKTransition.doorsOpenHorizontal(withDuration: 1))
Krishna Raj Salim
  • 7,331
  • 5
  • 34
  • 66