FMPhotoPicker icon indicating copy to clipboard operation
FMPhotoPicker copied to clipboard

edit multiple photos simultaneously bug

Open ChokShen opened this issue 6 years ago • 1 comments

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.

ChokShen avatar Apr 03 '19 11:04 ChokShen

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

congnd avatar Apr 08 '19 00:04 congnd