Sdwebimage: BUG: HEIC encoder does not respect frame duration timing when encoding HEIC sequences; defaults to 0.1sec

Created on 3 Nov 2020  路  9Comments  路  Source: SDWebImage/SDWebImage

New Issue Checklist

Issue Info

Info | Value |
-------------------------|-------------------------------------|
Platform Name | ios
Platform Version |13+
SDWebImage Version | 5.9.4
Integration Method |Swift Package
Xcode Version |Xcode 12.1
Repro rate |all the time (100%)
Repro with our demo prj |not sure
Demo project link |https://github.com/TysonParks/SDWebImageTestingApp

Issue Description and Steps

The HEIC encoder appears to only encode HEIC sequences at 10fps (or with a 0.1sec frame duration).

I mainly just write Swift so it's a little challenging to fully understand all the Obj-C code in this framework but...
maybe this has to do with a (0.1sec) frameDuration limiter like at the bottom of the SDImageIOAnimatedCoder frameDurationAtIndex() method implementation? Perhaps the heic encoder is somehow always receiving a frameDuration value below the frameDuration's (0.011sec) threshold and bumping everything up to 0.1sec?

I wrote a simple testing app that shows how SDWebImage transcoding from GIFs and APNGs with different frame rates successfully maintains frame rates when converting to GIF or APNG, but always converts to HEIC sequences at 10fps.

Many thanks in advance!

https://github.com/TysonParks/SDWebImageTestingApp

ImageIO apple bug heif

All 9 comments

The SDWebImageHEICCoder use Apple's built-in Image/IO framework. And for APNG/GIF they share the similar codebase...Maybe this is some bug because of Image/IO, I'll have a check.

Found the reason: not SDWebImage's issue, but Apple's limit in SDK.

For GIF/APHG, if we provide kCGImagePropertyGIFDelayTime: 10ms, it will actually encode current frame as 10ms.
For HEICS, if we provide kCGImagePropertyHEICSDelayTime: 10ms, it will actually encode current frame as 100s.

Even I try to use the kCGImagePropertyHEICSUnclampedDelayTime instead of kSDCGImagePropertyHEICSDelayTime, the result is the same :(

See: https://developer.apple.com/documentation/imageio/kcgimagepropertygifunclampeddelaytime

Try to de-compile the ImageIO.framework

Thanks for digging into this so quickly!
Okay, I see it's on Apple's end. :(
Yes, I thought that the SD implementations for HEICCoder seemed to be the exact same as the GIF/APNG coders, corresponding to their matching keys, but I thought I might just be missing something when digging through the framework.

Try to de-compile the ImageIO.framework

Is this possible?

Does not found a good way to workaround this. I've fired radar to Apple :(

FB8881566

image

If anyone want to check about this bug, use this demo:

image

Reproduce Demo: ImageIOHEICSEncodeDecodeBug.zip

@TysonParks For now, I suggest you to use the open-source libheif codec solution for HEICS animated image encoding.

We provide a external coder plugin as well: https://github.com/SDWebImage/SDWebImageHEIFCoder

@dreampiggy Thanks for digging further into this! I will test the SDWebImageHEIFCoder today.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

floprr picture floprr  路  4Comments

Ricardo1980 picture Ricardo1980  路  6Comments

MagLiC picture MagLiC  路  3Comments

ku8ar picture ku8ar  路  4Comments

mohacs picture mohacs  路  5Comments