I have a UIScrollView which contains a "Draw View" that the user can draw freehand UIBezierPath's with. It uses CATiledLayer so I can zoom without blur.
When I draw the paths, there is no EXC_BAD_ACCESS error despite stroke being called many times. However, when I translate a path using CGAffineTransForm it lasts less than a few seconds before throwing a EXC_BAD_ACCESS error when the path is stroked. It also visually creates artefacts with the path.
I am certain this is something to do with CATiledLayer not liking the translation, because when I stop using CATiledLayer there is no issue whatsoever -- the path translates as expected with no artefacts. However, I need the CATiledLayer to zoom without blurring (as far as I am aware there is no alternative solution to that other than just setting contentscalefactor to the zoom level).
The memory/CPU usage is not abnormal when the error is thrown.
It's worth noting that I am using the iOS 11 and Xcode 9 betas. (Edit: happens on iOS 10 too, but still using same Xcode 9 Beta)
I have tried turning on zombie objects but it isn't providing any useful info.
CATiledLayeruses multiple threads to draw it's content. Many UIKit operations need to be done from the main thread. The best way to keep the advantages of the tiled layer should be using a core graphics path instead of the UIKit path. See also Technical Q&A 1637.