title: How to significantly reduce Energy Impact in iOS app?
body: <p>I'm developing an ARKit app with Vision framework capabilities (handling CoreML model). </p>
  
  <p><code>loopCoreMLUpdate()</code> function makes a loop which leads to <strong>Very High Energy Impact</strong> (CPU=70%, GPU=66%).</p>
  
  <p><strong>How to handle this task and decrease Energy Impact to LOW level</strong>?</p>
  
  <p><strong>What is a workaround for this loop issue that will help me decrease a CPU/GPU workload</strong>?</p>
  
  <p>Here'a my code:</p>
  
  <pre><code>import UIKit
  import SpriteKit
  import ARKit
  import Vision
  
  class ViewController: UIViewController, ARSKViewDelegate {
  
      @IBOutlet weak var sceneView: ARSKView!
      let dispatchQueueML = DispatchQueue(label: "AI")
      var visionRequests = [VNRequest]()
  
      // .........................................
      // .........................................
  
      override func viewDidAppear(_ animated: Bool) {
          super.viewDidAppear(animated)
          let configuration = AROrientationTrackingConfiguration()
          sceneView.session.run(configuration)
  
          loopCoreMLUpdate()
      }
  
      func loopCoreMLUpdate() {          
          dispatchQueueML.async {
              self.loopCoreMLUpdate()  // SELF-LOOP LEADS TO A VERY HIGH IMPACT
              self.updateCoreML()
          }
      }
  
      func updateCoreML() {
          let piBuffer: CVPixelBuffer? = (sceneView.session.currentFrame?.capturedImage)
          if piBuffer == nil { return }
          let ciImage = CIImage(cvPixelBuffer: piBuffer!)
          let imageRequestHandler = VNImageRequestHandler(ciImage: ciImage, options: [:])
  
          do {
              try imageRequestHandler.perform(self.visionRequests)
          } catch {
              print(error)
          }
      }
      // .........................................
      // .........................................
  }
  </code></pre>