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

console.error: "Image source size {28.666666666666668, 25} does not match loaded image size {28, 25}." #5586

Closed
jasonmerino opened this issue Jan 27, 2016 · 34 comments
Labels
Bug Component: Image Help Wanted :octocat: Issues ideal for external contributors. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@jasonmerino
Copy link

I'm getting this error when loading up the main view of the app I'm working on. I've tracked it down to one of the icon images in the tab bar. The dimensions of the image it's trying to load up is 56px x 50px. The funny thing is that it seems to only be happening on the @2x version of the image. The @3x image doesn't show this issue.

I've tried updating the image and resaving it to the exact size of 56 x 50 to no avail. Not sure if this is an issue with React Native, but figured I'd put it up here since the issue just popped up a couple versions ago when I upgraded the version of React Native.

simulator screen shot jan 27 2016 1 17 14 pm

@facebook-github-bot
Copy link
Contributor

Hey jasonmerino, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

@coderdave
Copy link

I got this error too but only after upgrading to xcode 7.2.1

@jasonmerino
Copy link
Author

So I just got a message from the designer I work with that he has resolved this issue. May have been the way the image was saved initially. Who knows.

Going to leave this open, but as of now, this issue has been resolved on our side.

@RoryCombe
Copy link

I have the same issue. Commenting out the section in RCTConvert.m is a workaround for me at the moment: https://github.com/facebook/react-native/blob/master/React/Base/RCTConvert.m#L914-L918 but obviously that is not a suitable fix and it may have side effects.

@silent-tan
Copy link

anyone fixed that problem? I met the same problem.

@caoyue
Copy link

caoyue commented Mar 3, 2016

I had a image that 57px × 57px for @2x and 85px × 85px for @3x, met the same problem.
Guess that 57/2 != 85/3 cause this problem? so I updated the images to 56px × 56px and 84px × 84px, and it was resolved :)

@pppluto
Copy link

pppluto commented Mar 15, 2016

why this error occured? i got this error in debug but not in release. it's very werid

@geirman
Copy link
Contributor

geirman commented Apr 10, 2016

@facebook-github-bot bugfix

@geirman
Copy link
Contributor

geirman commented Apr 10, 2016

@facebook-github-bot label Help Wanted

@facebook-github-bot
Copy link
Contributor

Hey @jasonmerino, we're a small team and rely on the community to fix issues that don't affect fb apps. If you're sure this is a bug can you send a pull request with a fix?

@facebook-github-bot facebook-github-bot added Help Wanted :octocat: Issues ideal for external contributors. Ran Commands One of our bots successfully processed a command. labels Apr 10, 2016
@joeytat
Copy link

joeytat commented Jul 4, 2016

I've got the same error message and found out this is because my 3x.png image are not exactly thrice the point size.

@donald-jackson
Copy link

Same error for me, only able to get it to work by having exactly 3* and 2* multiples of image sizes.

@fabioruxo
Copy link

fabioruxo commented Nov 24, 2016

Same issue. What solved it for me is having a 3x image that doesn't create a 1x image that has decimals other than .0 or .5 otheriwse RCTConvert will do its math and fail because the actual image does have the decimals in its width or height. It's actually fairly easy: just make sure your 3x image has sides that can be divided by 2 and 3 without causing issues.

@piv199
Copy link

piv199 commented Jan 24, 2017

