penfeizhou / APNG4Android

Android animation support for APNG & Animated WebP & Gif & Animated AVIF, High performance
Apache License 2.0
570 stars 75 forks source link

StreamReader > modify skip function logic #184

Closed huiung closed 1 year ago

huiung commented 1 year ago

Hi, While using the library, I thought the behavior of the StreamReader was strange.

Normally, this would be fine because we're fetching resources from remote and then using the glide's disk cache(default). So, If we use disk cache, this will not be a problem because it is through the BytebufferReader.

but, In my case, not use disk cache. The problem is StreamReader's skip function. Java's InputStream define MAX_SKIP_BUFFER_SIZE 2048 as follow

private static final int MAX_SKIP_BUFFER_SIZE = 2048;

In general, the chunk size of the webp images I tested is larger than this. Therefore, it cannot be skipped normally. In this case, the offset is twisted and an exception is thrown, and of course, since it's not an awebp, the handling is handed off to the glide's decoder, but since we're using a RecyclableBufferedInputStream, the end result is a problem.

The modified code references the skip function of streamReader inside glide's defaultImageHeaderParser.

Maybe, https://github.com/penfeizhou/APNG4Android/issues/105 is related to this

huiung commented 1 year ago

@jingpeng I accidentally made a commit with the wrong email domain specified. I'm guessing that's why i wasn't assigned as a contributor, is it possible to do that manually?

jingpeng commented 1 year ago

eh, wrong email address cannot be made a contributor according to Github, may be you need to amend this commit (revert it & commit with correct email address) in new PR

huiung commented 1 year ago

@jingpeng https://github.com/penfeizhou/APNG4Android/pull/189

I created a new PR. Sorry to bother you.

jingpeng commented 1 year ago

189 rebase and merged,now contributors list includes you