react / react/react-native

transformOrigin produces incorrect results on android

オープン
#49,286 コメント 3 件 リアクション 8 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

API: Transforms Issue: Author Provided Repro Platform: Android
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

Transforming a view with perspective and transformOrigin to achieve 3d-effects is working perfectly on iOS, but not on android.

This has probably something to do with the normalization of camera perspectives: https://github.com/facebook/react-native/blob/7b7c45030ba6ae196b89f0fb8615d184a261cd4a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java#L599

I would be very thankful for possible workarounds.

Steps to reproduce
  1. Create a RN App using cli or Expo
  2. Add a View which is transformed with origin and perspective

const {width, height} = Dimensions.get('window');

export default function App() {
  return (
    <View
      style={{
        width,
        height,
        backgroundColor: 'red',
        transformOrigin: [0, height / 2, 0],
        transform: [
          {perspective: width},
          {rotateY: '45deg'}],
      }}>
      <Text>test</Text>
    </View>
  );
}```

### React Native Version

0.77.0

### Affected Platforms

Runtime - Android

### Output of `npx react-native info`

```text
System:
  OS: macOS 15.3
  CPU: (14) arm64 Apple M3 Max
  Memory: 101.89 MB / 36.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.4.0
    path: ~/.nodenv/versions/21.4.0/bin/node
  Yarn:
    version: 1.22.21
    path: ~/.nodenv/versions/21.4.0/bin/yarn
  npm:
    version: 10.2.4
    path: ~/.nodenv/versions/21.4.0/bin/npm
  Watchman:
    version: 2024.12.02.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK:
    API Levels:
      - "31"
      - "33"
      - "34"
      - "35"
    Build Tools:
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
    System Images:
      - android-34 | Google APIs ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23726.103.2422.12816248
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /Users/take/.sdkman/candidates/java/current/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.77.0
    wanted: 0.77.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: false
Stacktrace or Logs
no stacktrace
Reproducer

https://snack.expo.dev/TUuheLubQqqLvtaHBxTR8

Screenshots and Videos

iOS: Image android: Image

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

React Native 0.77.0を使用し、リンクされたExpo SnackでAndroidとiOSの差異を再現します。まず、perspectiveの正規化が疑われているReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.javaの599行目付近を調査します。プラットフォーム間で変換結果の挙動を比較します。transformOriginとperspectiveがAndroidで一致する3D結果を生成すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, javascript, react-native
領域
mobile
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。