commit f0075904c273a023d12a9b98e2192e647959939a
parent 1e22984d52c910b0d17c18996219174a2e144355
Author: OlegAba <mail@olegaba.com>
Date: Tue, 14 Feb 2023 21:51:06 -0500
Fix frequent KFImage hang
Changelog-Fixed: Fix some hangs when scrolling by images
Closes: #614
Diffstat:
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/damus/Components/ImageCarousel.swift b/damus/Components/ImageCarousel.swift
@@ -231,10 +231,10 @@ struct ImageCarousel: View {
KFAnimatedImage(url)
.callbackQueue(.dispatch(.global(qos: .background)))
.processingQueue(.dispatch(.global(qos: .background)))
+ .cancelOnDisappear(true)
+ .backgroundDecode()
.cacheOriginalImage()
- .loadDiskFileSynchronously()
.scaleFactor(UIScreen.main.scale)
- .fade(duration: 0.1)
.configure { view in
view.framePreloadCount = 3
}
diff --git a/damus/Views/BannerImageView.swift b/damus/Views/BannerImageView.swift
@@ -33,15 +33,15 @@ struct InnerBannerImageView: View {
.processingQueue(.dispatch(.global(qos: .background)))
.serialize(by: imageModel.serializer)
.setProcessor(imageModel.processor)
+ .cacheOriginalImage()
.configure { view in
- view.framePreloadCount = 1
+ view.framePreloadCount = 3
}
.placeholder { _ in
Color(uiColor: .secondarySystemBackground)
}
.scaleFactor(UIScreen.main.scale)
.loadDiskFileSynchronously()
- .fade(duration: 0.1)
.onFailureImage(defaultImage)
.id(imageModel.refreshID)
} else {
diff --git a/damus/Views/ProfilePicView.swift b/damus/Views/ProfilePicView.swift
@@ -70,19 +70,20 @@ struct InnerProfilePicView: View {
KFAnimatedImage(imageModel.url)
.callbackQueue(.dispatch(.global(qos: .background)))
.processingQueue(.dispatch(.global(qos: .background)))
+ .cancelOnDisappear(true)
+ .backgroundDecode()
.serialize(by: imageModel.serializer)
.setProcessor(imageModel.processor)
.cacheOriginalImage()
+ .scaleFactor(UIScreen.main.scale)
.configure { view in
- view.framePreloadCount = 1
+ view.framePreloadCount = 3
}
.placeholder { _ in
Placeholder
}
- .scaleFactor(UIScreen.main.scale)
- .loadDiskFileSynchronously()
- .fade(duration: 0.1)
- .onFailure { _ in
+ .onFailure { error in
+ if error.isTaskCancelled { return }
imageModel.downloadFailed()
}
.id(imageModel.refreshID)