fresco icon indicating copy to clipboard operation
fresco copied to clipboard

Loading network images to off screen or Gone SimpleDrawees

Open Mithrandir21 opened this issue 11 years ago • 3 comments

I have a FrameLayout with 3 full screen SimpleDraweeView's. I have implemented a touch listener that enables me to swipe left-to-right and right-to-left. The functionality works fine and images load very fast, no issues here. There is always 1 SimpleDraweeView that is set to Visible, while the 2 other SimpleDraweeViews are set to Gone. When swiping to either side, an additional SimpleDraweeView is set to Visible and brought in from the correct side.

_My issue is that when setting the SimpleDraweeView to Visible and bringing it in from the side, the image is not already visible and takes a few ms to load._

I am sure that the ImageRequest is created and called a long time before the 2nd SimpleDraweeView comes into view. (This is guarantied both programmatically and through debugging.) I have also attempted to set the fading-in duration of the SimpleDraweeView to 0, which only makes the image simply appear mid-way through the swipe, which highlights the issue even more.

My thought is that Fresco will not load an image to a SimpleDraweeView that is off-screen or set to Gone. Or there could be some setting I'm not setting correctly.

As per the guideline for contributions:

  • App does not crash.
  • The image is a PNG from Network. Not a GIF.

Under is the code for my ImageRequest (that is guarantied to be performed waaaay before the SimpleDraweeView is on-screen):

ImageRequest request = ImageRequestBuilder
    .newBuilderWithSource(Uri)
    .setProgressiveRenderingEnabled(true)
    .build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
    .setImageRequest(request)
    .setOldController(nextDrawee.getController())
    .build();

nextDrawee.setController(controller);

Mithrandir21 avatar Nov 30 '15 01:11 Mithrandir21

Can you attach or link to a sample application where this is visible/testable?

balazsbalazs avatar Nov 30 '15 09:11 balazsbalazs

issue-gif

As you can see, there is a slight delay before the next image is shown. But the ImageRequest has been executed long before the "Swipe" action is performed.

Mithrandir21 avatar Nov 30 '15 15:11 Mithrandir21

Yes, Fresco does not load images that are not visible. That's by design and greatly reduces the memory usage occupied by the bitmaps. If you explicitly want an image to be loaded even if not visible, prefetch it to the bitmap cache so that it is immediately ready when needed.

plamenko avatar Dec 05 '15 01:12 plamenko