[iOS][Fabric] Pinch-zoomed ScrollView breaks (position jumps, cannot zoom back out) after its size changes
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 25/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- À l'abandon
- Stack technique
- ios, objective-c, react-native
- Domaine
- mobile
Piste de recherche
Commencez par updateState:oldState: et prepareForRecycle de RCTScrollViewComponentView, puis exécutez l’exemple reproducer-react-native sur iOS. Vérifiez le comportement pendant un zoom et lors d’un redimensionnement ou d’une rotation ; c’est terminé lorsque la position de défilement reste stable et que le contenu peut à nouveau être entièrement dézoomé après les changements de taille.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description
On iOS with the new architecture, a ScrollView with maximumZoomScale > 1 gets into a broken state whenever its size changes while the user is zoomed in (device rotation, or the layout around it changing):
- The scrolled position jumps to a different spot.
- The content can no longer be zoomed all the way back out; it stays stuck against one side or corner.
The only way to recover is to zoom all the way out in the broken state and then resize again (rotate back and forth). After that it works again until the next resize while zoomed.
Cause. RCTScrollViewComponentView returns _containerView from viewForZoomingInScrollView:, so while zoomed in that view carries UIScrollView's scale transform. In updateState:oldState: a content size change does
_containerView.frame = CGRect{RCTCGPointFromPoint(data.contentBoundingRect.origin), contentSize};
...
self->_scrollView.contentSize = contentSize;
- Setting
frameon a view whosetransformis not the identity is undefined behavior per the UIView docs ("If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored"). In practice UIKit shrinks the container'sboundsby the zoom scale, so when the user zooms back out to scale 1 the content is smaller than the scroll view and sits in a corner. contentSizeis set to the unzoomed size whilezoomScale != 1. UIScrollView itself keepscontentSizeat the zoomed size, so the offset is clamped to the wrong range and the position jumps.
The same code is on main today. prepareForRecycle already hints at it: "Invalidate cached content size so that updateState: recalculates the container frame after zoomScale reset (which may have mutated it in RTL)".
Fix: lay the container out through bounds/center and give the scroll view the zoomed content size. PR: https://github.com/react/react-native/pull/58498
Steps to reproduce
- Run the reproducer on an iOS device or simulator (new architecture is on by default).
- Pinch to zoom in (2x or more) and pan somewhere away from the top-left.
- Tap "Resize" (changes the ScrollView's height) or rotate the device.
- The position jumps. Pinch back out: the content stays stuck in a corner and does not fill the ScrollView.
- Zoom out fully, resize again: it recovers.
React Native Version
0.87.1
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
Not run: the reproducer repository is a fresh `reproducer-react-native` template pinned to react-native 0.87.1, run on iOS 18 simulator/device.
Stacktrace or Logs
No crash or log output; the bug is visual.
MANDATORY Reproducer
https://github.com/mifi/reproducer-react-native
Screenshots and Videos
None yet.
- Langage dominant
- C++
- Étoiles
- 127k
- Forks
- 25.3k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de react/react-native
-
Needs: Author Feedback Needs: Repro
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
react/react-native#58659 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Needs: Author Feedback Needs: Repro
Difficulté 1/5 Moins d'une heure Accessibilité débutants 92/100
react/react-native#58621 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Add TypeScript declaration for the performance globalPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. OuverteNeeds: Attention Needs: Repro
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
react/react-native#58610 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Needs: Triage :mag:
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
react/react-native#58565 · 2 commentaires · 2 réactions ·
Les mainteneurs répondent en général sous 1 jour
-
[Android][Fabric] addViewAt hard-crashes on a placeholder ViewState synthesised by updateEventEmitterPeut-être pris @wneel l’a pris il y a 22 jours. OuverteNeeds: Attention Needs: Repro
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
react/react-native#58526 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de react/react-native
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
cataclysmbn/Cataclysm-BN#10516 ·
Les mainteneurs répondent en général sous 1 jour
-
area:runtime good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
WATonomous/wato_f1tenth#39 ·
-
[APP BUG]: Sorting by name after searching can bring up irrelevant resultsPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
shadps4-emu/shadps4-qtlauncher#465 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
duckdb/duckdb-excel#104 ·