Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using react-native-screens and SwiftUI Preview at the same project breaks Preview #1602

Open
sercand opened this issue Sep 29, 2022 · 8 comments
Labels
Missing info The user didn't precise the problem enough Missing repro This issue need minimum repro scenario Platform: iOS This issue is specific to iOS

Comments

@sercand
Copy link
Contributor

sercand commented Sep 29, 2022

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

Screens version

3.17

React Native version

0.68.3

Platforms

iOS

Build type

Debug mode

Device

iOS simulator. Xcode Preview

Acknowledgements

Yes

@github-actions github-actions bot added Platform: iOS This issue is specific to iOS Missing repro This issue need minimum repro scenario labels Sep 29, 2022
@github-actions
Copy link

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@github-actions github-actions bot added the Missing info The user didn't precise the problem enough label Sep 29, 2022
@github-actions
Copy link

github-actions bot commented Sep 29, 2022

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Snack or a link to a repository section.

@AndersonVanzo
Copy link

Facing the same problem, did you find any solution?

@sercand
Copy link
Contributor Author

sercand commented Oct 24, 2022

Facing the same problem, did you find any solution?

@AndersonVanzo We decided to split project into different Frameworks and those new frameworks don't have dependency on react-native

@karankalsi
Copy link

We are also facing this issue. Any update on this?

@lilidotshi
Copy link

Also running into this issue with Previews and Xcode 15

@GrandLarseny
Copy link

GrandLarseny commented Jun 21, 2024

This issue is still happening. It is difficult to describe exact steps to reproduce since this is basic functionality with SwiftUI in any iOS project that includes React Native components.

What's happening is that in SwiftUI previews the normal setup for UIKit doesn't happen, so the Objective-C method swizzling in RNScreens causes an infinite loop because findChildRNSScreensViewController , which is called by reactNativeScreensChildViewControllerForStatusBarHidden, always returns nil. What I'd really love is some type of workaround to be able to use SwiftUI previews since that is absolutely the preferred method for development.

@gmantuanrosa
Copy link

Still looking for a solution to this RNScreen issue but I think none will come in place, maybe changing library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing info The user didn't precise the problem enough Missing repro This issue need minimum repro scenario Platform: iOS This issue is specific to iOS
Projects
None yet
Development

No branches or pull requests

6 participants