قالب وردپرس درنا توس
Home / IOS Development / fast – iOS SceneKit application faster in App Switcher Mode

fast – iOS SceneKit application faster in App Switcher Mode



I encounter quite a bizarre behavior with a SceneKit program that I develop. I invoke a method that manipulates the property simdWorldPosition by various SCNNode objects. The method changes simdWorldPosition in a loop that can run around ~ 40k times.

I define a DispatchQueue :

  la updateQueue = DispatchQueue (label: Bundle.main.bundleIdentifier! +
".SerialSceneKitQueue")

A button press calls the following:

  @objc func didPressGreedy () {
updateQueue.async {
let _ = self.Greedy ()
}
}
  car release pool {
for offset in stride (from: 0.0, through: plane Width, by: increment) {
was topLeftTransform = arkitAnchor! .simdWorldTransform * HelperMethods.makeTranslationMatrix (tx: -Float (planeWidth / 2), ty: 0.0, tz: -Float (planeHeight / 2))
topLeftTransform = topLeftTransform * HelperMethods.makeTranslationMatrix (tx: Float (offset), ty: 0.0, tz: 0.0)
la topEdgePosition = simd_float3 (x: topLeftTransform.columns.3.x, y: topLeftTransform.columns.3.y, z: topLeftTransform.columns.3.z)
saLabelComponent.simdWorldPosition = topEdgePosition

let oldSpriteTransform = sprite.simdWorldTransform

for xOffset in steps (from: -0.20, through: 0.20, by: increase) {
for yOffset in stride (from: 0.05, to: 0.20, by: increase) {
LOOP_1
_ITERATIONS + = 1 var newSpriteTransform = anchor.simdWorldTransform * HelperMethods.makeTranslationMatrix (tx: Float (xOffset), ty: Float (yOffset), tz: 0.0) sprite.simdWorldTransform = newSpriteTransform } } } }

These iterations are slow – I can sometimes see if a thousand manipulations happen for several seconds, and it takes some time to do 50 simdWorldPosition updates. If I click on the screen, I can see the executions faster.

When I use the iOS App Switcher (just swiping up the application on the iPhone XS and leaving it in the App Switcher), the application significantly increases the implementation of the iterations by a factor of 10x.

Any idea why this is caused? If I have conceptual issues, please point out the relevant topic (s).


Source link