From 85c6ca40c29a7be4306f4a5f397831d91012c165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=82=93=E3=81=AE=E3=81=9F=E3=82=93?= Date: Wed, 24 Jul 2019 06:47:08 +0900 Subject: [PATCH 1/5] Fix build error when using Xcode 10.2.1 (#524) * "private" is reserved word * Update CHANGELOG.md [fixed] Fixes build error when using Xcode 10.2.1 --- CHANGELOG.md | 1 + Source/Classes/PINRemoteImageManager+Private.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5c57f1f..173bba94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [fixed] Fixes blending in animated WebP images. [#507](https://github.com/pinterest/PINRemoteImage/pull/507) [garrettmoon](https://github.com/garrettmoon) - [fixed] Fixes support in PINAnimatedImageView for WebP animated images. [#507](https://github.com/pinterest/PINRemoteImage/pull/507) [garrettmoon](https://github.com/garrettmoon) - [new] Add cancel method for PINRemoteImageManager. [#509](https://github.com/pinterest/PINRemoteImage/pull/509) [zhongwuzw](https://github.com/zhongwuzw) +- [fixed] Fixes build error when using Xcode 10.2.1. [#524](https://github.com/pinterest/PINRemoteImage/pull/524) [ANNotunzdY](https://github.com/ANNotunzdY) ## 3.0.0 Beta 14 - [fixed] Re-enable warnings check [#506](https://github.com/pinterest/PINRemoteImage/pull/506) [garrettmoon](https://github.com/garrettmoon) diff --git a/Source/Classes/PINRemoteImageManager+Private.h b/Source/Classes/PINRemoteImageManager+Private.h index 0c673ccf..39550e32 100644 --- a/Source/Classes/PINRemoteImageManager+Private.h +++ b/Source/Classes/PINRemoteImageManager+Private.h @@ -13,7 +13,7 @@ typedef void (^PINRemoteImageManagerDataCompletion)(NSData *data, NSURLResponse *response, NSError *error); -@interface PINRemoteImageManager (private) +@interface PINRemoteImageManager (PrivateExtension) @property (nonatomic, strong, readonly) dispatch_queue_t callbackQueue; @property (nonatomic, strong, readonly) PINOperationQueue *concurrentOperationQueue; From 4b86ba558f9717af5adb92382ce4b02377a93089 Mon Sep 17 00:00:00 2001 From: Wu Zhong Date: Wed, 24 Jul 2019 05:47:24 +0800 Subject: [PATCH 2/5] #trivial Fix macOS example Podfile (#522) --- Examples/Example-Mac/Podfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Example-Mac/Podfile b/Examples/Example-Mac/Podfile index dd43b8ae..5b9fe62e 100644 --- a/Examples/Example-Mac/Podfile +++ b/Examples/Example-Mac/Podfile @@ -1,4 +1,4 @@ -platform :macos, 10.9 +platform :macos, 10.11 target 'PINRemoteImage' do pod "PINRemoteImage/OSX", :path => "../../" From d7ff599213a5141bed0d16d011ec322ec2c5ca1e Mon Sep 17 00:00:00 2001 From: Wu Zhong Date: Wed, 24 Jul 2019 05:48:15 +0800 Subject: [PATCH 3/5] Set bpp(bits per pixel) to 32 bit for GIF (#511) * Set bpp(bits per pixel) to 32 bit for GIF * Added test * Add changelog --- CHANGELOG.md | 1 + .../AnimatedImages/PINGIFAnimatedImage.m | 2 +- Tests/PINAnimatedImageTests.swift | 23 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 173bba94..3fdf74f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - [new] Add PINRemoteImageManagerConfiguration configuration object. [#492](https://github.com/pinterest/PINRemoteImage/pull/492) [rqueue](https://github.com/rqueue) - [fixed] Fixes blending in animated WebP images. [#507](https://github.com/pinterest/PINRemoteImage/pull/507) [garrettmoon](https://github.com/garrettmoon) - [fixed] Fixes support in PINAnimatedImageView for WebP animated images. [#507](https://github.com/pinterest/PINRemoteImage/pull/507) [garrettmoon](https://github.com/garrettmoon) +- [fixed] Set bpp(bits per pixel) to 32 bit for GIF. [#511](https://github.com/pinterest/PINRemoteImage/pull/511) [zhongwuzw](https://github.com/zhongwuzw) - [new] Add cancel method for PINRemoteImageManager. [#509](https://github.com/pinterest/PINRemoteImage/pull/509) [zhongwuzw](https://github.com/zhongwuzw) - [fixed] Fixes build error when using Xcode 10.2.1. [#524](https://github.com/pinterest/PINRemoteImage/pull/524) [ANNotunzdY](https://github.com/ANNotunzdY) diff --git a/Source/Classes/AnimatedImages/PINGIFAnimatedImage.m b/Source/Classes/AnimatedImages/PINGIFAnimatedImage.m index 182bbb3d..2b5016f9 100644 --- a/Source/Classes/AnimatedImages/PINGIFAnimatedImage.m +++ b/Source/Classes/AnimatedImages/PINGIFAnimatedImage.m @@ -133,7 +133,7 @@ - (uint32_t)height - (uint32_t)bytesPerFrame { - return _width * _height * 3; + return _width * _height * 4; } - (NSError *)error diff --git a/Tests/PINAnimatedImageTests.swift b/Tests/PINAnimatedImageTests.swift index 0b73e090..66d91f7d 100644 --- a/Tests/PINAnimatedImageTests.swift +++ b/Tests/PINAnimatedImageTests.swift @@ -133,6 +133,29 @@ class PINAnimatedImageTests: XCTestCase, PINRemoteImageManagerAlternateRepresent self.waitForExpectations(timeout: self.timeoutInterval(), handler: nil) } + func testGIFBytes() { + let animatedExpectation = self.expectation(description: "Animated image should be downloaded") + let imageManager = PINRemoteImageManager.init(sessionConfiguration: nil, alternativeRepresentationProvider: self) + imageManager.downloadImage(with: self.slowAnimatedGIFURL()!) { (result : PINRemoteImageManagerResult) in + XCTAssert(result.image == nil) + guard let animatedData = result.alternativeRepresentation as? NSData else { + XCTAssert(false, "alternativeRepresentation should be able to be coerced into data") + return + } + + XCTAssert(animatedData.pin_isGIF() && animatedData.pin_isAnimatedGIF()) + + let pinCachedAnimatedImage = PINGIFAnimatedImage(animatedImageData: animatedData as Data)! + let bytesSize = UInt32((pinCachedAnimatedImage.image(at: 0, cacheProvider: nil)!.takeUnretainedValue() as CGImage).bytesPerRow) * pinCachedAnimatedImage.height + + XCTAssert(pinCachedAnimatedImage.bytesPerFrame == bytesSize) + + animatedExpectation.fulfill() + } + + self.waitForExpectations(timeout: self.timeoutInterval(), handler: nil) + } + func testInvalidAnimatedData() { let data = "AA".data(using: .ascii) let gifAnimatedImage = PINGIFAnimatedImage(animatedImageData: data) From a10757e633f48f6d99401c5bb9e5c9dab3ba3e1a Mon Sep 17 00:00:00 2001 From: Wu Zhong Date: Wed, 24 Jul 2019 06:44:31 +0800 Subject: [PATCH 4/5] Fixes AnimatedImageView designated inilializer not work (#512) * Fixes AnimatedImageView designated inilializer not work * Add test case * Add changelog --- CHANGELOG.md | 1 + .../AnimatedImages/PINAnimatedImageView.m | 47 +++++++++++-------- Tests/PINAnimatedImageTests.swift | 27 ++++++++++- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fdf74f2..5490ed61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - [new] Add PINRemoteImageManagerConfiguration configuration object. [#492](https://github.com/pinterest/PINRemoteImage/pull/492) [rqueue](https://github.com/rqueue) - [fixed] Fixes blending in animated WebP images. [#507](https://github.com/pinterest/PINRemoteImage/pull/507) [garrettmoon](https://github.com/garrettmoon) - [fixed] Fixes support in PINAnimatedImageView for WebP animated images. [#507](https://github.com/pinterest/PINRemoteImage/pull/507) [garrettmoon](https://github.com/garrettmoon) +- [fixed] Fixes AnimatedImageView designated initializer not work. [#512](https://github.com/pinterest/PINRemoteImage/pull/512) [zhongwuzw](https://github.com/zhongwuzw) - [fixed] Set bpp(bits per pixel) to 32 bit for GIF. [#511](https://github.com/pinterest/PINRemoteImage/pull/511) [zhongwuzw](https://github.com/zhongwuzw) - [new] Add cancel method for PINRemoteImageManager. [#509](https://github.com/pinterest/PINRemoteImage/pull/509) [zhongwuzw](https://github.com/zhongwuzw) - [fixed] Fixes build error when using Xcode 10.2.1. [#524](https://github.com/pinterest/PINRemoteImage/pull/524) [ANNotunzdY](https://github.com/ANNotunzdY) diff --git a/Source/Classes/AnimatedImages/PINAnimatedImageView.m b/Source/Classes/AnimatedImages/PINAnimatedImageView.m index 53823bdf..8ef426fc 100644 --- a/Source/Classes/AnimatedImages/PINAnimatedImageView.m +++ b/Source/Classes/AnimatedImages/PINAnimatedImageView.m @@ -61,6 +61,33 @@ - (void)commonInit:(PINCachedAnimatedImage *)animatedImage { _animatedImage = animatedImage; _animatedImageRunLoopMode = NSRunLoopCommonModes; + + if (animatedImage) { + [self initializeAnimatedImage:animatedImage]; + } +} + +- (void)initializeAnimatedImage:(nonnull PINCachedAnimatedImage *)animatedImage +{ + PINWeakify(self); + animatedImage.coverImageReadyCallback = ^(PINImage *coverImage) { + dispatch_async(dispatch_get_main_queue(), ^{ + PINStrongify(self); + // In this case the lock is already gone we have to call the unlocked version therefore + [self coverImageCompleted:coverImage]; + }); + }; + + animatedImage.playbackReadyCallback = ^{ + dispatch_async(dispatch_get_main_queue(), ^{ + // In this case the lock is already gone we have to call the unlocked version therefore + PINStrongify(self); + [self checkIfShouldAnimate]; + }); + }; + if (animatedImage.playbackReady) { + [self checkIfShouldAnimate]; + } } - (void)dealloc @@ -84,25 +111,7 @@ - (void)setAnimatedImage:(PINCachedAnimatedImage *)animatedImage _animatedImage = animatedImage; if (animatedImage != nil) { - PINWeakify(self); - animatedImage.coverImageReadyCallback = ^(PINImage *coverImage) { - dispatch_async(dispatch_get_main_queue(), ^{ - PINStrongify(self); - // In this case the lock is already gone we have to call the unlocked version therefore - [self coverImageCompleted:coverImage]; - }); - }; - - animatedImage.playbackReadyCallback = ^{ - dispatch_async(dispatch_get_main_queue(), ^{ - // In this case the lock is already gone we have to call the unlocked version therefore - PINStrongify(self); - [self checkIfShouldAnimate]; - }); - }; - if (animatedImage.playbackReady) { - [self checkIfShouldAnimate]; - } + [self initializeAnimatedImage:animatedImage]; } else { // Clean up after ourselves. self.layer.contents = nil; diff --git a/Tests/PINAnimatedImageTests.swift b/Tests/PINAnimatedImageTests.swift index 66d91f7d..5c31b6d2 100644 --- a/Tests/PINAnimatedImageTests.swift +++ b/Tests/PINAnimatedImageTests.swift @@ -132,8 +132,33 @@ class PINAnimatedImageTests: XCTestCase, PINRemoteImageManagerAlternateRepresent } self.waitForExpectations(timeout: self.timeoutInterval(), handler: nil) } + + func testAnimatedImageViewInitializer() { + let animatedExpectation = self.expectation(description: "Animated image should be downloaded") + let imageManager = PINRemoteImageManager.init(sessionConfiguration: nil, alternativeRepresentationProvider: self) + imageManager.downloadImage(with: self.slowAnimatedGIFURL()!) { (result : PINRemoteImageManagerResult) in + XCTAssert(result.image == nil) + guard let animatedData = result.alternativeRepresentation as? NSData else { + XCTAssert(false, "alternativeRepresentation should be able to be coerced into data") + return + } + + XCTAssert(animatedData.pin_isGIF() && animatedData.pin_isAnimatedGIF()) + + DispatchQueue.main.async { + let pinCachedAnimatedImage = PINCachedAnimatedImage(animatedImageData: animatedData as Data) + + let gifImageView = PINAnimatedImageView(animatedImage: pinCachedAnimatedImage!) + XCTAssert(gifImageView.animatedImage?.coverImageReadyCallback != nil) + + animatedExpectation.fulfill() + } + } + + self.waitForExpectations(timeout: self.timeoutInterval(), handler: nil) + } - func testGIFBytes() { + func testGIFBytes() { let animatedExpectation = self.expectation(description: "Animated image should be downloaded") let imageManager = PINRemoteImageManager.init(sessionConfiguration: nil, alternativeRepresentationProvider: self) imageManager.downloadImage(with: self.slowAnimatedGIFURL()!) { (result : PINRemoteImageManagerResult) in From ebe69fb9880ca6afe5e954caaf150d2ac7607c3b Mon Sep 17 00:00:00 2001 From: Garrett Moon Date: Mon, 5 Aug 2019 13:31:45 -0700 Subject: [PATCH 5/5] Comment out social media URL causing failures --- PINRemoteImage.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PINRemoteImage.podspec b/PINRemoteImage.podspec index 8a525217..81995018 100644 --- a/PINRemoteImage.podspec +++ b/PINRemoteImage.podspec @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.license = 'Apache 2.0' s.author = { "Garrett Moon" => "garrett@pinterest.com" } s.source = { :git => "https://github.com/pinterest/PINRemoteImage.git", :tag => s.version.to_s } - s.social_media_url = 'https://twitter.com/garrettmoon' + # s.social_media_url = 'https://twitter.com/garrettmoon' ios_deployment = "8.0" tvos_deployment = "9.0"