react / react/react-native

100% height does not match window height on some devices.

未关闭
#42,050 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Issue: Author Provided Repro Needs: Triage :mag:
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

Description

The height obtained from useWindowDimensions() and the height provided by "onLayout" when the style is "height: 100%" is not consistent on some Android devices. I have specifically seen this on the Nexus 4 and Nexus 5X devices. When the same code runs on the Pixel 6, it provide consistent results out to many decimal places.

Steps to reproduce
  1. Clone this project: HeightBug (github) (based on the standard new tempate-- only App.tsx differs)
  2. Run it on a Pixel 6 (emulator, API 33). See that it reports similar numbers
  3. Run it on a Nexus 4 (emulator, API 33). See that it does dissimilar numbers (616, and 592 for me).
React Native Version

0.73.1

Affected Platforms

Runtime - Android

Output of npx react-native info
info Fetching system and libraries information...
System:
  OS: macOS 14.2
  CPU: (10) arm64 Apple M1 Max
  Memory: 79.38 MB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.16.1
    path: ~/.nvm/versions/node/v18.16.1/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v18.16.1/bin/yarn
  npm:
    version: 9.5.1
    path: ~/.nvm/versions/node/v18.16.1/bin/npm
  Watchman:
    version: 2023.07.03.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.0
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK:
    API Levels:
      - "29"
      - "33"
      - "34"
    Build Tools:
      - 29.0.2
      - 30.0.3
      - 33.0.0
      - 34.0.0
    System Images:
      - android-21 | Google APIs ARM 64 v8a
      - android-23 | ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 20.0.1
    path: /Users/dcorbin/.jenv/shims/javac
  Ruby:
    version: 3.1.0
    path: /Users/dcorbin/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.1
    wanted: 0.73.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false
Stacktrace or Logs
There is no crash.
Reproducer

https://github.com/dcorbin/rnHeightBug

Screenshots and Videos

Nexus4Api33

Pixel6API33

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 rnHeightBug 复现器开始,在 Pixel 6 和 Nexus 4 API 33 配置上,对样式设置为 height: 100% 的视图,将 useWindowDimensions() 与 onLayout 的结果进行比较。检查涉及这些测量的 React Native 0.73.1 Android 布局行为。当受影响设备上报告的高度保持一致,且不改变复现器预期的布局时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, react-native
领域
mobile-dev
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。