Very high CPU usage when draw a stroke on a canvas with more than 5000 strokes

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.

I'm also running into high CPU usage. I'm using xcode v13.2.1 iOS 15.0. I don't need to have over 5k stroke like OP, just continuously adding strokes will spike the cpu until it gets so hot it freezes up the app. Anyone have a fix?

Very high CPU usage when draw a stroke on a canvas with more than 5000 strokes
 
 
Q