[iOS] RCTLogBoxView crashes on dealloc when app uses SceneDelegate because it still assumes AppDelegate.window exists
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
When using a SceneDelegate-based iOS app lifecycle, React Native crashes in RCTLogBoxView during deallocation because it still accesses RCTSharedApplication().delegate.window.
The following code in RCTLogBoxView is problematic:
- (void)dealloc
{
#if !TARGET_OS_MACCATALYST // sharedApplication.delegate is not available on Mac Catalyst
[RCTSharedApplication().delegate.window makeKeyWindow];
#endif
}
In a SceneDelegate setup, the app’s main window is typically owned by the active UIWindowScene, not exposed as AppDelegate.window. As a result, this code can crash with an unrecognized selector / invalid access depending on how the app delegate is implemented.
This looks like the same broader class of SceneDelegate compatibility issues as other places in React Native that still assume application.delegate.window exists.
Steps to reproduce
- Create a React Native app on iOS
- Adopt SceneDelegate / UIScene lifecycle
- Ensure the app delegate does not expose a window property
- Trigger LogBox presentation and dismissal / teardown in development
- Observe crash when RCTLogBoxView is deallocated
React Native Version
0.83.0
Output of npx @react-native-community/cli info
npx @react-native-community/cli info
Screenshots and Videos
RCTLogBoxView
- (void)dealloc
{
#if !TARGET_OS_MACCATALYST
[RCTSharedApplication().delegate.window makeKeyWindow];
#endif
}
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 bằng cách xác định RCTLogBoxView và đọc implementation dealloc của nó, đặc biệt là việc truy cập RCTSharedApplication().delegate.window. Tái hiện luồng teardown với một app dựa trên SceneDelegate, sau đó xác minh rằng việc dismiss và deallocation LogBox không còn gây crash trong khi hành vi hiện tại vẫn được giữ nguyên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- ios, objective-c, react-native
- Lĩnh vực
- mobile-dev
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 58/100