PKCanvasView acting weird after it's resized

Every time I resize the PKCanvasView on a button tap, PKCanvasView, sometimes a few strokes later, sometimes on the first stroke after resize, removes all strokes except the one currently being drawn & this happens as soon as I start to draw. Then, when I lift the pencil up & away from screen, all previous strokes become visible except the one I just drew. And then, on the very next stroke, the drawing is updated correctly, with all strokes correctly visible.

This is how I update the view when it's resized:

UIView.animate(withDuration: 0.3, animations: {
            self.descriptionPane.isHidden = self.canvasToggle.isSelected
            (self.descriptionPane.superview as! UIStackView).layoutIfNeeded()

            self.currentMaxZoomScale = self.canvasToggle.isSelected ? (self.canvasView.bounds.width / oldCanvasRect.width) : 1
            self.canvasView.maximumZoomScale = self.currentMaxZoomScale
            self.canvasView.setZoomScale(self.currentMaxZoomScale, animated: false)
            self.canvasView.setContentOffset(CGPoint(x: 0,y: 0), animated: false)
        }, completion: { isComplete in
            self.canvasToggle.isUserInteractionEnabled = true
            self.canvasView.isUserInteractionEnabled = true
        })

I more often than not see the following warning when I this problem occurs.

[Stroke Generator] Missed updates at end of stroke: 2 (total points: 69)

Could anyone guide me on how I should approach this problem? Is it even a good idea to resize the canvas?

PKCanvasView acting weird after it's resized
 
 
Q