From 2e71c1fa5ec073400aa8ed8ec7cd6963b5f1ff0f Mon Sep 17 00:00:00 2001 From: Ali <> Date: Fri, 24 Jun 2022 02:48:30 +0100 Subject: [PATCH] Fix fetch queue parallelization --- .../Components/AnimationCache/Sources/AnimationCache.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/submodules/TelegramUI/Components/AnimationCache/Sources/AnimationCache.swift b/submodules/TelegramUI/Components/AnimationCache/Sources/AnimationCache.swift index ddce377bf3..96c6211985 100644 --- a/submodules/TelegramUI/Components/AnimationCache/Sources/AnimationCache.swift +++ b/submodules/TelegramUI/Components/AnimationCache/Sources/AnimationCache.swift @@ -748,7 +748,9 @@ public final class AnimationCacheImpl: AnimationCache { updateResult(AnimationCacheItemResult(item: nil, isFinal: false)) if beginFetch { - guard let writer = AnimationCacheItemWriterImpl(queue: self.fetchQueues[self.nextFetchQueueIndex % self.fetchQueues.count], allocateTempFile: self.allocateTempFile, completion: { [weak self, weak itemContext] result in + let fetchQueueIndex = self.nextFetchQueueIndex + self.nextFetchQueueIndex += 1 + guard let writer = AnimationCacheItemWriterImpl(queue: self.fetchQueues[fetchQueueIndex % self.fetchQueues.count], allocateTempFile: self.allocateTempFile, completion: { [weak self, weak itemContext] result in queue.async { guard let strongSelf = self, let itemContext = itemContext, itemContext === strongSelf.itemContexts[sourceId] else { return