Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Image] White flickering when changing image #2570

Closed
PhilippKrone opened this issue Sep 6, 2015 · 38 comments
Closed

[Image] White flickering when changing image #2570

PhilippKrone opened this issue Sep 6, 2015 · 38 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@PhilippKrone
Copy link
Contributor

Hi,

I just updated from RN 0.8 to the current master and I'm seeing the following behaviour.

I'm showing images from the local UserDefaultsDirectory and when loading such an image, I see a very fast white flickering (I think while loading the image). This was not the case in RN 0.8. I know that the loading happens async and thus, loading times might occur. But is there any option to not have this white flickering - knowing that perhaps for 1 or 2 FPS, the view is not updated (I would prefer having the old content shown for another 1 or 2 FPS than having old content -> white screen -> new content).

My background is the following: I'm having a card which I "flip" via the Animated API. After the animation is done, I actually have to re-render the screen as otherwise, Touchable buttons are not working correctly (due to still being on the "wrong side" of the card). And while re-rendering, I get a white flickering on the position of the image (although the actual image is the same all the time, I'm rendering it in another Image component that is on the other side of the card).

Thanks
Philipp

@ide
Copy link
Contributor

ide commented Sep 6, 2015

I encountered flickering when switching between tabs when upgrading from 0.9 to master as well. It may have to do with an optimization that removes off-screen images cc @a2

@jsierles
Copy link
Contributor

Did anyone find a workaround for this?

@ghost
Copy link

ghost commented Oct 2, 2015

I see flickering when doing navigator.push to a new view. The images on the previous screen flicker once as the new view slides from the right. Any ideas how to fix this? My issue posted here: #3187

@PhilippKrone
Copy link
Contributor Author

@a2 Do you have any idea here?

@Purii
Copy link
Contributor

Purii commented Oct 15, 2015

I can notice a similar behavior as described by @PhilippKrone

@IlyasM
Copy link

IlyasM commented Dec 4, 2015

I have image flickering when doing tab switching in TabBarIOS on 0.15, any fix yet?

@IlyasM IlyasM unassigned a2 Dec 4, 2015
@Intellicode
Copy link
Contributor

I'm using the images for background purposes and when switching to a new scene using the navigator, it starts rendering the image mid transition. This is unfortunate, and I wouldn't mind waiting 1-2 frames for the transition to start too.

@satya164
Copy link
Contributor

I think it would be better to at least fade in the images.

@eduardoboucas
Copy link

I wonder if the problem I'm having is related to this issue. Is there any successful workaround?

Thanks!

@hasen6
Copy link

hasen6 commented Mar 19, 2016

This thread is closed in favour of #4869 and #4869 is closed in favour of this thread!

This is definitely an issue, I'm experiencing it with switching to any page in NavigatorIOS or Tab bar IOS and back to a page with a background image.

@xvalentino
Copy link
Contributor

I'd like to note that resizeMode being set to 'cover' instead of 'contain' solved one flickering issue when the assets were being loaded for a second time.

However, I experience a flicker when switching between two images, on first load. I expect this is because the image is being decoded on the fly, can anyone think of a way we can decode assets before they are being rendered, so the user won't experience a flash?

@hasen6
Copy link

hasen6 commented May 7, 2016

I'm experiencing flickering on rendering the same image. It re-renders when selected the image does not change. The previously selected image becomes deselected but also does not change image. Every time the image is deselected, it flickers, even though its position has not changed and the image is the same.

Is this every going to be fixed? Its been eight months now since this was raised and I feels its somewhat of a major issue. It makes apps look very unprofessional.

@roman01la
Copy link

We are experiencing the same issue for navigation bar icons when switching between screens using Navigator.

@MichaelDanielTom
Copy link

Just wondering if anything was in the works for this?

In the meantime, I have a somewhat hacky workaround component to switch between 2 images on highlight, which works with resizeMode=contain

Check it out!

@roman01la
Copy link

@MichaelDanielTom We have switched to SVGs. Didn't notice any problems so far.

@hasen6
Copy link

hasen6 commented May 20, 2016

@roman01la That's not really a solution for all though.

@MichaelDanielTom
Copy link

@roman01la I wasn't aware that SVGs were supported, how are you using them exactly, just in an ?

@blakeandrewwood
Copy link

I use a background image for several sequential screens and did the following as a quick fix for each.

    componentWillMount() {
        // "Preload" static image
        (<Image source={require('./background.png')} />);
    }

I know it's another hacky fix, but it helps for the mean time.

@roman01la I'm curious also, how are you using svg?

@roman01la
Copy link

@MichaelDanielTom @blakeandrewwood We are using ReactNativeART package which is included into React Native. This article has examples of rendering SVG.

@juanpujol
Copy link

juanpujol commented Aug 24, 2016

@blakeandrewwood how are you rendering the Image inside the component after doing that with componentWillMount()? Thanks.

@di3goleite
Copy link

@juanpujol you can do something like:

componentWillMount() {
    this.image = (<Image source={require('./background.png')} />);
}

and in your render() function:

render() {
    return(
        <View>
            {this.image}
        </View>
    );
}

@tlcheah2
Copy link

@di3goleite What if the Image component is actually a container to several view?

@ammichael
Copy link

I have a List using images as row background, and my fps drop to 10 while scrolling. Doesn't matter image size, rendering an image slows down the whole app.

@roman01la
Copy link

@ammichael I had this issue before. The problem is that image is scaled at runtime, try to render images in their original resolution (do not scale them at runtime).

@ammichael
Copy link

@roman01la That is interesting! How am I supposed to not scale them at runtime? At first I thought about resizing manually, but this seems wrong in many ways..

@roman01la
Copy link

@ammichael For example if you want to render image at 10x10 points on 2x display, then the image should be exactly 20x20 pixels resolution.

@ammichael
Copy link

@roman01la Yeap. But in this case you have a fixed width and height. I just have a fixed height, since the width is the screen width.

Any suggestion?

@roman01la
Copy link

@ammichael I would recommend to test and find out if scaled images is really the problem. If it it, then you need to figure out how to not scale them.

@nicely
Copy link

nicely commented Nov 6, 2016

Add backgroundColor to your container .I mean body , than problem fixed for me.

@ammichael
Copy link

Guys, for me the fix was resizing all the images to smaller sizes. Some of them was over 2000x2000, and I was using just 500x300 or so

@xvalentino
Copy link
Contributor

@ammichael that makes sense, since the image is larger, it may take a longer time to load.

@MnemosyneMei
Copy link

After resizing all my images, it works well.. Thanks @ammichael .

@manishoo
Copy link

this is not working for me! I'm using react-navigation StackNavigator on iOS (haven't tested for android) and when I swipe back to the previous view, my background image flickers. I have set it to resizeMode: cover

@hramos
Copy link
Contributor

hramos commented Aug 24, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos added the Icebox label Aug 24, 2017
@hramos hramos closed this as completed Aug 24, 2017
@rogerkerse
Copy link
Contributor

I am still struggling with this issue, I have icon that is only 26@x3 on navbar and when I try to show modal, it flickers. resizemode or nothing works.

@marcosmartinez7
Copy link

Same problem here in ios

@dswbx
Copy link

dswbx commented Mar 22, 2018

+1

@StanislavMayorov
Copy link

StanislavMayorov commented Aug 17, 2018

We had the same issue on android devices (RN 0.55.4) when load local asset image first time. We have created component that shows previous source until new source is loaded for android.
https://www.npmjs.com/package/react-native-no-flicker-image

@facebook facebook locked as resolved and limited conversation to collaborators Aug 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests