I am growing an app that strikes a “grid” with Spritekit SKAction.transfer, based mostly on frequent updates from ARKit. It crashes sporadically at digicam?.run(moveToAction). Generally the app runs for 10-15 minutes with out drawback so it is arduous to debug. I am pretty inexperienced and any assist is extremely appreciated.
func setupScene(scale: String, root: String) {
removeAllChildren()
cameraNode.removeAllChildren()
if (scale == "Free Pitch") {
spritesheetNode = SKSpriteNode(texture: SKTexture(imageNamed: "grid6"))
} else if (scale == "Chromatic") {
spritesheetNode = SKSpriteNode(texture: SKTexture(imageNamed: "chromatic"))
} else {
if (scale == "Minor Pentatonic" || scale == "Main Pentatonic") {
spritesheetNode = SKSpriteNode(texture: SKTexture(imageNamed: "pentatonic7"))
} else if (scale == "Minor" || scale == "Main") {
spritesheetNode = SKSpriteNode(texture: SKTexture(imageNamed: "diatonic"))
} else if (scale == "Harmonic Minor") {
spritesheetNode = SKSpriteNode(texture: SKTexture(imageNamed: "diatonic"))
} else if (scale == "Entire Tone"){
spritesheetNode = SKSpriteNode(texture: SKTexture(imageNamed: "wholenote"))
} else if (scale == "Diminished"){
spritesheetNode = SKSpriteNode(texture: SKTexture(imageNamed: "dimarp"))
} else if (scale == "Major3rd"){
spritesheetNode = SKSpriteNode(texture: SKTexture(imageNamed: "major3rdarp"))
} else if (scale == "Quarter"){
spritesheetNode = SKSpriteNode(texture: SKTexture(imageNamed: "quartal"))
}
getScale(scale: scale, root: root)
}
let heightFactor = 0.2667
let width = 2000.0
spritesheetNode.dimension = CGSize(width: width, peak: heightFactor * width)
spritesheetNode.anchorPoint = CGPoint(x:0.179, y:0.3)
yPosition = dimension.peak/2
spritesheetNode.place = CGPoint(x: 0, y: yPosition)
backgroundColor = UIColor.black
addChild(spritesheetNode)
digicam = cameraNode
addChild(cameraNode)
cameraNode.place = spritesheetNode.place
staticObjectsNode.dimension = CGSize(width: 600, peak: 140)
staticObjectsNode.place = CGPoint(x:0.5, y:340)
staticObjectsNode.zPosition = 1
cameraNode.addChild(staticObjectsNode)
}
func animateCamera(xMovement: Float) {
let sensitivity: Float = appState.conductor.currentSynth.sensitivity
var x = xMovement
if (appState.selectedScaleOption == "Free Pitch" || appState.selectedScaleOption == "Chromatic") {
let increment: Float = 0.1412;
x = xMovement * sensitivity / 85.0 + (((-xMovement * sensitivity / 85.0 / 0.14 - 0.071425).rounded(.down) + 1.0) * increment)
} else if (appState.selectedScaleOption == "Minor Pentatonic" || appState.selectedScaleOption == "Main Pentatonic") {
let increment: Float = 0.0588;
x = xMovement * sensitivity / 85.0 + (((-xMovement * sensitivity / 85.0 / increment + 0.03).rounded(.down) + 1.0) * increment)
} else if (appState.selectedScaleOption == "Minor" || appState.selectedScaleOption == "Main" || appState.selectedScaleOption == "Harmonic Minor") {
let increment: Float = 0.08235;
x = xMovement * sensitivity / 85.0 + (((-xMovement * sensitivity / 85.0 / increment).rounded(.down) + 1.0) * increment)
} else if (appState.selectedScaleOption == "Entire Tone") {
let increment: Float = 0.0706;
x = xMovement * sensitivity / 85.0 + (((-xMovement * sensitivity / 85.0 / increment).rounded(.down) + 1.0) * increment)
} else if (appState.selectedScaleOption == "Diminished") {
let increment: Float = 0.04705;
x = xMovement * sensitivity / 85.0 + (((-xMovement * sensitivity / 85.0 / increment).rounded(.down) + 1.0) * increment)
} else if (appState.selectedScaleOption == "Major3rd") {
let increment: Float = 0.03523;
x = xMovement * sensitivity / 85.0 + (((-xMovement * sensitivity / 85.0 / increment).rounded(.down) + 1.0) * increment)
} else if (appState.selectedScaleOption == "Quarter") {
let increment: Float = 0.1412;
x = xMovement * sensitivity / 85.0 + (((-xMovement * sensitivity / 85.0 / increment).rounded(.down) + 1.0) * increment)
}
let xPosition: Double = Double(x * 19300 * 0.375)
let level = CGPoint(x: xPosition, y: yPosition)
let moveToAction = SKAction.transfer(to: level, period: 0.005)
digicam?.run(moveToAction)
}
Exception NSException * "*** -[__NSArrayM insertObject:atIndex:]: index 1 past bounds for empty array"
sensitivity: Float 85
x: Float 0.122448787
xPosition: Double 886.2230224609375
level: CGPoint (x = 886.2230224609375, y = 422)
moveToAction: SKMove 0x0000000303389c40
0x1f5c9cf6c <+364>: ldrsw x8, [x19, #0xac]
0x1f5c9cf70 <+368>: stp x20, x21, [sp, #-0x10]!
0x1f5c9cf74 <+372>: adrp x20, 11
0x1f5c9cf78 <+376>: add x20, x20, #0x332 ; "BUG IN LIBPTHREAD: __workq_kernreturn returned"
0x1f5c9cf7c <+380>: adrp x21, 21192
0x1f5c9cf80 <+384>: add x21, x21, #0x8 ; gCRAnnotations
0x1f5c9cf84 <+388>: str x20, [x21, #0x8]
0x1f5c9cf88 <+392>: str x8, [x21, #0x38]
0x1f5c9cf8c <+396>: ldp x20, x21, [sp], #0x10
0x1f5c9cf90 <+400>: ldp x29, x30, [sp, #0x20]
0x1f5c9cf94 <+404>: ldp x20, x19, [sp, #0x10]
0x1f5c9cf98 <+408>: ldp x22, x21, [sp], #0x30
0x1f5c9cf9c <+412>: retab
0x1f5c9cfa0 <+416>: mov x0, x19
0x1f5c9cfa4 <+420>: bl 0x1f5ca1814 ; _pthread_wqthread_exit
0x1f5c9cfa8 <+424>: bl 0x1f5ca1854 ; _pthread_wqthread_legacy_worker_wrap
0x1f5c9cfac <+428>: b 0x1f5c9cee4 ; <+228>
0x1f5c9cfb0 <+432>: mov x0, x22
0x1f5c9cfb4 <+436>: bl 0x1f5ca6680 ; _pthread_wqthread.chilly.1
The “level” appears to be because it ought to, I am having bother debugging this because it occurs sporadically and could be at decrease degree. It could be higher to not use transfer motion when it’s this frequent, however i discover it smoother than updating the place straight.