swift - Adding animation to CALayer when switching to fullscreen causes app to freeze for a while -


i having trouble macos app freezing 2-3 seconds when switch fullscreen. precise, app's window remains way until few seconds on , begins animation fullscreen without further issues. same problem occurs when leaving full screen.

now implemented own layoutsublayers() layer inside window so:

override func layoutsublayers() {     guard self.image != nil else { return }      if var currentposition = self.imagelayer.presentation()?.position {         let relativecurrentposition = cgpoint(x: currentposition.x / self.oldbounds.width, y: currentposition.y / self.oldbounds.height)         currentposition = cgpoint(x: self.bounds.width * relativecurrentposition.x, y: self.bounds.height * relativecurrentposition.y)          var targetposition = (self.direction == .atob) ? self.positionb : self.positionb         let relativetargetposition = cgpoint(x: targetposition.x / self.oldbounds.width, y: targetposition.y / self.oldbounds.height)         targetposition = cgpoint(x: self.bounds.width * relativetargetposition.x, y: self.bounds.height * relativetargetposition.y)          if self.direction == .atob {             self.positiona = currentposition             self.positionb = targetposition         } else {             self.positionb = currentposition             self.positiona = targetposition         }          let newpananimation = self.pananimation         newpananimation.duration = self.animationduration - (cacurrentmediatime() - self.timeatimagestart)         self.imagelayer.add(newpananimation, forkey: "pan")     } else {         calayer.performwithoutanimation {             self.imagelayer.position = cgpoint(x: self.bounds.width / 2, y: self.bounds.height / 2)         }     }      calayer.performwithoutanimation {         self.imagelayer.bounds = self.originalimagelayerbounds     } } 

i noticed when delete line self.imagelayer.add(newpananimation, forkey: "pan") freezing doesn't occur.

i have tried first deleting old animation key 'pan' before replacing it, didn't help.

i don't know if that's of help, self.pananimation computed property.

i hope has idea.

thanks lot!


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -