react / react/react-native

Scroll position not maintained after resume on iOS

未关闭
#54,979 5 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

Description

The scroll position of a ScrollView that has been scrolled to the bottom is not maintained on resume after being backgrounded on iOS.

The position appears to be reset to landscape when the device is in portrait. In addition to triggering an unexpected scroll, the layoutMeasurement.height of the scroll event indicate that the device orientation has changed to portrait. However, no corresponding onLayout event is triggered, and the app resumes in landscape.

Initially I thought this was an issue with FlashList but I found that it can be reproduced with ScrollView alone.

Steps to reproduce
  1. Run the Snack on an iPad simulator
  2. Rotate the screen to landscape (app must be fullscreen)
  3. Scroll to the bottom
  4. Background the app
  5. Wait a few seconds
  6. Open the app
  7. See that the ScrollView position has changed
React Native Version

0.83.1

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info
System:
  OS: Linux 6.17 Debian GNU/Linux 13 (trixie) 13 (trixie)
  CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Memory: 11.53 GB / 23.24 GB
  Shell:
    version: "5.9"
    path: /usr/bin/zsh
Binaries:
  Node:
    version: 22.21.0
    path: /usr/bin/node
  Yarn:
    version: 1.22.22
    path: /usr/bin/yarn
  npm:
    version: 10.9.4
    path: /usr/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
IDEs:
  Android Studio: AI-252.27397.103.2522.14514259
Languages:
  Java: Not Found
  Ruby:
    version: 3.0.2
    path: /home/mhoran/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.5
    wanted: 0.81.5
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
Stacktrace or Logs

https://github.com/user-attachments/assets/6cc7ab12-6996-4576-86d3-d9f696875386

MANDATORY Reproducer

https://snack.expo.dev/@mhoran/restless-green-graham-crackers

Screenshots and Videos

No response

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先在 iPad 模拟器上运行必需的 Snack 复现步骤,并按照列出的旋转、滚动、后台运行和恢复步骤操作。将 ScrollView 滚动事件的 layoutMeasurement.height 与设备方向进行比较,并检查恢复期间是否发生 onLayout 事件。重新打开应用后,如果滚动位置保持稳定且方向/布局状态一致,则表示完成。

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

评估

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

把新 issue 发到你的邮箱

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