-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Fix: RedBoxes don't always show up after React Native destroys #38997
Commits on Aug 21, 2023
-
Easy: Rename adb logs: Rename old/newPreload() -> old/newStart() (fac…
…ebook#39001) Summary: Pull Request resolved: facebook#39001 Changelog: [Internal] Differential Revision: https://internalfb.com/D48076894 fbshipit-source-id: 670dfa49d9fafebbea43ce77925eb990df0b5b4d
Configuration menu - View commit details
-
Copy full SHA for 6793c42 - Browse repository at this point
Copy the full SHA 6793c42View commit details -
Fix: React Native teardown crashes app
Summary: During React Native teardown, we should stop all React surfaces. Otherwise, the app could crash with this error: ``` 08-06 14:54:08.644 14843 14843 F DEBUG : Abort message: 'xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp:171: function ~Scheduler: assertion failed (surfaceIds.empty() && "Scheduler was destroyed with outstanding Surfaces.")' ``` When can teardown occur? One case: an exception occurs on the NativeModules thread. NOTE: This diff impacts the **new** Bridgeless mode lifecycle methods. Changelog: [Internal] Differential Revision: https://internalfb.com/D47926966 fbshipit-source-id: 60d0aa032c9eecbf7d4b1181c0675d96ea338232
Configuration menu - View commit details
-
Copy full SHA for 7cf3f58 - Browse repository at this point
Copy the full SHA 7cf3f58View commit details -
Fix: React Native reloads after teardown render a "blank screen" (fac…
…ebook#38999) Summary: Pull Request resolved: facebook#38999 After React Native tears down, a RedBox can appear, prompting the user to reload. **Problem:** After React Native reloads, the React Native screen wouldn't show up. **Cause:** ReactContext.onHostResume() wasn't executed. Why: - React Native teardown moves the React manager into the **onHostDestroy()** state. - During initialization, React Native only calls ReactContext.onHostResume(), if the React manager was *already* in the **onHostResume()** state. https://www.internalfb.com/code/fbsource/[f82938c7cc9a0ee722c85c33d1027f326049d37c]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridgeless/ReactHost.java?lines=924-925 **Question:** Why does React Native only call ReactContext.onHostResume(), **if the React manager was already in the onHostResume() state?** In short, we want ReactContext.onHostResume() to be delayed until the user navigates to the first React Native screen. Please read the comments in the code to understand why. ## The fix If we're initializing React Native during a reload, just always call ReactContext.onHostResume(). If React Native is reloading, it seems reasonable to assume that: 1. We must have navigated to a React Native screen in the past, or 2. We must be on a React Native screen. Changelog: [Internal] Differential Revision: https://internalfb.com/D48076895 fbshipit-source-id: df2caeab9a98f543b8479463ada6c8fbdbc046cf
Configuration menu - View commit details
-
Copy full SHA for db9745e - Browse repository at this point
Copy the full SHA db9745eView commit details -
Refactor: Use get/setCurrentActivity in ReactHost (facebook#38998)
Summary: Pull Request resolved: facebook#38998 Instead of using the mActivity reference directly, let's just use getCurrentActivity() and setCurrentActivity(). Changelog: [Internal] Differential Revision: https://internalfb.com/D48076896 fbshipit-source-id: 7a8ab56037429c9221d23cc603d89f0dd883b099
Configuration menu - View commit details
-
Copy full SHA for 5299e5b - Browse repository at this point
Copy the full SHA 5299e5bView commit details -
Fix: RedBoxes don't show up after teardowns (facebook#38997)
Summary: Pull Request resolved: facebook#38997 After React Native gets destroyed (e.g: via an exception), the ReactHost resets its current activity. ## Problem React Native can display RedBoxes after React Native destruction (e.g: in the case of an exception). Displaying RedBoxes requires the current activity, which gets nullified. So, the RedBox might not show up after destruction. ## Changes This diff makes ReactHost keep a track of its last non-null activity in a WeakRef. Then, the DevMenu just uses the last non-null activity to display RedBoxes (and everything else). Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D48076893 fbshipit-source-id: c75f8b8c6e50e62414a4d5acd374af283dda7459
Configuration menu - View commit details
-
Copy full SHA for b7352ee - Browse repository at this point
Copy the full SHA b7352eeView commit details