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

[Question] Why ReactInstanceManager needs to be initialized on main thread? #786

Open
Kshitij09-sc opened this issue May 16, 2024 · 2 comments

Comments

@Kshitij09-sc
Copy link

Introduction

I noticed ReactInstanceManager methods have @ThreadConfined(UI) and has assertions around same. Wanted to understand why do we need to initialize this on main thread?

Details

https://github.com/facebook/react-native/blob/d94c4c46f27139d68d5303d0dafe106c4c685ea6/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java#L1117

Discussion points

  • Can we move this to background thread and think of other ways of thread confinement and safety?
@cortinico
Copy link
Member

Can you elaborate more?

Specifically in your title you ask:

Why SoLoader needs to be initialized on main thread?

while in the issue body you point to runCreateReactContextOnNewThread. I'm unsure what you'r exactly asking.

@Kshitij09-sc Kshitij09-sc changed the title [Question] Why SoLoader needs to be initialized on main thread? [Question] Why ReactInstanceManager needs to be initialized on main thread? May 23, 2024
@Kshitij09-sc
Copy link
Author

Let's focus this question on ReactInstanceManager. I noticed SoLoader & these classes are somehow linked when it comes to initialization, but to keep it specific, why ReactInstanceManager needs to be initialized on main thread?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants