TextInput desynchronizes with its native counterpart
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C++
- Star
- 127k
- Fork
- 25.3k
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 4
Mô tả
Description
React TextInput component can go "out of sync" with the native text input widget. The desynchronization can be triggered by quick user interactions. The problem becomes severe when the efficiency of the application code is not perfect; in this case, the user's interactions don't have to be quick to trigger the desynchronization.
The React TextInput component eventually re-synchronizes with its native counterpart, but the user experience and application behavior are affected.
See "Steps to reproduce" for the example and details.
React Native Version
0.71.7
Output of npx react-native info
System:
OS: macOS 13.3
CPU: (12) arm64 Apple M2 Max
Memory: 13.88 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.1/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.1/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.12.0 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2022.2 AI-222.4459.24.2221.9787799
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 18.0.2 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.7 => 0.71.7
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Steps to reproduce
Let's consider the example app, which consists of a TextInput component and a "Clear input" button, which clears the text input. A real-life case would be a chat app with a "Send" button.
This is a Git repository with the MCVE.
- Type something into the text input, for example, "abcd"
- Press "Clear input", but immediately after that type some letter, let's say "e" (it's easier on an emulator, but possible on a physical device too, especially if it has an older CPU)
- Observe the text input content
- Expected content: "e"
- Actual content (if the problem is reproduced): "abcde"
Screen recording:
https://github.com/facebook/react-native/assets/2590174/79249e94-b45a-43c7-a50d-8c17fdbe2e95
If the performance of the application JavaScript code is not-so-good, at step 2. you don't have to type the next letter immediately. If the task in which the TextInput is cleared takes 200 ms, the window to trigger the unexpected behavior will have 200 ms.
You can experiment with the performance implications in the provided MCVE by enabling the "Slow down" switch. It will artificially slow down the render by adding an extra computation.
Screen recording with non-ideal performance:
https://github.com/facebook/react-native/assets/2590174/2bac65c7-623a-4666-a05e-b7d0f289a4e5
Snack, code example, screenshot, or link to a repository
https://github.com/cubuspl42/react-native-TextInput-sync-issue-mcve-1
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với ví dụ tối thiểu có thể tái hiện được được liên kết và thực hiện theo trình tự đã liệt kê: nhập văn bản, xóa ô nhập, sau đó nhập lại ngay lập tức. Tái hiện sự không khớp cả khi có và khi không có độ trễ nhân tạo, rồi lần theo đường dẫn đồng bộ hóa của React Native TextInput. Được xem là hoàn tất khi các giá trị native và giá trị React vẫn nhất quán, đồng thời việc tái hiện không còn cho ra "abcde" thay vì "e".
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- react-native
- Lĩnh vực
- mobile
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100