Skip to content

Commit

Permalink
Adjust GIF buffer limits
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Jul 20, 2023
1 parent 7523844 commit 2afb460
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
9 changes: 0 additions & 9 deletions WordPress/Classes/Utility/Media/GIFPlaybackStrategy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ public protocol GIFPlaybackStrategy {
///
var maxSize: Int { get }

/// The number of frames that should be buffered. A high number will result in more
/// memory usage and less CPU load, and vice versa. Default is 50.
///
var frameBufferCount: Int { get }

/// Returns the coresponding GIFStrategy enum value.
///
var gifStrategy: GIFStrategy { get }
Expand All @@ -57,24 +52,20 @@ extension GIFPlaybackStrategy {
// This is good for thumbnail GIFs used in a collection view
class TinyGIFPlaybackStrategy: GIFPlaybackStrategy {
var maxSize = 2_000_000 // in MB
var frameBufferCount = 5
var gifStrategy: GIFStrategy = .tinyGIFs
}

class SmallGIFPlaybackStrategy: GIFPlaybackStrategy {
var maxSize = 8_000_000 // in MB
var frameBufferCount = 50
var gifStrategy: GIFStrategy = .smallGIFs
}

class MediumGIFPlaybackStrategy: GIFPlaybackStrategy {
var maxSize = 20_000_000 // in MB
var frameBufferCount = 150
var gifStrategy: GIFStrategy = .mediumGIFs
}

class LargeGIFPlaybackStrategy: GIFPlaybackStrategy {
var maxSize = 50_000_000 // in MB
var frameBufferCount = 300
var gifStrategy: GIFStrategy = .largeGIFs
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ public class CachedAnimatedImageView: UIImageView, GIFAnimatable {
private func animate(data: Data, success: (() -> Void)?) {
animatedGifData = data
DispatchQueue.main.async() {
self.setFrameBufferCount(self.gifPlaybackStrategy.frameBufferCount)
self.animate(withGIFData: data) {
success?()
}
Expand Down

0 comments on commit 2afb460

Please sign in to comment.