Im currently working on a SceneKit app and I've recently ran into a problem while testing it on my iPhone 5s.
I write the code below to have a block move left and right repeatedly, everything works fine.
SCNAction *mn1 = [SCNAction moveByX:-2.2 y:0 z:0 duration:1];
SCNAction *mn2 = [SCNAction moveByX:2.2 y:0 z:0 duration:1];
SCNAction *mn3 = [SCNAction waitForDuration:0.5];
SCNAction *mns = [SCNAction repeatActionForever:[SCNAction sequence:@[mn3,mn1,mn3,mn2]]];
[self.blueNode1 runAction:mns];
and in The AppDelegate.m
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for
certain types of temporary interruptions (such as an incoming phone call or SMS message) or when
the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame
rates. Games should use this method to pause the game.
SCNView *view = (SCNView *)self.window.rootViewController.view;
view.scene.paused = YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive.
If the application was previously in the background, optionally refresh the user interface.
SCNView *view = (SCNView *)self.window.rootViewController.view;
view.scene.paused = NO;
}
When I enter "background/inactive mode" via the Home Button and return to my app, everything still runs smooth.
when I enter the "background" via the Power Button and wait a few seconds and return to my app. The blueNode1 will repeatedly run the action at a very fast speed for a period of time. The longer time that I spend off the app the longer the block moves at an extreme speed when I return to the App. Im not sure why this happens but its potentially a game-breaking bug.
I hope that I made my problem clear. Any help is appreciated.
EDIT: I just created a brand new test app to see if I could recreate the bug on a new project and I was able to. It didn't seem to happen while my iPhone was running the app through my Mac tho, however, As soon as I unplugged my iPhone and ran the test app through it, I was able to recreate it on the new project.