title: Scaling image in background thread crashes - UIGraphicsImageRenderer
body: <pre><code>private func scale(image ciImage: CIImage?, for scale: CGFloat) -&gt; UIImage {
      guard let ciImage = ciImage else {
          return UIImage()
      }
  
      let image = UIImage(ciImage: ciImage)
      let size = CGSize(width: image.size.width * scale, height: image.size.height * scale)
  
      let renderer = UIGraphicsImageRenderer(size: size)
  
      return renderer.image(actions: { (context) in
          image.draw(in: CGRect(origin: .zero, size: size))
      })
  }
  </code></pre>
  
  <p>I am using this method to scale (and generate before that) images. This is done in background thread and the result is then dispatched back to main thread. However, on image.draw - sometimes 1 out of 10 times, the app crashes with EXC_BAD_ACCESS. </p>
  
  <p>What am I doing wrong? Can I do that in background? </p>
  
  <p>THANKS    </p>