Regression: iOS images loaded from filesystem don't respect scaling factor in filename
See original GitHub issueEnvironment
React Native Environment Info: System: OS: macOS High Sierra 10.13.6 CPU: (8) x64 Intel® Core™ i7-8559U CPU @ 2.70GHz Memory: 206.29 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.9.0 - /src/homebrew/bin/node Yarn: 1.9.4 - /src/homebrew/bin/yarn npm: 6.2.0 - /src/homebrew/bin/npm SDKs: iOS SDK: Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0 Android SDK: API Levels: 28 Build Tools: 28.0.2 IDEs: Android Studio: 3.1 AI-173.4907809 Xcode: 10.0/10A255 - /usr/bin/xcodebuild npmPackages: react: 16.6.1 => 16.6.1 react-native: 0.57.5 => 0.57.5
Description
Image assets loaded from the filesystem don’t respect iOS’s image scaling naming convention.
This appears to be a regression of functionality introduced by 998197f444aca06cde0d5258469b3d314f8ea8b9 where [UIImage imageWithContentsOfFile:filePath];
was replaced by [UIImage imageWithData:fileData];
, but that leaves UIKit unable to inspect the filePath
for the presence of @3x
filename suffixes.
Reverting that change locally fixes the issue.
Where this really comes into play is in projects using CodePush where the image assets are loaded from the filesystem (e.g., file:///.../Library/Application%20Support/CodePush/path/to/Image@3x.png
) vs. the bundle included with the application at build time (e.g., file:///var/containers/Bundle/Application/.../path/to/Image@3x.png
) where the filename-based constructor [UIImage imageNamed:imageName];
is used.
Reproducible Demo
CodePush bugs contain references to sample repros: https://github.com/Microsoft/react-native-code-push/issues/1222 https://github.com/Microsoft/react-native-code-push/issues/1276
Let me know if you need any help setting up a repro… although at a minimum if the desired functionality is to always respect iOS’s image scaling filename convention then I feel it should be fairly safe to revert (a portion of) the original change.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:22
- Comments:10 (1 by maintainers)
Top GitHub Comments
We are also having this issue.
This is how it looks in development:
And this is how it looks with code-push
This is a legit issue, we’re currently unable to add CodePush support to our app due to this limitation. 😔