react / react/react-native

Scroll position not maintained after resume on iOS

オープン
#54,979 コメント 5 件 リアクション 2 件 担当者 0 名 GitHub で見る

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

Needs: Triage :mag: Platform: iOS
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、iPadシミュレータで必須のSnack再現手順を実行し、記載されている回転、スクロール、バックグラウンド移行、復帰の手順に従います。ScrollViewのスクロールイベントのlayoutMeasurement.heightをデバイスの向きと比較し、復帰中にonLayoutイベントが発生するか確認します。アプリを再度開いた後もスクロール位置が安定し、向きとレイアウトの状態が一貫していれば完了です。

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

評価

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

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

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