Skip to content

Commit

Permalink
Merge pull request #780 from kean/async-image-task-events
Browse files Browse the repository at this point in the history
Nuke 12.7
  • Loading branch information
kean authored May 5, 2024
2 parents 8e43125 + dbb37e4 commit 97f5323
Show file tree
Hide file tree
Showing 41 changed files with 786 additions and 743 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ jobs:
# run: Scripts/test.sh -s "Nuke Memory Management Tests" -d "OS=14.4,name=iPhone 12 Pro"
ios-performance-tests:
name: Performance Tests
runs-on: macOS-13
env:
DEVELOPER_DIR: /Applications/Xcode_14.3.1.app/Contents/Developer
runs-on: macOS-14
env:
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- name: Run Tests
run: Scripts/test.sh -s "Nuke Performance Tests" -d "OS=16.4,name=iPhone 14 Pro"
run: Scripts/test.sh -s "Nuke Performance Tests" -d "OS=17.4,name=iPhone 15 Pro"
swift-build:
name: Swift Build (SPM)
runs-on: macOS-13
env:
DEVELOPER_DIR: /Applications/Xcode_14.3.1.app/Contents/Developer
runs-on: macOS-14
env:
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
steps:
- uses: actions/checkout@v2
- name: Build
Expand Down
48 changes: 20 additions & 28 deletions Nuke.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

76 changes: 0 additions & 76 deletions Sources/Nuke/AsyncImageTask.swift

This file was deleted.

6 changes: 4 additions & 2 deletions Sources/Nuke/Caching/Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ final class Cache<Key: Hashable, Value>: @unchecked Sendable {
self.memoryPressure.resume()

#if os(iOS) || os(tvOS) || os(visionOS)
registerForEnterBackground()
Task {
await registerForEnterBackground()
}
#endif
}

Expand All @@ -68,7 +70,7 @@ final class Cache<Key: Hashable, Value>: @unchecked Sendable {
}

#if os(iOS) || os(tvOS) || os(visionOS)
private func registerForEnterBackground() {
@MainActor private func registerForEnterBackground() {
notificationObserver = NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: nil) { [weak self] _ in
self?.clearCacheOnEnterBackground()
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Nuke/Encoding/ImageEncoders+ImageIO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ extension ImageEncoders {
self.compressionRatio = compressionRatio
}

@Atomic private static var availability = [AssetType: Bool]()
private static let availability = Atomic<[AssetType: Bool]>(value: [:])

/// Returns `true` if the encoding is available for the given format on
/// the current hardware. Some of the most recent formats might not be
/// available so its best to check before using them.
public static func isSupported(type: AssetType) -> Bool {
if let isAvailable = availability[type] {
if let isAvailable = availability.value[type] {
return isAvailable
}
let isAvailable = CGImageDestinationCreateWithData(
NSMutableData() as CFMutableData, type.rawValue as CFString, 1, nil
) != nil
availability[type] = isAvailable
availability.withLock { $0[type] = isAvailable }
return isAvailable
}

Expand Down
10 changes: 6 additions & 4 deletions Sources/Nuke/ImageResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

import Foundation

#if !os(macOS)
import UIKit.UIImage
#else
import AppKit.NSImage
#if canImport(UIKit)
import UIKit
#endif

#if canImport(AppKit)
import AppKit
#endif

/// An image response that contains a fetched image and some metadata.
Expand Down
Loading

0 comments on commit 97f5323

Please sign in to comment.