facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.1k stars 24.07k forks source link

Image component returns different data between iOS and Android in onLoad prop #45188

Open bohdanprog opened 1 week ago

bohdanprog commented 1 week ago

Description

Hello, I looked at the output of the onLoad function. Can you help me understand why the size differs for the same image between iOS and Android platforms? Image link: https://image-placeholder.com/images/actual-size/75x75.png IOS:

RNImage:ios load PNG image from url with strict size {"source": {"height": 25.333333333333332, "uri": "https://image-placeholder.com/images/actual-size/75x75.png", "width": 25.333333333333332}, "target": 3}

ANDROID:

RNImage:android load PNG image from url with strict size {"source": {"height": 76, "uri": "https://image-placeholder.com/images/actual-size/75x75.png", "width": 76}}

Steps to reproduce

  1. git clone git@github.com:bohdanprog/react-native-image-onLoad-prop.git
  2. cd react-native-image-onLoad-prop
  3. yarn
  4. yarn start
  5. yarn ios

React Native Version

0.75.0-nightly-20240612-fd618819c

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.4.1
  CPU: (11) arm64 Apple M3 Pro
  Memory: 104.17 MB / 18.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.9.0
    path: ~/.nvm/versions/node/v20.9.0/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.1.0
    path: ~/.nvm/versions/node/v20.9.0/bin/npm
  Watchman:
    version: 2024.04.08.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.3 AI-233.14808.21.2331.11709847
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.75.0-nightly-20240611-5b3a32142
    wanted: 0.75.0-nightly-20240611-5b3a32142
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

IOS:

RNImage:ios load PNG image from url with strict size {"source": {"height": 25.333333333333332, "uri": "https://image-placeholder.com/images/actual-size/75x75.png", "width": 25.333333333333332}, "target": 3}

ANDROID:

RNImage:android load PNG image from url with strict size {"source": {"height": 76, "uri": "https://image-placeholder.com/images/actual-size/75x75.png", "width": 76}}

Reproducer

https://github.com/bohdanprog/react-native-image-onLoad-prop

Screenshots and Videos

No response

zhongwuzw commented 1 week ago

@bohdanprog Thanks for the report, I'll create a PR to fix this inconsistent. But it's a breaking change I think :) .