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

Answered by DTS Engineer in 913661022

I checked on FB22297047, and it remains open and under investigation. Please continue to test your software in release and pre-release versions of system software made available to you through your developer.apple.com account. When you do, add details about that into your bug report to keep it up to date. Please see developer.apple.com/download.

Thanks also for the frame-accurate recording and log in the latest reply. Your own report is the right place for that evidence and the iPadOS 27.0.1 details. Please post its number here once it's filed.

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

I hit what looks like the same thing in Pen Friend, a handwriting app I'm building on PKCanvasView inside a zooming page, and spent most of a day trying to prove it wasn't my code.

I recorded an iPad Air (M4, iPadOS 27.0.1) over USB while writing with the Pencil, and logged every touch, scroll tick, gesture state and app event against a frame counter drawn in the corner of the screen, so each video frame lines up with the log exactly.

After writing, when I pan or pinch, strokes coming in at the screen edge are missing for a few frames, then fade in light grey, then go black. In those frames the log has nothing but scroll callbacks, no drawing changes, no layout from my side. It looks like the canvas only has tiles for what was already on screen and renders the new strip late.

With synthesized touches I also caught a stroke still being drawn losing part of itself along a tile edge for one frame, again with nothing of mine running.

One thing on my side did make it worse, a SwiftUI state change during the pinch was re-running my view update mid gesture, and that frame took about twice as long, right when the edge tiles were coming in. Worth checking if you wrap the canvas in UIViewRepresentable too.

I'm filing a Feedback with the recording and the trace and will reference FB25374087 in it.

I checked on FB22297047, and it remains open and under investigation. Please continue to test your software in release and pre-release versions of system software made available to you through your developer.apple.com account. When you do, add details about that into your bug report to keep it up to date. Please see developer.apple.com/download.

Thanks also for the frame-accurate recording and log in the latest reply. Your own report is the right place for that evidence and the iPadOS 27.0.1 details. Please post its number here once it's filed.