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.
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)
}
}
}`
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.
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()
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.