Skip to content

ImageTask stays in loading state #859

@ristkof

Description

@ristkof

I am using Nuke 12.8.0, on iOS Simulator iOS 18.5

I check whether an image loading task has finished by checking if the task.state == .completed, but sometimes it looks like it stays in the running state even after all progress has been made: ImageTask(id: 30, priority: normal, progress: 46934 / 46934, state: running)

My loading request looks like this:

        var size = bounds.size
        if size.width == 0 || size.height == 0 {
            // Fallback to screen size if bounds are not set
            size = UIScreen.main.bounds.size
        }
        let s = UIScreen.main.bounds.width * UIScreen.main.scale
        var url = url
        if NSClassFromString("XCTest") != nil {
            url = URL(string: "https://placecats.com/neo/300/200")!
        }
        let request = ImageRequest(url: url?.rewriteImageURL(s), processors: [
            ImageProcessors.Resize(size: size, contentMode: .aspectFill, crop: true),
            ImageProcessors.Anonymous(id: "overlaygray") { i -> PlatformImage? in
                i.darkened(transparentStart: transparentStart, blackStart: blackStart)
            },
        ])
        task?.cancel()
        task = loadImage(with: request, options: Self.imageLoadingOptions, into: self) { result in
            switch result {
            case .success:
                do {}
            case let .failure(e):
                Crashlytics.crashlytics().record(error: e)
            }
        }

Any idea what could be causing this? Is this a bug in Nuke, or could I be making a mistake somewhere?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions