Post not yet marked as solved
After testing iOS16, I've found a serious bug that make all apps with PencilKit (Prodrafts, InDraft, Pencil it in, Paint...) completely useless:
If a canvasView is scrolled, all existing strokes will be shifted while writing with Apple Pencil.
After writing, all strokes will be shifted back to its positions but it make users unable to write anything.
This bug is also occurs in the example app of PencilKit: https://developer.apple.com/documentation/pencilkit/drawing_with_pencilkit
It's easy to reprocedure: Run the example app, open a note, scroll down, then write something. You will see the bug (this bug only happens in iOS 16 and iPadOS 16).
I have sent multiple bug reports since the first days of the beta, none of them are answered. It's been 2 beta versions and the bug has not been fixed yet.
I'm an indie developer and I have worked with my app for 2 years - full time - 12 hours a day - no weekend. The main feature of my app is taking note with Apple Pencil and this bug made my app completely broken. I'm terrifying that 2 years of my work will be wasted.
Please answer me, give me hope. Thank you :(
Post not yet marked as solved
Years ago I used to use the Apple Pencil to play pubg. I used to move with my left hand and use the pencil in my right to control the view and shoot. I played today for the first time in a while and the pencil no longer works if my hand is already using the left side. Please tell me there’s a fix for this!!
Post not yet marked as solved
I am trying to use the PencilKit to build a note App. One of the issue I had was that if I use the lasso tool to select and copy a stroke, and pasted the stroke that I copied, the lasso tool focuses on the original stroke instead of the newly pasted one. Wondering if anyone have the same issue, and how can I solve it?
I uploaded a demo git in stack overflow
Post not yet marked as solved
In the recent WWDC 2022, FreeForm app was introduced and in that app in the tool picker there was a Fill Tool.
I want to put that fill tool (or any similar filling tool) in my xcode app that I am building. But when I use pencilkit PKToolPicker, there is not Fill Tool.
So how to get this fill tool in my app.
Any leads would be helpful. Thanks.
Post not yet marked as solved
Hi,
can i create custom tool for PKToolPicker?
On documentation page on PKTool says "Don’t adopt this protocol in your own objects. Instead, create a tool object to provide users with the desired the tool behavior."
Best regards,
Matej Klemen
Post not yet marked as solved
Hi everyone, i have two questions about pencil 2 that how many language does it support using scribble? At the present, i know it supports english and japanese. The second quesion is... How long can its battery use in once full charge?
Thanks
Post not yet marked as solved
In the sample project "Drawing with PencilKit", even scrolling by 1 pixel can cause my iPad Pro to use 167% CPU and keep this usage for 2-5 seconds. My iPad got too hot after few minutes that I can't barely put my palm on it.
This a serious problem and could be reprocedure easily:
Run the sample "Drawing with PencilKit" on your iPad
Open the sample note
Select all strokes in the note and duplicate about 7 times (it is just an average number of strokes I write in a page on a note-taking app like GoodNotes).
Scroll and watch the CPU usage jumps in Xcode
It is not matter how long you scroll or how many strokes are visible on the screen. If the drawing has that much strokes, the CoreHandwriting objects will eat all the CPU.
I hope it got fixed soon because it make apps with PencilKit consume too much baterry, getting too hot and we receive many bad review because of it :(
Many thank to Pencil and Paperteam for developing this Framework btw, this framework is awesome, but it could be better, I believe.
Post not yet marked as solved
i read year old post here https://developer.apple.com/forums/thread/650386?answerId=628394022#reply-to-this-question , where it is said it's not available for everyone right now.
does anyone have any info about this when snap to Shape and writing to text might be available for every one ?
Post not yet marked as solved
Seeing an issue with 15.5 beta 3, where the Apple Pencil disconnects from the iPad Pro 3rd gen when the iPad is also connected to the Magic Keyboard. Once I disconnect the keyboard the Apple Pencil works again. Anyone else seeing this?
Post not yet marked as solved
Tried to ask as a comment in the other thread:
https://developer.apple.com/forums/thread/650386?answerId=628394022#reply-to-this-question
But can't leave a comment in there for some reason (the thread is locked?). Asking exactly the same question, now for iOS 15. Anything changed in this area?
When selecting a stroke path for object on PKCanvas, the option "Snap to Shape" appears.
I understand this function is still in beta and has not made available natively to other PencilKit app. Is there a way using Stroke API to call this function directly after the user hold pencil for half a second when stroke is done drawing, just like how it behaves in native apps?
Post not yet marked as solved
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?
Post not yet marked as solved
For some reasons I am unable to set PKInk color to black.
It works with yellow, red, blue, …but black is just ignored and I get the stroke in white.
This is really weird and I don’t know why.
I tried by setting black to PKInkingTool and even by creating a stroke manually and set the PKInk color to black.
Do you have an idea?
Thanks.
Post not yet marked as solved
When I use pencil or highlighter of PencilKit on debug, and write it quickly, it'll crash. But it's fine on release
the error message:
-[MTLDebugCommandBuffer lockPurgeableObjects]:2103: failed assertion `MTLResource 0x2816cd0a0 (label: (null)), referenced in cmd buffer 0x11a041400 (label: Live rendering command buffer) is in volatile or empty purgeable state at commit'
is it a bug, or am I making something wrong?
Post not yet marked as solved
Many users reported my app use too much energy. I have profiled the app and find out the problem is from PencilKit.
It only happens on a canvas with more than 5000 strokes: When user use pen or any ink tool to draw something on the screen and leave the pencil off from the screen, the CPU go immediately to 100-165% for 3 seconds then go back to 0%.
I have time profiled CPU and found out that 90% of the calculation are from CoreHandwriting.
I suppose each time when user did draw something on the screen, PencilKit will try to recognize text from the handwriting in the background. That leads to high CPU usage.
If this is true, I hope there will be an option to disable the CoreHandwriting.
Otherwise I hope PencilKit will be updated to consume less energy, because my app received many bad reviews because of this problem and I can't do anything.
Post not yet marked as solved
The title is my question.
Post not yet marked as solved
I created a document based app with SwiftUI and a PKCanvasView.
Now I want to save the drawings of the PKCanvasView inside of the file.
How can I do this?
Post not yet marked as solved
It seems PKCanvasView overrides the property UIScrollViewDelegate which inherits from the UIScrollView to PKCanvasViewDelegate. And does not provide access to UIScrollViewDelegate.
In order to implement zooming, so I added a PKCanvasView into my own UIScrollView. And implemented delegate method viewForZooming in which return PKCanvasView.
But all drawing in PKCanvasView was blurred when zooming or scale. How to re-render drawing after zoom to make it has reasonable stroke width and clear ?
Some related code:
let canvasView = PKCanvasView()
let scrollView = UIScrollView()
override func viewDidLoad() {
super.viewDidLoad()
self.view.addSubview(scrollView)
scrollView.addSubview(canvasView)
scrollView.delegate = self
scrollView.minimumZoomScale = 0.5
scrollView.maximumZoomScale = 2.5
}
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return canvasView
}
Some solutions I had tried:
1: Reset PKCanvasView contentScaleFactor
func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
if let canvas = view {
let contentScale = scale * UIScreen.main.scale
canvas.contentScaleFactor = contentScale
}
}
Not worked!
2: Re-render PKStroke:
func reRender(_ scale: CGFloat) {
let newStrokeWidth = strokeWidth * scale
var newDrawingStrokes: [PKStroke] = []
for stroke in canvasView.drawing.strokes {
canvasView.tool = PKInkingTool(.pen, color: .red, width: newStrokeWidth)
var newPoints = [PKStrokePoint]()
stroke.path.forEach { (point) in
let newPoint = PKStrokePoint(location: point.location,
timeOffset: point.timeOffset,
size: CGSize(width: newStrokeWidth, height: newStrokeWidth),
opacity: CGFloat(1), force: point.force,
azimuth: point.azimuth, altitude: point.altitude)
newPoints.append(newPoint)
}
let newPath = PKStrokePath(controlPoints: newPoints, creationDate: Date())
let newStroke = PKStroke(ink: PKInk(.pen, color: UIColor.red), path: newPath)
newDrawingStrokes.append(newStroke)
}
let newDrawing = PKDrawing(strokes: newDrawingStrokes)
canvasView.drawing = newDrawing
}
Not worked! Still blurred, just changed strokeWidth by multiply scale.
3: I try to reset PKDrawing or PKStroke transform by using scrollView scale. Then PKDrawing position disordered and it was still blurred.
Please help me.
Post not yet marked as solved
I'm developing an app that allows you to view PDFs (music notes). I'm using PDFkit to display the pdf and need the pencilkit functionality while viewing the pdf (in the same way that you could mark up a book you are reading in iBooks when you click on the "Mark up" button). I am able to add a canvas on top of the pdf view however, I cannot save the canvas to be merged with the PDF. QuickLook offers a solution because the pencilkit looks to be built into it and works perfectly just the way I need it to, however, I don't need the other things that come with QuickLook. I desperately need your help with how I can get the pencilkit functionality on my custom PDF viewing app. At this point, I can't even find a solution for the "Mark up" button (pencil.tip.crop.circle) to be filled when tapped. Thank you in advance!
Post not yet marked as solved
I thought that PencilKit's PKPoint force was in a some kind of interval. However I don't find anywhere a max value for this pressure property.
Is there a max value? If not, how could I know the almost max pressure level value?
Post not yet marked as solved
I've got a question about PKPoint processing. I've got an application where I have to get both image and points which generated this image. However I've checked that points have been already interpolated, so there's no way to get raw points (which I thought should be similar to display's refresh rate x seconds requested to draw).
Is there a way to get raw points (not processed) and not interpolated points?