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

iOS 11兼容性问题 #86

Closed
hao-feng opened this issue Oct 25, 2023 · 19 comments · Fixed by #87
Closed

iOS 11兼容性问题 #86

hao-feng opened this issue Oct 25, 2023 · 19 comments · Fixed by #87
Labels
CGImage The CGImage related stuff HDR HDR 16bit images

Comments

@hao-feng
Copy link

hao-feng commented Oct 25, 2023

iOS 11.3
Xcode 15
libwebp 1.3.2

在这里会报错,导致iOS 11设备无法正常加载webp图片。
8196947#diff-e9c046b25a4d1b5fd2e490c2ebc802f1a63ef0459e0ad74dd3647f72d9c68323R638
Unsupported libwebp preferred CGBitmapInfo: 4357

@dreampiggy
Copy link
Contributor

Have a try with SDWebImageWebPCoder 0.14.0, I'm sure this is a old version issue.

@hao-feng
Copy link
Author

The bug introduced in 0.13.0, and we can still reproduce it in 0.14.0

@dreampiggy
Copy link
Contributor

dreampiggy commented Oct 26, 2023

? I think this is similar to SDWebImage/SDWebImage#3334

Do you means "Only contains issue on iOS 11-, no issue on iOS 12+~iOS 17" ?

@dreampiggy
Copy link
Contributor

Seems Apple old version does not supports the new version's CGImage bitmap combination...Suck

@dreampiggy
Copy link
Contributor

dreampiggy commented Oct 26, 2023

Please provide the runtime return value of [SDImageCoderHelper preferredBitmapInfo:hasAlpha] on that iOS 11 devices.

Using lldb to print the combination (not the raw Int value) of CGBitmapInfo. Or you can step into that [SDImageCoderHelper preferredBitmapInfo:hasAlpha] that call, there are one empty static CGImage here, po that CGImage

I check whether libwebp can nativally support this format

If not, we can add a backup logic, which use CGBitmapContext to draw canvas and CGContextDrawImage on it with RGBA8888 libwebp CGImage

@dreampiggy dreampiggy added the CGImage The CGImage related stuff label Oct 26, 2023
@dreampiggy
Copy link
Contributor

image

Do like this (on your iPhone OS 11 device)

@hao-feng
Copy link
Author

hao-feng commented Oct 26, 2023

(lldb) po cgImage
<CGImage 0x1c43c0c30>
	<<CGColorSpace 0x1c40ac9c0> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)>
		width = 1, height = 1, bpc = 16, bpp = 64, row bytes = 32 
		kCGImageAlphaNoneSkipLast | kCGImageByteOrder16Little | kCGBitmapFloatComponents 
		is mask? No, has mask? No, has matte? No, should interpolate? Yes

@dreampiggy
Copy link
Contributor

dreampiggy commented Oct 26, 2023

The kCGImageByteOrder16Little | kCGBitmapFloatComponents is 16bit RGBA16161616, for HDR image, and 2x bigger (RAM occupy) than normal non-HDR images

Which SDWebImage does not supported yet.

See feature requests SDWebImage/SDWebImage#3553

@dreampiggy
Copy link
Contributor

The better quick workaround is to limit the [SDImageCoderHelper preferredBitmapInfo:hasAlpha] to always return non-HDR images (at least for now)

Or, I update the SDWebImageWebPCoder logic here to ignore HDR image. Because even the decoder product the 16 bit CGImage, on SDWebImage there are logic which strip the HRD away and consume only 8 bit CGImage, which still waste the work decoder done.

@dreampiggy dreampiggy added the HDR HDR 16bit images label Oct 26, 2023
@dreampiggy
Copy link
Contributor

I guess this is Apple's internal changes behavior. The old version UIGraphicsImageRenderer internally use 16 bit on iOS 11, but revert this behavior on iOS 12.

@dreampiggy
Copy link
Contributor

Decide to quick hack to treat this 16 bits as 8 Bits instead. :(

And I totally aggree SDWebImage itself should provide some HDR control, because actually WebP (legacy) does not supports HDR at all, and no need to produce 16 bit CGImage. It should always produce 8 bit CGImage

@hao-feng
Copy link
Author

Decide to quick hack to treat this 16 bits as 8 Bits instead. :(

And I totally aggree SDWebImage itself should provide some HDR control, because actually WebP (legacy) does not supports HDR at all, and no need to produce 16 bit CGImage. It should always produce 8 bit CGImage

Great, after you have a fix, I'm happy to test again

@dreampiggy
Copy link
Contributor

dreampiggy commented Oct 26, 2023

@hao-feng Test now

#87

@hao-feng
Copy link
Author

pod 'SDWebImageWebPCoder', :git => 'github.com/SDWebImage/SDWebImageWebPCoder.git', :commit => 'eeebf2137e96db6211b909891c67112697b9421c'

the imageRef is nil after this
https://github.com/SDWebImage/SDWebImageWebPCoder/pull/87/files#diff-e9c046b25a4d1b5fd2e490c2ebc802f1a63ef0459e0ad74dd3647f72d9c68323R679

@dreampiggy
Copy link
Contributor

dreampiggy commented Oct 26, 2023

Typo. The bitmapInfo create a empty enum and not override the outer one.

@hao-feng Use new commits 74164f9

@hao-feng
Copy link
Author

Typo. The bitmapInfo create a empty enum and not override the outer one.

@hao-feng Use new commits 74164f9

This fix works~

@dreampiggy
Copy link
Contributor

Can I merge it and release a new fix version ? 0.14.1 ?

@hao-feng
Copy link
Author

yes, please

@dreampiggy
Copy link
Contributor

0.14.1 available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CGImage The CGImage related stuff HDR HDR 16bit images
Projects
None yet
2 participants