software-mansion / software-mansion/react-native-screens
Using react-native-screens and SwiftUI Preview at the same project breaks Preview
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.7k
- Forks
- 713
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 71
Description
Description
When we add a SwiftUI Preview to our project in order to get a preview of a native component, we get an infinite loop of reactNativeScreensChildViewControllerForStatusBarHidden call and preview crashes.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_PROTECTION_FAILURE at 0x000000016b1dffd0
Exception Codes: 0x0000000000000002, 0x000000016b1dffd0
VM Region Info: 0x16b1dffd0 is in 0x1679dc000-0x16b1e0000; bytes after start: 58736592 bytes before end: 47
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
MALLOC_MEDIUM (reserved) 15f800000-160000000 [ 8192K] rw-/rwx SM=NUL ...(unallocated)
GAP OF 0x79dc000 BYTES
---> STACK GUARD 1679dc000-16b1e0000 [ 56.0M] ---/rwx SM=NUL ... for thread 0
Stack 16b1e0000-16b9dc000 [ 8176K] rw-/rwx SM=PRV thread 0
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [18989]
Triggered by Thread: 0
Kernel Triage:
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
VM - pmap_enter retried due to resource shortage
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 UIKitCore 0x1116dc008 -[UIViewController(UIContainerViewControllerProtectedMethods) childViewControllers] + 0
1 PermissionView.1.preview-thunk.dylib 0x126726068 -[UIViewController(RNScreens) findChildRNScreensViewController] + 32
2 FirstWords 0x104b105ec -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 32
3 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
4 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
5 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
6 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
7 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
8 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
9 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
10 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
11 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
12 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
13 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
14 FirstWords 0x104b10630 -[UIViewController(RNScreens) reactNativeScreensChildViewControllerForStatusBarHidden] + 100
Steps to reproduce
- Create a SwiftUI preview for a native view following https://www.swiftjectivec.com/using-xcode-previews-for-uikit/ this tutorial.
- Preview crashes
Screens version
3.17
React Native version
0.68.3
Platforms
iOS
Build type
Debug mode
Device
iOS simulator. Xcode Preview
Acknowledgements
Yes
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the crash with the SwiftUI UIKit preview steps and inspect the native UIViewController(RNScreens) entry points named in the stack trace: reactNativeScreensChildViewControllerForStatusBarHidden and findChildRNScreensViewController. Done means the Xcode Preview no longer recurses through these calls or crashes while normal react-native-screens behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, swift
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100