zhxf2012 / CropImageView

A lightweight library to crop image in special area,Write in swiftUI
MIT License
74 stars 4 forks source link

Pinch to zoom freezes app. #1

Open pmasonuh opened 2 years ago

pmasonuh commented 2 years ago

Hi, the zoom at the bottom works fine, but when I pinch to zoom and release the cropper freezes the app.

iOS 15+, SwiftUI 5+, Xcode 13+

johngoren commented 1 year ago

It seems like there is an issue with SwiftUI's MagnificationGesture(). I am researching other ways of zooming. https://developer.apple.com/forums/thread/689117

johngoren commented 1 year ago

I fixed it by dispatching scale changes asynchronously with DispatchQueue.main.async. May do a pull request for this if i have time.

One theory for freezes like this is that GeometryReader goes into an endless loop, which does not happen if the scale change is updated in an async manner.