Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

真机播放Gif崩溃 #440

Closed
alimysoyang opened this issue Sep 16, 2016 · 4 comments
Closed

真机播放Gif崩溃 #440

alimysoyang opened this issue Sep 16, 2016 · 4 comments

Comments

@alimysoyang
Copy link

3.0.1,在真机上播放Gif时崩溃,模拟器上不会崩溃,崩溃信息如下:

  • thread Replace all 'url' with 'URL'. #1: tid = 0x20e78a, 0x0000000184a3627c vImagevPremultipliedAlphaBlendWithPermute_ARGB8888 + 836, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10ada4000) frame #0: 0x0000000184a3627c vImagevPremultipliedAlphaBlendWithPermute_ARGB8888 + 836
    frame Replace all 'url' with 'URL'. #1: 0x0000000184a2eb7c vImagevImagePremultipliedAlphaBlendWithPermute_ARGB8888 + 436 frame #2: 0x0000000184e3b7fc CoreGraphicsCGSBlend8888toARGB8888 + 284
    frame Fix typo and eliminate confusion. #3: 0x000000018504ef98 CoreGraphicsARGB32_image + 4088 frame #4: 0x0000000184fdade8 CoreGraphicsripl_Mark + 32
    frame A question about dispatch_sync #5: 0x0000000184fd79f0 CoreGraphicsRIPLayerBltImage + 972 frame #6: 0x0000000184f368e4 CoreGraphicsripc_DrawImage + 768
    frame CocoaPods update #7: 0x0000000184f27610 CoreGraphicsCGContextDrawImageWithOptions + 456 frame #8: 0x0000000102a37d0c libswiftCoreGraphics.dylib(extension in CoreGraphics):__ObjC.CGContext.draw (__ObjC.CGImage, in : __C.CGRect, byTiling : Swift.Bool) -> () + 48
    • frame Building with Xcode 6.3 using cocoa pods give me a libtool linker error #9: 0x000000010014cf38 BoBoCGImage.fixed.getter(self=0x000000012762d890) + 240 at Image.swift:712 frame #10: 0x000000010014cc18 BoBoUIImage.kf_resize(size=(width = 320, height = 230), self=0x000000012764cba0) -> UIImage + 100 at Image.swift:409
      frame Add not nil judgment for placeholderImage before set it to UIImageView #11: 0x000000010014d100 BoBo@objc UIImage.kf_resize(to : CGSize) -> UIImage + 84 at Image.swift:0 frame #12: 0x000000010014c830 BoBoUIImage.kf_resize(size=(width = 320, height = 320), contentMode=scaleAspectFit, self=0x000000012764cba0) -> UIImage + 164 at Image.swift:388
      frame Feature: Is it possible to get somehow the cache size? #13: 0x000000010014cb94 BoBo@objc UIImage.kf_resize(to : CGSize, for : UIViewContentMode) -> UIImage + 92 at Image.swift:0 frame #14: 0x0000000100594414 BoBoAnimator.prepareFrame(index=0, self=0x0000000127616fe0) -> AnimatedFrame + 568 at AnimatedImageView.swift:285
      frame Add total disk cache size method. #15: 0x0000000100593f64 BoBoAnimator.($0=0 values, $1=0, self=0x0000000127616fe0) -> ()).(closure #1) + 80 at AnimatedImageView.swift:254 frame #16: 0x00000001005940d8 BoBothunk + 48 at AnimatedImageView.swift:0
      frame [WIP] 1.1.2 #17: 0x00000001026323f0 libswiftCore.dylib(extension in Swift):Swift.Sequence.reduce <A> (A1, (A1, A.Iterator.Element) throws -> A1) throws -> A1 + 552 frame #18: 0x0000000100593e60 BoBoAnimator.prepareFrames(self=0x0000000127616fe0) -> () + 2120 at AnimatedImageView.swift:254
      frame when does the image download start? #19: 0x0000000100591f70 BoBoAnimatedImageView.reset(self=0x0000000127570d10) -> () + 896 at AnimatedImageView.swift:165 frame #20: 0x0000000100591064 BoBoAnimatedImageView.image.didset(oldValue=nil, self=0x0000000127570d10) + 148 at AnimatedImageView.swift:97
      frame Add challenge handler for image downloader #21: 0x0000000100590fb0 BoBoAnimatedImageView.image.setter(newValue=0x0000000127578bb0, self=0x0000000127570d10) + 248 at AnimatedImageView.swift:0 frame #22: 0x0000000100590ea4 BoBo@objc AnimatedImageView.image.setter + 68 at AnimatedImageView.swift:0

崩溃代码发生在Image.swift中的712行
extension CGImage {
var isARGB8888: Bool {
return bitsPerPixel == 32 && bitsPerComponent == 8 && bitmapInfo.contains(.alphaInfoMask)
}

var fixed: CGImage {
    if isARGB8888 { return self }

    // Convert to ARGB if it isn't
    guard let context = CGContext.createARGBContext(from: self) else {
        assertionFailure("[Kingfisher] Failed to create CG context when converting non ARGB image.")
        return self
    }
    context.draw(self, in: CGRect(x: 0, y: 0, width: width, height: height))//这里
    guard let r = context.makeImage() else {
        assertionFailure("[Kingfisher] Failed to create CG image when converting non ARGB image.")
        return self
    }
    return r
}

}

@alimysoyang
Copy link
Author

请问一个问题,AnimatedImageView这个类是不是只能显示本地GIF,不能显示网络GIF,谢谢

@onevcat
Copy link
Owner

onevcat commented Sep 21, 2016

@alimysoyang It should be able to display either local and remote GIF file. May I know the url address of your GIF file so I could have a deeper look at it.

Thanks!

@alimysoyang
Copy link
Author

我说一下我调用的方法,初始化一个AnimatedImageView,如下:
fileprivate lazy var ivMonsterEmoji:AnimatedImageView = {
let imageView:AnimatedImageView = AnimatedImageView(frame: CGRect.zero);
imageView.contentMode = UIViewContentMode.scaleAspectFit;
imageView.isHidden = true;
imageView.autoPlayAnimatedImage = false;
return imageView;
}();

调用远端GIF
self.ivMonsterEmoji.kf_setImage(with:URL(string: String(format: "%@%@/id/%@", BBHelper.kHostName, BBHelper.kHTTPMonsterEmojiUrlPath, emojid)), placeholder: nil, options: [.preloadAllGIFData], progressBlock: nil, completionHandler: {[weak self](image, error, cacheType, imageURL) in
if let strongSelf = self
{
strongSelf.ivMonsterEmoji.isHidden = false;
strongSelf.ivMonsterEmoji.startAnimating();
}
});
后来我测试了一下,发现问题出在“options: [.preloadAllGIFData]”,这个参数,我开始设置的是“options:nil”,这样设置在模拟器上没有任何问题,可以播放GIF,但是在真机上运行就crash了,但是如果我设置成“options: [.preloadAllGIFData]”,又出现一个问题,AnimatedImageView这个里面的方法都不执行了,变成了一个完全的UIImageView的扩展

@onevcat
Copy link
Owner

onevcat commented Sep 28, 2016

Should be resolved in #461 and version 3.1.1. Would you like to confirm it in the latest version? Thanks!

@onevcat onevcat closed this as completed Sep 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants