-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Using Apple's ImageIO on iOS 17 cause APNG pictures flicker abnormally #3697
Comments
Why not try use SDAnimatedImageView ? Also, update SD to the latest version and test both on iOS 16(any 16.x) && 17.3+ iOS 17.0-17.2 has a global PNG decode bug, if you test on this version maybe we can not help
This seems YY does not use ImageIO, it use a copy of libpng (a third part PNG codec) (Maybe because at that time, ImageIO does not support APNG, 7 years ago) Using third party codec is the last choice, because it can not use Hardware Media Decoder to accelerate, which may consume more CPU/Battery so we usually don't (unless we found something buggy and will provide a custom plugin instead. see readme about plugin system) |
tagged as Apple's ImageIO bug currently |
Thanks , I will try. I'm sure iOS 17 has some bug on Apng, because some of my static png in the asset abnormally either. |
Reopen if you tested on iOS 17.3 and it's still broken |
Anyway, SDWebImage's coder is plugin based If you don't want to use Apple's ImageIO, OK. Just see (https://github.com/SDWebImage/SDWebImage/wiki/Coder-Plugin-List) and use libpng(https://github.com/rickytan/libpng-apng) to write a custom coder for APNG, like what YYImage's done. libpng with APNG is not merged into upstream, many many people fork their own and copy the code from Mozilla 😂, even like https://github.com/onevcat/libpng/ |
In history there is a talk to whether SDWebImage org should provide a PNG plugin using But was rejected because we think Apple's media team is good at it. Integrate another codec is bad for both code size and performance. See more:
|
@fuguangxin A stupid way: Use https://github.com/SDWebImage/SDWebImageYYPlugin This wrap a You can use this coder to force load PNG without Apple's ImageIO if you want. var context: [SDWebImageContextOption: AnyObject] = [:]
if url.pathExtension == ".png" {
context[.imageCoder] = SDImageYYCoder.shared // magic here
}
view.sd_setImage(with: url, placeholderImage: nil, options: [], context: context) or you can wrap it as a global coder well, by override the Have a try, if this repo does not work as expected please ping me (2 years after the last update from me?) |
Yes, it's still broken , my device version is 17.3.1 |
It's ok,but need add code like this |
So this is concluded as Apple's Bug ? Should we fix this ? (provide a libpng based codec ?) or update to #3605 A new bug in iOS 17's ImageIO APNG decoder (not SDWebImage's issue) |
I suggest that we can provide a way to solve this problem.Apple has not solved this problem for too long. |
Is there any open-source libpng (A objc/C++/swift wrapper is better) available ? Must support at least CocoaPods package manager (SwiftPM is better) Or can you help for some PR ? Because it's Apple's bug, in most cases, I don't want to waste my time to fix it. Until the Only if there are something like https://github.com/SDWebImage/libwebp-Xcode available for APNG, I can spend days to fix. |
It will take some time any way to integrate APNG. APNG stores each frame in different size and expects that you will position and blend next frame into last one, and do not provide integrated method to do so. Download and apply a APNG patch for libpng and create SPM, or find one, it is easiest part I think:) |
Also libpng itself depends on zlib, so link against Perhaps, integrating libpng may not worth it |
YYImage do the simple thing to add extensions to apng, why not just continue to use that ? You can filter only PNG format and iOS 17.0 (means , buggy version you want to support) use that YYImageDecoder |
THIS IS ACTUALLY THE EASIEST PART. Because I already written at least 5 times of this code, like webp avif bpg. Use a CGcontext as canvas is easy: https://github.com/SDWebImage/SDWebImageWebPCoder/blob/fed1583714dc02489ec69debdaf6fafb1dc0581a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m#L544 But anyway, I still think OS provided codec should handle this, the API (CGImageSourceCreateImageAtIndex) should always return the final one, instead of internal-mixing part of frame |
New Issue Checklist
Issue Info
Issue Description and Steps
YYImage doesn't have this problem。
Behave as follows
https://recite-words.oss-cn-hangzhou.aliyuncs.com/web/tmp/RPReplay_Final1712828721.MP4
The code is as follows
The apng is as follows
https://recite-words.oss-cn-hangzhou.aliyuncs.com/headframe/e592f78bf9cb0ffde9520e02879da7b1.png
The text was updated successfully, but these errors were encountered: