Skip to content

Cost is ignored for MacOS #236

@kevinoneill

Description

@kevinoneill

The cost function is ignored for MacOS always returning 1 for any image.

    func cost(for image: Image) -> Int {
        #if !os(macOS)
        let dataCost = ImagePipeline.Configuration.isAnimatedImageDataEnabled ? (image.animatedImageData?.count ?? 0) : 0

        // bytesPerRow * height gives a rough estimation of how much memory
        // image uses in bytes. In practice this algorithm combined with a
        // concervative default cost limit works OK.
        guard let cgImage = image.cgImage else {
            return 1 + dataCost
        }
        return cgImage.bytesPerRow * cgImage.height + dataCost

        #else
        return 1
        #endif
    }

It should be possible to interrogate image representations to determine the approximate size.

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementNon-functional change that improves existing functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions