swift – Calling CALayer’s setNeedsDisplay() method on iOS 17 can lead to a crash


Calling CALayer’s setNeedsDisplay() method on iOS 17 can lead to a crash. Even though i have called the method from the main thread, internally it triggers the layoutSubviews method of the views from a background thread, causing the below crash.

Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread. Unsupported layout off the main thread for UITextEffectsWindow with no associated or ancestor view controller

We have a grid view drawn using CALayer. Whenever there are changes in the grid data, we redraw the grid using the layer.setNeedsDisplay() method. However, when we submit data quickly in the grid, it calls this method frequently, which leads to crashes. This issue started occurring after iOS 17. Have attached the crash logs please check the backtrace of the crash.

enter image description here

enter image description here

enter image description here

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img