diff --git a/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift b/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift index eb44ee1691..ac3c045fa6 100644 --- a/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift @@ -322,8 +322,10 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode { strongSelf.recognizedContentNode?.removeFromSupernode() if !results.isEmpty { let size = strongSelf.imageNode.bounds.size - let recognizedContentNode = RecognizedContentContainer(size: size, recognitions: results, presentationData: strongSelf.context.sharedContext.currentPresentationData.with { $0 }, present: { c, a in - strongSelf.galleryController()?.presentInGlobalOverlay(c, with: a) + let recognizedContentNode = RecognizedContentContainer(size: size, recognitions: results, presentationData: strongSelf.context.sharedContext.currentPresentationData.with { $0 }, present: { [weak self] c, a in + if let strongSelf = self { + strongSelf.galleryController()?.presentInGlobalOverlay(c, with: a) + } }, performAction: { [weak self] string, action in guard let strongSelf = self else { return diff --git a/submodules/ImageContentAnalysis/Sources/ImageContentAnalysis.swift b/submodules/ImageContentAnalysis/Sources/ImageContentAnalysis.swift index 13b5e5ca05..eb0bf757a8 100644 --- a/submodules/ImageContentAnalysis/Sources/ImageContentAnalysis.swift +++ b/submodules/ImageContentAnalysis/Sources/ImageContentAnalysis.swift @@ -302,6 +302,7 @@ private func recognizeContent(in image: UIImage) -> Signal<[RecognizedContent], let _ = barcodeResult.swap(mappedResults) completion() } + barcodeRequest.preferBackgroundProcessing = true requests.append(barcodeRequest) if #available(iOS 13.0, *) { @@ -310,6 +311,7 @@ private func recognizeContent(in image: UIImage) -> Signal<[RecognizedContent], let _ = textResult.swap(mappedResults) completion() } + textRequest.preferBackgroundProcessing = true textRequest.usesLanguageCorrection = true requests.append(textRequest) } else { @@ -320,7 +322,11 @@ private func recognizeContent(in image: UIImage) -> Signal<[RecognizedContent], try? handler.perform(requests) return ActionDisposable { - + if #available(iOS 13.0, *) { + for request in requests { + request.cancel() + } + } } } } else {