question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Image blinking when changing remote image source

See original GitHub issue

Consider the following case: display preview image from camera. Preview is refreshed every 2 seconds. We get image blinking every 2 seconds when replacing the image source:

class CameraPreview extends Component {
  constructor(props) {
    super(props);
    this.refreshInterval = null;
    this.state = {previewURL: 'http://via.placeholder.com/1280x720'};
  }

  componentDidMount() {
    this.refreshInterval = setInterval(() => {
      const timestamp = new Date().getTime();
      this.setState({previewURL: `http://via.placeholder.com/1280x720?t=${timestamp}`});  
    }, 2000);
  }

  componentDidUnmount() {
    clearInterval(this.refreshInterval);
    this.refreshInterval = null;
  }

  render() {
    return (<FastImage style={styles.previewImage}
      source={{
        uri: this.state.previewURL,
        headers:{ Authorization: 'someAuthToken' },
      }}
    />);
  }
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
jpmazzacommented, Oct 23, 2018

+1

0reactions
alubeckcommented, Jan 17, 2019

Hi there,

just checked out this library here, to get rid of this blinking issue using the built-in <Image> component, but… no success 😦 . The problem issued here still appears… on iOS and anroid. Any advices, thoughts?

Thanks in advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you remove the 'flicker' when switching img src on ...
The reason the flicker happens, by the way, is that changing the background image unloads the current one and then loads in the...
Read more >
Images are flashing when updates by img.src[]=url in Firefox ...
Setting the src attribute of an <img > sporadically causes the blink whether or not the image is pre-cached. Creating two stacked img's...
Read more >
Avoid layout flicker during image load - Mohammed Omer
Sometimes, when you load a web page you see some flickering in the page layout before the image is downloaded and rendered on...
Read more >
371733 - background image flickers on image changes
Issue 371733: background image flickers on image changes · 1. create a div block · 2. using js setInterval() change the background image...
Read more >
ILCE-7RM3 | Help Guide | Anti-flicker Shoot. (still image)
Detects flickering/blinking from artificial light sources such as fluorescent lighting and times the shooting of images to moments when flickering will have ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found