Sdwebimage: Feature: Supports WebP/Animated WebP nativally for iOS 14/macOS 11/tvOS 14/watchOS 7 without extra libwebp dependency

Created on 23 Jun 2020  路  3Comments  路  Source: SDWebImage/SDWebImage

New Issue Checklist

Image/IO in iOS 14/macOS 14/tvOS 11/watchOS 7 supports WebP (including Animated WebP) nativally. See full changelog: http://codeworkshop.net/objc-diff/sdkdiffs/ios/14.0/ImageIO.html

It's easy and right time to drop the libwebp for user who set minimun deployment target version to iOS 14+.

ImageIO use hardware-accelerated codec instead of that libwebp (which is written in C and run on CPU), is much faster than the current WebP codecs on iOS 13.

Design

Introduce the new subclass for AWebP: SDImageAWebPCoder. The SDImageWebPCoder naming already been taken by another codec repo maintained by us. So this a new naming.

In the future (2 Years later ?), that SDWebImageWebPCoder repo may be deprecated.

Note: For Static WebP, you don't need to add SDImageAWebPCoder, the SDImageIOCoder already handle those cases.

Usage

For iOS 14+ user, you can use avaiable check to use the native WebP support. For iOS 13-, use the fallback version of libwebp support.

if (@available(iOS 14, macOS 11, tvOS 14, watchOS 7, *)) {
    [SDImageCodersManager.sharedManager addCoder:SDImageAWebPCoder.sharedCoder];
} else {
    [SDImageCodersManager.sharedManager addCoder:SDImageWebPCoder.sharedCoder];
}
ImageIO WebP

All 3 comments

Great News

Seems Apple's ImageIO framework already vendor the libwebp source code:

image

Also, they directly call the libwebp API for decoding:

image

Bad news: confirms that current iOS 14 Beta, does not supports WebP Encoding.

Was this page helpful?
0 / 5 - 0 ratings