PencilKit PKCanvasView flicker

I have the following setup: UIViewRepresentable with a UIView holding

  • UIScrollView
    • ImageView
  • PKCanvasView

this is in order to make it appear as if you are writing on a paper which you can zoom and scroll. The UIImageView is holding the paper image.

The problem is if you draw some pen strokes at zoom level 1, then zoom in (say zoom level 2) as soon as you place down the pen, the PKCanvasView starts flickering repeatedly very badly. A sample video is here: https://youtube.com/shorts/5zeq6EDheSM

a small sample project showing this is here: https://www.icloud.com/iclouddrive/0a0NSLP4bsism69L7jRtZPIhQ#BugDemo

Thank you for the sample project and the video — both were very helpful.

We were able to reproduce the flickering on iPad with Apple Pencil using your sample project. We tested several potential app-level workarounds (deferring contentInset updates, guarding against layout recalculation during active drawing, consolidating CATransaction blocks) but none of them resolved the issue.

Based on our investigation, the flicker appears to be occurring within PKCanvasView's internal tile rendering when drawing at non-1x zoom scales, rather than being caused by anything in your app code.

Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. Please file a bug report, include a small Xcode project and some directions that can be used to reproduce the problem, and post the Feedback number here once you do. I'll check the status next time I do a sweep of forums posts where I've suggested bug reports and post any information about changes I am able to share to this thread.

Bug Reporting: How and Why? has tips on creating your bug report.

Thanks for confirming and hope a fix will come soon.

I did file a bug: FB22063128

As for the view hierarchy, I've since found that the amount of flicker seems to be dependent on the amount of pen strokes you do before you zoom. If you draw heavily on the entire "paper" before zooming you do eventually reach a state where the flickering doesn't stop and continues forever.

refiled it under the Developer technologies and SDKs topic mentioned in the how to file link posted above: FB22297047

PencilKit PKCanvasView flicker
 
 
Q