duguyihou / react-native-turbo-image

Performant image component for React Native
https://www.npmjs.com/package/react-native-turbo-image
MIT License
167 stars 9 forks source link

bug: urlCache not work smoothly #355

Closed MS0015 closed 2 months ago

MS0015 commented 2 months ago

What's happening?

When I open the app and load the image using a remote URL, I want the image to cache. However, when I kill the app and reopen it, it still shows a gray box instead of the image. In the production build, it flickers with a black box.

Screenshot 2024-09-18 at 6 15 52 PM Screenshot 2024-09-18 at 6 16 12 PM

Reproduceable Code

<TurboImage
          tint={COLOR.GRAY}
          style={{
            position: 'relative',
            width: 22,
            height: 22,
            marginHorizontal: 4,
            ...iconStyle,
          }}
          source={iconSource}
          resizeMode={'contain'}
        />

Relevant log output

no

Device

iPhone xs

TurboImage Version

1.17.2

Can you reproduce this issue in the TurboImage Example app?

No, I cannot reproduce the issue in the Example app

duguyihou commented 2 months ago

Can you provide a reproducer with the urls? If you want to use urlCache, make sure the response of the url has cache-control. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control

MS0015 commented 2 months ago

https://lyrak.fra1.cdn.digitaloceanspaces.com/icons/add-circle.png

duguyihou commented 2 months ago

I modified the code in SuccessScreen, but I cannot reproduce the issue. The url request is only called once. To me, I did not see flicker. Is this the correct way to reproduce it?

import { StyleSheet } from 'react-native';
import React from 'react';
import TurboImage from 'react-native-turbo-image';

const SuccessScreen = () => {
  return (
    <TurboImage
      source={{
        uri: 'https://lyrak.fra1.cdn.digitaloceanspaces.com/icons/add-circle.png',
      }}
      tint="gray"
      style={styles.image}
      resizeMode="contain"
    />
  );
};

export default SuccessScreen;

const styles = StyleSheet.create({
  image: {
    width: 300,
    height: 300,
  },
});

https://github.com/user-attachments/assets/3a8d7d46-7802-40b0-abc9-529858222db3

duguyihou commented 2 months ago

@MS0015

Can you provide a reproducer?

duguyihou commented 2 months ago

closing it since cannot reproduce it.