react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Images reload every time View is rendered

Open zachgibson opened this issue 10 years ago • 5 comments

Should Images be re-rendering every time an iOS view is changed?

Anytime you dismiss a native controller and come back to your app there's a bit of time where RN Images are not there because they are being loaded again. If you have a lot of Images in the View you're coming back to, the time of seeing no Images increases—note the TabBar icons in the first GIF.

React Native App (Images reload): image-flickers

Native iOS App (Images seem to not reload): image-doesnt-flicker

I tested this with TabBarIOS, logging Image onLoad, each time you switch tabs Images are loading again. Looking at some native apps it seems like once your images are loaded in a view each time you come back to that view the images don't re-render.

I'm running React Native 0.27 on a Mac. I've only seen this on iOS, not sure about Android.

Side note: The first screenshot (my app) is not using TabBarIOS, when using TabBarIOS the TabBar icons do not re-render when swiping back into the app from Safari View Controller.

zachgibson avatar Jun 19 '16 20:06 zachgibson

@facebook-github-bot label iOS

DanielMSchmidt avatar Jun 20 '16 06:06 DanielMSchmidt

@facebook-github-bot label Perf

DanielMSchmidt avatar Jun 20 '16 06:06 DanielMSchmidt

not sure, but maybe you can cache the image/data you're using in that bottom bar because that seems like data that shouldn't need to be reloaded right?

281330 avatar Jun 20 '16 13:06 281330

Adding defaultSource to local images seems to improve it for me.

There's also this commit although I haven't tested it.

samuelkraft avatar Jun 20 '16 14:06 samuelkraft

@samuelkraft defaultSource fixes the local images problem. That commit seems to address this problem too. Thanks for the suggestions!

zachgibson avatar Jun 20 '16 16:06 zachgibson