microspaze / FFImageLoading.Maui

FFImageLoading.Maui - Fast & Furious Image Loading for .NET MAUI
MIT License
114 stars 18 forks source link

It seems like the image is being downloaded again rather than loaded from the cache on android #38

Closed YoonYoeungJun closed 4 months ago

YoonYoeungJun commented 4 months ago

Description

hello When using image cache I am using ffimageloading and Devexpress DxCollectionView together to display the product list.

Images are loaded based on URL.

When loading an image from the cache, fade-in is disabled, and when downloading an image to a URL, fade-in is enabled.

When you first load a product, it is processed as a fade-in, and it works normally until a certain number of products are scrolled, but when you load a certain number of images (eg, about 100?) and scroll up again, the loaded images fade in again.

And if you close the app and run it again, the image will be loaded again as a fade-in.

iOS is working normally. Android is strange.

Is it a problem with my settings??

I would like to know how to check where cached images are saved on my phone

my code

private static readonly HttpClient httpClient = new HttpClient(new HttpClientHandler {
    MaxConnectionsPerServer = 10 // 병렬 연결 수 제한
}) {
    Timeout = TimeSpan.FromSeconds(15) // 타임아웃 설정
};
private void InitializeFFImageLoading() {
    // FFImageLoading 설정
    ImageService.Instance.Initialize(new FFImageLoading.Config.Configuration {
        HttpClient = httpClient,
        MaxMemoryCacheSize = 300 * 1024 * 1024, // 50 MB
        TransformPlaceholders = true,
        DownsampleInterpolationMode = FFImageLoading.Work.InterpolationMode.Default,
        BitmapOptimizations = true,
        ClearMemoryCacheOnOutOfMemory = true,
        SchedulerMaxParallelTasks = 4,
        DiskCacheDuration = TimeSpan.FromDays(30),
        FadeAnimationEnabled = true,
        FadeAnimationForCachedImages = false,
        ExecuteCallbacksOnUIThread = false,
        InvalidateLayout = true,
        VerboseLogging = false
    });
}
<ffimageloading:CachedImage
    Grid.Column="0"
    Grid.Row="0"
    ZIndex="9"
    Aspect="AspectFit"
    Margin="0,10,0,0"
    HeightRequest="80"
    WidthRequest="80"
    HorizontalOptions="Center"
    VerticalOptions="Start"
    DownsampleToViewSize="True"
    DownsampleWidth="300"
    DownsampleHeight="300"
    RetryCount="3"
    RetryDelay="300"
    CacheDuration="100"
    TransformPlaceholders="True"
    FadeAnimationDuration="100"
    FadeAnimationEnabled="True"
    FadeAnimationForCachedImages="False"
    LoadingPlaceholder="tp_app_icon.png"
    ErrorPlaceholder="tp_app_icon.png"
    Source="{Binding ProductPhoto, Mode=OneTime}">
    <ffimageloading:CachedImage.Transformations>
        <fftransformations:RoundedTransformation Radius="60"/>
    </ffimageloading:CachedImage.Transformations>
</ffimageloading:CachedImage>

Steps to Reproduce

When you first load a product, it is processed as a fade-in, and it works normally until a certain number of products are scrolled, but when you load a certain number of images (eg, about 100?) and scroll up again, the loaded images fade in again.

And if you close the app and run it again, the image will be loaded again as a fade-in.

Expected Behavior

It seems like the image is being downloaded again rather than loaded from the cache.

Actual Behavior

Basic Information

Reproduction Link / Code

my android app try https://play.google.com/store/apps/details?id=com.gaonsoft.tablepacker&hl=ko-KR

YoonYoeungJun commented 4 months ago

If you scroll toward the top of a product that has already been loaded, the image will be reloaded and the scrolling will become unnatural.

microspaze commented 4 months ago

After researching the original source code, it seems that FadeAnimationForCachedImages configs only apply to the memory cached images but not to disk cached images.

I think It is by design.

Because loaded from memory is much more faster than loaded from disk or url.

So you can not identify whether the disk cache works or not from the fade animation. You can see the image load log in the debug mode from the console window to see if the images are beening reloaded.

YoonYoeungJun commented 4 months ago

Thank you for answer understand