The same using NavigatorIOS->initalRoute->titleImage. I've just got image from xcode resources and past it to react native project, made reference to the image. And it doesn't display it :( Why it's not automatically resized or why this error is ever shown?

@reactionic27
Copy link

reactionic27 commented Feb 21, 2017

I found this solution.
I've got this issue in Tab Bar icon image.
It was my problem. (home.png(25X25), home@2x.png(50X51), home@3x.png(75X76))
I solved this issue by resizing home@2x.png and home@3x.png file.
This is good result.
25X25, 50X50, 75X75
Hope this helps.
Regards.

@anncatton
Copy link

I've been getting this issue with the thumbImage for a Slider, but all my images are sized with matching ratios: 1x(40x40), 2x(80x80) and 3x(120x120). But my error says the loaded image size is {0,0} so I'm not sure if it's the same as the above issues?
handleslidererror

Anyone else experienced this? It's happened in RN 0.39 and RN 0.44, but occurs only intermittently.

@fabioruxo
Copy link

fabioruxo commented May 17, 2017 via email

@anncatton
Copy link

The error complains about the 2x image, although the size it gives is the 1x dimensions. All 3 are definitely exact multiples - 40, 80 and 120.

@hramos hramos added the Icebox label Jul 20, 2017
@hramos

This comment has been minimized.

@hramos hramos closed this as completed Jul 20, 2017
@melvynkim
Copy link

melvynkim commented Nov 13, 2017

The error complains about the 2x image, although the size it gives is the 1x dimensions. All 3 are definitely exact multiples - 40, 80 and 120.

I had same issue.

to resolve

Remove the original image asset that has filename without @. This means if you have:

  • menu_icon.png
  • menu_icon@1x.png
  • menu_icon@2x.png
  • menu_icon@3x.png

You must remove menu_icon.png.

If you only have:

  • menu_icon.png

Then you can just keep that alone (with no ${img_name}@[1-3].png)

@WhoJave
Copy link

WhoJave commented Nov 17, 2017

@anncatton Have you solved this error ? It occurs only intermittently,too ,My react-native version is 0.49.3

@getaaron
Copy link
Contributor

getaaron commented May 25, 2018

@hramos I still see this issue in React Native 0.55.4. Can we reopen the issue?

@getaaron
Copy link
Contributor

Looks like image may be getting replaced with a 0-sized image here:

https://github.com/facebook/react-native/blob/master/React/Base/RCTConvert.m#L764-L768

Why are we running all images through [UIImage -imageWithCGImage:scale:orientation:]? It seems certain valid, already-scaled images are run obtained from RCTImageFromLocalAssetURL, and then [UIImage -imageWithCGImage:scale:orientation:] is returning nil for some reason?

If I understand this method correctly, images from RCTImageFromLocalAssetURL shouldn't be rescaled through this method anyway.

@hramos hramos reopened this May 26, 2018
@amit2908
Copy link

amit2908 commented Aug 30, 2018

@anncatton how did you managed to solve the issue which is giving {0,0} size of loaded image?

@anncatton
Copy link

@amit2908 I never did find a solution for this issue, but I haven't had time to look at it recently.

@pribeh
Copy link

pribeh commented Sep 6, 2018

@getaaron I'm running into this a bunch right now. Any idea how to resolve this? Have you?

@hramos
Copy link
Contributor

hramos commented Sep 6, 2018

You can resolve this by making sure your 2x and 3x images are exact multiples of the 1x image size.

@pribeh
Copy link

pribeh commented Sep 6, 2018

@hramos thanks. I will make sure to do that.

@getaaron
Copy link
Contributor

getaaron commented Sep 6, 2018

@hramos I don’t think that fixes the part of the issue where some images load as 0,0 sized images

@pribeh
Copy link

pribeh commented Sep 6, 2018

@getaaron that's the error message we're receiving. Perhaps we should create a new issue for this? I'll do some more testing to see if the changes @hramos suggested resolve the issue for us. Are your images all the exact point sizes and the issue still occurs?

@rodrigoelp
Copy link

Following this, does anybody has steps to reproduce?

@Niryo
Copy link

Niryo commented Feb 14, 2019

@anncatton , are you using custom root with the metro bundler?
I have the same problem only in a project with custom root.

@elicwhite
Copy link
Member

The solution to the issue reported by the OP is that the 1x, 2x, and 3x images must be exact multiples of the 1x image.

It seems like the 0,0 sized image error is a separate problem. I'm going to close this as it seems like the original issue is resolved, but feel free to create a new issue for the 0,0 problem.

@rupalpatel0008
Copy link

why this error occured? i got this error in debug but not in release. it's very werid

@MrPluto We are also facing the same issue in debug mode.

@facebook facebook locked as resolved and limited conversation to collaborators Mar 20, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: Image Help Wanted :octocat: Issues ideal for external contributors. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests