react / react/react-native

[iOS] RCTLogBoxView crashes on dealloc when app uses SceneDelegate because it still assumes AppDelegate.window exists

Đang mở
#56,571 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Debugging Needs: Attention Needs: Repro Platform: iOS
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
  1. Create a React Native app on iOS
  2. Adopt SceneDelegate / UIScene lifecycle
  3. Ensure the app delegate does not expose a window property
  4. Trigger LogBox presentation and dismissal / teardown in development
  5. 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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. 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

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.