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
iOS 17/macOS 14 PNG image render wrong by default, only works when disable force decode #3605
Comments
At least, you need to provide a sample URL for reproduction and debug... Also, the issue template should provide the version of SDWebImage and iOS version you used |
@dreampiggy sorry...
iOS: 17.0; SDWebImage: 5.18.1 |
Seems not reproducible in our SDWebImage Demo. I guess it's because your own project's code, for example you use some template image or filter, dark mode (with alpha image) which effect the rendering result. You can compare the rendering result with MacOS or iPhone native Preview.app to see the differences. |
@dreampiggy You need to use iOS 17 debug |
I mean, is this behavior different from Apple's other native App ? Like Photos or Preview, and even on macOS 14 and tvOS 17 If not, it's not SDWebImage's bug, it's Apple's bug, you'd better to fire radar to Apple Give you a simple demo code, without any use of SDWebImage at all let data = Data(url: URL(string: url))!
let image = UIImage(data: data)!
imageView.image = image Is this render issue still not correct ? |
Or you can choose not to use ImageIO (Apple's Image decoder), use the open-source libpng instead. |
Give you the demo and run by yourself, is this behavior different from SDWebImage ? Note the background view use |
I guess this is not bug. The PNG is alpha image so it can blend with the background. I don't think these two render result is different, because You should not use that |
sorry my fault,i tried to download the image using the iOS API, but got a different result from SDWebImage
|
Disable the force decode and try again. Use that "avoidDecodeImage" options (or use new API called context[.forceDecodePolicy] = .never) SDWebImage by default actually just do simple:
I guess this maybe something bug of CoreGraphics I will test again on my demo later. Note: SDWebImage supports file URL as well, so we don't need URLSession or any network, just put that image into App bundle and load via fileURL to compare render result |
thx!!! 👏👏👏 🎉🎉🎉 |
Open currently, seems need to fire radar to Apple or find some way for better workaround. |
Decide to upload this to Apple for radar: |
It seems like there are some bugs in |
Update: It's not bug of UIKit team actually :) It's bug of ImageIO teamThe decoded CGImage contains Wrong BitmapInfo, which store the RGB into pre-multiplied form (which means, each R is actually R * Alpha). It should use the A stupid and shit code quality. |
New Demo codeLeft iOS 16, Right iOS 17The first RGB pixel value is not equal, the iOS 17 one seems Premultiplied the alpha value, which makes each pixel RGB become smaller (or in visible, ligher) |
The alphaInfo shows the CGImage use RGBA8888 and non-premultiplied Check the first pixel value
CompareEach R in iOS 17 is the premultiply result of R in iOS 16. But CGImage still report non-premultiplied
|
Apple still don't reply for this issue. And this Bug exits on iOS 17.2 Beta 1🤮 |
This should be fixed (hacked) by #3634 |
Finally released 5.18.5 @DaoPinWang-git @lyandy Please have a try. This workaround only make all PNG decoded from SDWebImage works, but not using the hook for system SDK, which need Apple to fix. |
upgrade 5.18.5, our debug ipa no problem, but the testflihgt ipa not fix |
|
What's the difference between testflight build ? I means maybe about the real device or simulator Apple may optimize different image format based on Hardware media codec, so make sure you test on the same devices... |
@jiangxiaopeng I guess there are something mismatch between simulator and real device |
You're correct. Use 5.18.9, the final old PR contains typo and only enabled in Debug configuration 😃 |
I have found that if placeholderImage is set, there may still be issues. Could you please help me check the following settings: let URL=URL (string:“ https://user-images.githubusercontent.com/18020236/269165495-6a0069f8-582c-4faf-81ae-49879df63af9.png )! |
It's strange. The image cached on the disk looks normal, but once it's taken out, there will be a problem displaying it let url = URL(string: "https://user-images.githubusercontent.com/18020236/269165495-6a0069f8-582c-4faf-81ae-49879df63af9.png")! |
original image
display image
The text was updated successfully, but these errors were encountered: