[iOS] App crashes with multiple DateTimePicker modals - UIDatePickerContainerViewController conflicts
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- ios, javascript, react-native
- Lĩnh vực
- mobile
Hướng nghiên cứu
The report names the patch file patches/@react-native-community+datetimepicker+8.4.4.patch but does not identify the source files or tests to change. Read the patch and verify how its method swizzling and cleanup interact with the iOS picker lifecycle. Done means maintainers can reproduce the crash and confirm a reviewed fix prevents it; the issue has had no comment for 242 days.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[iOS] App crashes with multiple DateTimePicker modals - UIDatePickerContainerViewController conflicts
Bug Report
Problem
iOS app crashes when multiple DateTimePicker components are used, particularly when:
- Multiple date pickers exist on the same screen
- Rapid navigation between screens containing date pickers
- Conditional rendering of date picker components
Environment
- Package Version:
@react-native-community/[email protected] - React Native:
0.81.1 - Platform: iOS (iOS 13.0+)
- React:
19.1.0
Expected Behavior
Multiple date pickers should work without conflicts, allowing users to interact with different date/time selectors smoothly.
Actual Behavior
- App crashes when multiple
UIDatePickerContainerViewControllerinstances are presented - UI becomes unresponsive
- Inconsistent modal behavior
- Memory leaks from orphaned containers
Reproduction Steps
- Create multiple
DateTimePickercomponents in a React Native app - Use them on the same screen or navigate rapidly between screens with date pickers
- Trigger multiple date picker modals in succession
- Observe crashes or UI freezing on iOS
Code Example
// This pattern causes issues on iOS
export const CustomDateTimePicker: FC<IDateTimePicker> = ({ mode = 'datetime', onChange, value }) => {
const [visible, setVisible] = useState<boolean>(false);
return Platform.OS === 'ios' ? (
<View>
<DateTimePicker
display="default"
value={new Date(value)}
mode={mode}
onChange={onValueChange}
/>
</View>
) : (
// Android implementation
);
};
Proposed Solution
We've developed a working patch that resolves this issue through:
1. Method Swizzling
Intercepts UIViewController.presentViewController to handle date picker conflicts:
+ (void)initialize {
// Swizzle presentViewController to prevent conflicts
// (Full implementation in attached patch)
}
2. Proactive Cleanup
+ (void)destroyAllDatePickerContainers {
// Recursively finds and dismisses all UIDatePickerContainerViewController instances
// Prevents accumulation of orphaned modals
}
3. Touch Event Handling
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
// Cleanup existing containers before any interaction
[RNDateTimePicker destroyAllDatePickerContainers];
}
Results After Fix
- ✅ Stable operation with multiple date pickers
- ✅ No crashes or UI freezing
- ✅ Proper modal lifecycle management
- ✅ Memory leak prevention
- ✅ Consistent behavior across all usage patterns
Files Included
- Patch File:
patches/@react-native-community+datetimepicker+8.4.4.patch - Full Documentation: Available upon request
Request
We would like this fix to be considered for inclusion in the main package to resolve this critical iOS stability issue. The patch:
- ✅ Is thoroughly tested
- ✅ Uses safe, proven techniques (method swizzling)
- ✅ Has minimal performance impact
- ✅ Maintains full API compatibility
- ✅ Resolves the issue completely
Would the maintainers be open to reviewing this solution for potential integration into the main codebase?
Additional Information
This issue affects many React Native iOS applications using multiple date pickers. The patch provides a robust, production-ready solution that has been tested in real-world scenarios.
Happy to provide additional details, testing results, or adjust the implementation based on maintainer feedback.
- Ngôn ngữ chính
- JavaScript
- Star
- 2.9k
- Fork
- 459
- Merge trung bình
- 4 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc 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.
Issue khác của react-native-datetimepicker/datetimepicker
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
react-native-datetimepicker/datetimepicker#1070 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
-
DateTimePickerAndroid.open() throws "Cannot read property" error on RN 0.78.3 new architectureĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
react-native-datetimepicker/datetimepicker#1047 · 6 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
react-native-datetimepicker/datetimepicker#1046 · 1 bình luận ·
Tất cả issue của react-native-datetimepicker/datetimepicker
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
microsoft/monaco-editor#5575 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
stringify escapes leading digits in pseudo-class arguments (:nth-child(1) becomes :nth-child(\31 ))Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
digitalbazaar/forge#1170 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày