Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit multiple photos simultaneously bug #23

Open
ChokShen opened this issue Apr 3, 2019 · 1 comment
Open

edit multiple photos simultaneously bug #23

ChokShen opened this issue Apr 3, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@ChokShen
Copy link

ChokShen commented Apr 3, 2019

When I select multiple photos, then edit them, sometimes FMLoadingView can't hide and delegate method "didFinishPickingPhotoWith" can't response after tapping done button.Then, I set a breakpoint in DispatchQueue.main.async, and I found sometimes the code didn't enter into.
ps: my device is iPhone6,iOS12.2.

` private func processDetermination() {
FMLoadingView.shared.show()

    var dict = [Int:UIImage]()
    
    DispatchQueue.global(qos: .userInitiated).async {
        let multiTask = DispatchGroup()
        for (index, element) in self.dataSource.getSelectedPhotos().enumerated() {
            multiTask.enter()
            element.requestFullSizePhoto(cropState: .edited, filterState: .edited) {
                guard let image = $0 else { return }
                dict[index] = image
                multiTask.leave()
            }
        }
        multiTask.wait()

        let result = dict.sorted(by: { $0.key < $1.key }).map { $0.value }
        DispatchQueue.main.async { 
            FMLoadingView.shared.hide() // set a breakpoint
            self.delegate?.fmPhotoPickerController(self, didFinishPickingPhotoWith: result)
        }
    }
}`

image

Finally, I found the code "guard let image = $0 else { return }" has a bug.Because sometimes image is nil after call back , it leads to that enter() and leave() don't match, and "multiTask.wait()" will not work.

@congnd
Copy link
Owner

congnd commented Apr 8, 2019

Thanks for the detailed bug report.
I will try to investigate the problem and release a new fix version as soon as possible.

@congnd congnd added the bug Something isn't working label Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants