Images not rendering properly on ios after code-push with resizeMode center
Steps to Reproduce
- React Native Image Component local image which matches resizeMode center
- Install the app from Xcode Production version
- Change the tintColor of the image or change text if you have
- Release using "code-push release-react
ios "
Expected Behavior
Images should render properly as it is in dev version debug mode
Actual Behavior
Images with resizeMode "center" gets resizeMode "cover". I am mentioning "cover" because it matches with it in dev mode.
SCREENSHOTS
After CodePush to Production App - 1 Improper images
After CodePush to Production App - 1 Some proper images - Images representing Views, Comments, Attachments are looking good.
Environment
- react-native-code-push version: 5.2.1
- react-native version: 0.52.0
- iOS/Android/Windows version: iOS version 11.2.6
- Does this reproduce on a debug build or release build? Release
###Notes The App uses this tabbar component in React Navigation For the topbar it uses StackNavigator.
I notice this for resizeMode: "stretch" too. We are using stretch together with capInsets for some shadow assets (on semi transparent views) and it makes the shadow look completely wrong.
Aha, actually I see now that resizeMode: "stretch" is respected but it seems like the capInsets are just gone (which makes the shadow look wrong). Maybe a separate issue.
+1
Hey there!
We haven't forgotten about this issue. We have been doing some internal changes on the way we're executing github support. Are you still having this problem?
Hello, the case I mentioned above: yes! On Mon, 26 Mar 2018 at 23:02, Zakeel M. [email protected] wrote:
Hey there!
We haven't forgotten about this issue. We have been doing some internal changes on the way we're executing github support. Are you still having this problem?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/react-native-code-push/issues/1222#issuecomment-376310545, or mute the thread https://github.com/notifications/unsubscribe-auth/AAK22O5xkrsM_c4RwbZgzo4B7BIb_8qWks5tiVdjgaJpZM4SYeGg .
Hi guys,
Unfortunately I can't reproduce you issue.
There is my App.js:
import React, { Component } from 'react';
import { StyleSheet, Text, View, TouchableOpacity, Image } from 'react-native';
import codePush from "react-native-code-push";
class App extends React.Component {
render() {
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Image
style={{width: 100, height: 100, margin: 20}}
source={require('./1.png')}
resizeMode='cover'
tintColor='#ff00ff'
/>
<Image
style={{width: 100, height: 100, margin: 20}}
source={require('./1.png')}
resizeMode='center'
tintColor='#ff00ff'
/>
<Image
style={{width: 100, height: 100, margin: 20}}
source={require('./1.png')}
resizeMode='stretch'
tintColor='#ff00ff'
capInsets={{left: 15, right: 15, bottom: 15, top: 15}}
/>
<TouchableOpacity
style = {{height: 70, width: 200, backgroundColor: 'green'}}
onPress={() => {
codePush.sync({
updateDialog: true,
installMode: codePush.InstallMode.IMMEDIATE
});
}}>
<Text>Current version: 15</Text>
</TouchableOpacity>
</View>
)
}
}
let codePushOptions = { checkFrequency: codePush.CheckFrequency.MANUAL };
export default App = codePush(codePushOptions)(App);
After codepush release was installed all looks the same as in a binary version:

Would be great if you can create little project which I can use to reproduce
Thanks!
@iTOYS Thanks for the reply. In the case I described above (using a drop shadow image), we use absolute position and unset the width/height like this:
shadow: {
position: "absolute",
top: -18,
left: -20,
bottom: -22,
right: -20,
width: undefined,
height: undefined,
},
with capInsets:
{
top: 22,
left: 24,
bottom: 26,
right: 24,
}
This is probably relevant to the issue, especially unsetting width/height, I should have mentioned it before.
Sorry guys, I doesn't see difference between binary version and codepush. Example project would be helpful!
Sorry, was busy in other projects. I am still facing this issue. @iTOYS It's not possible for me to create a example project for some days. The only difference I see in Code push code is, I am not doing it manually, its done by Default option which is OnAppResume I think. I have updated the screenshots and text also, feel free to ask questions!
Hi @Ashwin-Mothilal I don't have access to new images. CodePush options which i use don't have any affects to styles. I'm waiting project from you :)
Thanks!
I have changed the permissions for the images, you can check it now. Just have a look at it. I will try to give project after this week, working on other production issues.
Noticing this as well. Changing to resizeMode={'contain'} seems to fix it. Most of these were absolutely positioned images. Maybe some data stripped from assets in the bundling/distribution process?
CodePush and plugins doesn't change your code and assets. Could you please download your bundle and compare props values?
https://codepush.azurewebsites.net/updateCheck?deploymentKey=[your-key]&appVersion=[app-version]
Closing this issue for now! I recommend you to wrap all your props values with {}
Thanks!
What if we are not using it as props but using it within the Image style object? Same problem? Also would it not make sense to have the code-push build mimic the behaviour of a normal production build? Production builds work and look just fine with no errors whatsoever.
Same here. I have two separate issueses.
First is a background image for a chat. It had transparency (by mistake) and for some reason it was resized incorrectly. It was zoomed and very low res. iOS had this bug, but android works well.
Second case is a simple png images with capInsets. It looks like it just ignores cap insets at all.
UPD: I actually tried to dig deeper to investigate problem with capInsets and found that in binary build image is not resized before applying capInsets (as it should be), but in codepush version RCTImageView resizes an image for some reason.
UPD2: Ah, i found the source of issue. Image was loaded without respect to screen dencity (x3 on iPhone X) when is loaded from codepush. Loading from local bundle works just fine. Still trying to figure out work-around...
Ok, i figured out the root cause of the issue. When loading images from CodePush bundle it doesn't respect scale factor of the resource. It works well for built-in resources since UIImage can load with right scale factor automatically.
Unfortunately, the only (and dirty) solution is to patch react-native implementation.
In react-native/React/Base/RTCUtils.m patch RCTImageFromLocalAssetURL:
image = [UIImage imageWithData:fileData];
with
CGFloat scale = 1.0;
if ([[imageURL absoluteString] hasSuffix: @"@3x.png"]) {
scale = 3.0;
} else if ([[imageURL absoluteString] hasSuffix: @"@2x.png"]) {
scale = 2.0;
}
image = [UIImage imageWithData:fileData scale: scale];
This will work only for png files.
@itoys should we open this back up?
For sure it should be opened back. Also after digging around image loading it turns out that there are no image caching at all for built-in images on iOS. For example, if app will show series of messages with bubble decorations then build with codepush will load each image again and again. That's really creepy for performance.
