fresco icon indicating copy to clipboard operation
fresco copied to clipboard

onLevelChange gif issue

Open ReginFell opened this issue 11 years ago • 15 comments

Hi! I think you can help me. We are using your awesome library to show jpg/png/gif images with the progress bar. With the jpeg and the png images everything work fine, but when we load gif, onLevelChange callback we get 10000, but the gif is shown after 10-25 seconds. How we can solve this issue?

cdae7426-2f96-11e5-8a50-01f95f54bc9f cdccd024-2f96-11e5-9efd-134532a199e2

ReginFell avatar Jul 21 '15 07:07 ReginFell

Is this an animated or static image? Can you give me the url so that we can test it our end? It sounds like it's taking a long time for the image to load after it is downloaded/retrieved from cache, but I'm not sure why that would be the case.

IanChilds avatar Jul 21 '15 12:07 IanChilds

Animated image.

We are facing this problem with some big gif, for example http://ta-ty-sho.com/wp-content/uploads/2015/04/gifki-gif-animatsia-multfilm-kot-v-sapogakh-i-t.gif

If the gif has cached, it take 1-2 seconds for appearance this gif image, but if it has loaded first time, we have that problem.

We tried to use the callback "onFinalImageSet" to intercept the downloading animation, but it worked after 10-25 seconds after onLevelChange level == 10000

ReginFell avatar Jul 21 '15 13:07 ReginFell

Same issue,after progressBarImage disappear fresco need a short time to show the gif. But after first loaded when gif show again ,it has no delay at all.

real-geekfan avatar Jul 23 '15 03:07 real-geekfan

It looks like this is a bug in Fresco - when we fetch an image from disk cache successfully, we say that the request is 100% completed, when we fact we still need to do the decode. For an animated GIF like the above one, the decode can take a long time, leading to the gap that you notice above.

IanChilds avatar Jul 23 '15 16:07 IanChilds

@IanChilds Do you have a recommendation for how to work around this issue for now?

rf3Studios avatar Jul 26 '15 07:07 rf3Studios

Can you use it in conjunction with the onFinalImageSet callback?

IanChilds avatar Jul 27 '15 08:07 IanChilds

@IanChilds yeah, we try to use it, but have no idea how we can connect onFinalImageSet with ProgressBarDrawable

ReginFell avatar Jul 28 '15 13:07 ReginFell

Don't you have access to the ProgressBarDrawable when you construct your listener for the DraweeController?

IanChilds avatar Jul 28 '15 16:07 IanChilds

Yeah, that is my code that extends GenericDraweeView and override setUri: http://pastebin.com/UhcW0vPw

ReginFell avatar Jul 29 '15 09:07 ReginFell

You need to add a ControllerListener to the DraweeControllerBuilder that overrides onFinalImageSet

IanChilds avatar Jul 29 '15 12:07 IanChilds

I tried this code http://pastebin.com/TAem1tta ProgressBar passed very fast, but the animation appeared after 10-25 seconds

ReginFell avatar Jul 29 '15 12:07 ReginFell

Yeah the problem is that the progress bar gets faded out when the progress is set to 100.

I wonder if it's possible to make this work by setting the progress bar to be the placeholder image too? Can you try that?

IanChilds avatar Jul 29 '15 12:07 IanChilds

We should handle this on the pipeline level. It is hard to estimate the decoding time, but my hunch is that there are two main components here: the size in bytes of the image and the decode queue length (in bytes).

We could make decode producer do some heuristics like: out_progress = f(in_progress, estimated_decode_wait_time) out_progress is the progress that decode producer reports to its parent in_progress is the progress of the child producer (e.g. network fetch progress) f(in_progress, wait_time) could be something like in_progress * 0.9 + exp(-C1 * wait_time) * 0.1. estimated_decode_wait_time could be something like C2 * (total_bytes_in_the_decode_queue_including_the_current_image) There is no optimal solution to this problem, all we can do is to provide an estimate. This is just one idea.

plamenko avatar Aug 05 '15 11:08 plamenko

Have you solved the delay problem? How ?

JiaoShuai avatar Jun 04 '16 16:06 JiaoShuai

I believe this should be solved by da9b7f162bb31f538bda2f34e83ac505f0e67a39.

kirwan avatar Jun 15 '16 06:06 kirwan