-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Integrate nightly 0.81.0-nightly-20250521-3cb70bb6a from React Native to React Native Windows.
Go through all these merged PRs:
- Integrate RN Nightly Build 0.80.0-nightly-20250506-3ac16dd6a #14951
- Integrate RN Nightly Build 0.80.0-nightly-20250428-9efcdc091 #14844
- Integrate RN Nightly Build 0.80.0-nightly-20250414-70cdf12c4 #14814
- Integrate RN Nightly Build 0.80.0-nightly-20250331-398ac1f71 #14791
And all other merged Prs in Main branch starting title with "Integrate RN Nightly Build", learn from these PRs and then create a new PR to integrate RN nightly build 0.81.0-nightly-20250521-3cb70bb6a.
Refer this doc for more information on steps to be followed:
- https://github.com/microsoft/react-native-windows/wiki/Integration-Process
- https://github.com/microsoft/react-native-windows/wiki/IntegrationTests
All CI Pipelines should pass in main from the PR, all build should succeed and yarn should also succeed.
Steps to Integrate Changes from Core:
-
Go into react-native-windows Pull Request history and find the last integration. See the range of commits that were added from the last integration.
The commit range with have the format <old commit hash 1>…<old commit hash 2>. Take note of <old commit hash 2>. This will be the <new commit hash 1> value for the integration you are about to complete.
-
Go to react native in npm and find the release with the value <old commit hash 2>. Take note of the date of this release.
-
Find the release one weeks after the release date of <old commit hash 2>. Take note of this date and the hash value associated with the release (the hash value will be the hash after the final
-in the version name). This will be <new commit hash 2>. -
Go to Facebook/react-native and use the <new commit hash 1>…<new commit hash 2> structure to view the commit range for your integration. Browse over this commit history and identify any repository changes that may require new issues to be filed.
Look to see if there were bugs fixed that need to also be fixed in Windows source, API changes, or new constants/object types. If these types of changes pop up, file issues. The issues should contain a link to the Facebook change and an explanation of what change should be made to stay in line with Facebook. Also tag the issue with the "Integration Follow-up" Tag.
Note we don't yet have Fabric or Layout Animation supported, so changes related to these you can ignore and not create issues about.
-
Go to your local copy of react-native-windows. Go to your main branch, and pull in your latest changes from upstream using
git pull upstream main --rebase. -
Checkout a fresh branch and run
yarn. -
Run
yarn integrate-rn <nightly build version>, where the nightly build version is the full version name you got <new commit hash 2> from (example: yarn integrate-rn 0.0.0-20220516-2016-4994b8b5d).We also need to manually check if "@react-native-community/template" is using the lastest matching nightly version. Check npm and see if we are using the correctly nightly in "packages@rnw-scripts\integrate-rn\package.json"
-
Run
npx react-native-platform-override upgrade -
Open source with
code .. -
Walk through conflicts and resolve. Note you'll have to manually search for
>>>>>>>; the conflicts will not show themselves automatically. The strategy here is to go into the Facebook repo and find the commit with the change to that file. See what changes were made and why and then take a look at the current edition of the file in react-native-windows to see if the changes should be applied to the Windows copy. Sometimes the Windows copy of files is a direct copy of the react-native version, other times small sections are changed, other times the entire file is different. In the latter two cases, it may be that the changes should not be merged in because the code sections that had changes don't actually exist in the Windows copy of the file.Typically, if only sections of the file are adjusted for Windows you will see a // [Windows comment around the section alerting you it is a Windows change.
Note: Some>>>>>>instances are intentional such as those in the E2E testing forreact-native-platform-override. Also leave the conflict in flowconfig.windows.conflict. Be careful not to remove these. -
After all conflicts are resolved, run
yarn validate-overrides. -
run
yarn lint:fixand after fixing all linting issues. Push the changes in a new branch. -
Then, run playground locally to do an initial check that RNW and playground are still working.
Commit your changes, add changelog, and create a PR. Make sure PR description matches structure of past integration PR's. Should list out Facebook commit range and link. Should list out and link any issues opened from integration (It's a good idea to start this PR as a Draft first to make sure all our tests pass). -
Run RNtesterApp-Fabric manually and test all funtionalities
Additional Information on Scripts and Packages
integrate-rn
integrate-rn is the script used to integrate a new nightly build of react-native into react-native-windows. The script updates all react-native dependencies to the new nightly build, pulls in source code changes, and runs the react-native-platform-override packages to refresh overrides.
react-native-platform-override
react-native-platform-override is a tool to manage "platform overrides" for out of tree React Native platforms. We use this package to add, update, and remove overrides from react-native-windows. Typically these overrides occur in the JavaScript section of the codebase for sections of code we want to fork from react-native.Run RNtesterApp-Fabric manually and test all funtionalities
Protocols
For integrations, our goal is to fall no more than one month behind the latest nightly build of React Native. In order to prevent falling behind, here are a couple pieces of protocol we like to follow:
- If we are caught up on integrations (i.e. RNW main is using the latest RN nightly build), the dev should integrate the next chunk 7 days later. In other words, when integrations are caught up we should be integrating a one week chunk of RN commits, weekly.
- If we are not caught up on integrations (i.e. RNW main is using a RN nightly build version that is >7 days behind the latest build), the dev should integrate of 14 days (can be less if only behind by 10 days for example). In other words, when integrations are not caught up we should be integrating larger chunks of RN commits. Once an integration is merged, the dev should immediately begin another integration until we are caught up with upstream.
- While working on an integration, the integration should be the devs primary focus until the integration is merged. The longer the time taken to complete an integration the more days we have to catch up on later.
- As a general rule of thumb if an integration is taking a dev longer that 7 days to complete, the dev should send an email to key developers on the team to ask for help and gather ideas. If the integration is taking longer than 10 days to complete, the dev should begin to search for the breaking commit. See below for more information on binary searching for the breaking commit.
- If you encounter an issue caused by code upstream which is breaking Windows behavior, reach out to the React Native maintainers on the Discord channel. Note, sometimes a break from upstream had already been fixed in a more recent RN Nightly build. If this is the case, just extend the integration to that nightly build version.
Searching for a Breaking Commit
When working on an integration, there are some breaks that are hard to track down from debugging the repo alone. If you have been working on an integration for 10 days and cannot find the culprit of an issue, the next step is to begin to track down the offending commit. To do this you will want to use binary search to integrate different nightly builds until you locate the nightly build which introduces the issue. This process can help you debug as the commit range is much smaller and you can concentrate on only the changes made on a particular day.
Troubleshooting
Overriding Files / Errors in ReactCommon
Sometimes upstream will make a change to ReactCommon that breaks the build on Windows. In this case, here are the steps to follow to fork the ReactCommon code and restore it to a working state.
- If the folder
vnext/ReactCommon/TEMP_UntilReactCommonUpdatedoes not exist, add it. - To this directory add the files that are throwing errors during the build. Make sure to include the relative path to those files within the ReactCommon directory to their path inside
TEMP_UntilReactCommonUpdate. - Make the edits to the broken files that are needed to restore the build. Edits should be surrounded by // [Windows #issuenumber ... code ... // Windows] comments to help the next developer.
- Run
yarn validate-overrides; this command should fail and tell you the files that need overrides add to them (should be the same as the list of files you just added toTEMP_UntilReactCommonUpdate). - Use
npx react-native-platform-override add <path_name>to add the overrides. - Create an issue to track the removal of the forked files following fixes upstream. The issue at minimum should have the integration where the override was introduced and the PR from upstream that created the issue. Make sure to link this issue in the override.json and imbedded it into the override file as a comment
- Commit your changes.
- Make a PR upstream to react-native with the required fixes. Link PR to issue tracking forked file removal.
Failing Policheck?
Due to internal tools, please see team OneNote for steps to update binaries if on the RNW team or contact someone from the RNW team
Other Common Errors
Flow
Wrong version of Flow. The config specifies version ^0.207.0 but this is version 0.206.0 x Error detected while running 'flow-check'. This means the integration tool didn't upgrade flow correctly. You'll have to manually search for the old version and replace it with the new version and re-run yarn!
VS Linker Errors
-
Seeing a LNK2019 or LNK2001 Error that looks like this?
EventTarget.obj : error LNK2019: unresolved external symbol "public: class facebook::jsi::Value __thiscall facebook::react::InstanceHandle::getInstanceHandle(class facebook::jsi::Runtime &)const " (?getInstanceHandle@InstanceHandle@react@facebook@@QBE?AVValue@jsi@3@AAVRuntime@53@@Z) referenced in function "public: void __thiscall facebook::react::EventTarget::retain(class facebook::jsi::Runtime &)const " (?retain@EventTarget@react@facebook@@QBEXAAVRuntime@jsi@3@@Z)ShadowNode.obj : error LNK2001: unresolved external symbol "public: class facebook::jsi::Value __thiscall facebook::react::InstanceHandle::getInstanceHandle(class facebook::jsi::Runtime &)const " (?getInstanceHandle@InstanceHandle@react@facebook@@QBE?AVValue@jsi@3@AAVRuntime@53@@Z). This usually means that RN added a file to ReactCommon upstream and we need to add it tovnext\Shared\Shared.vcxitems -
Seeing a LNK2019 or LNK2001 in the Desktop-ReactNative project that looks like this?
react-native-win32.exp(0,0): Error LNK2001: unresolved external symbol "public: virtual void __cdecl facebook::react::Instance::JSCallInvoker::invokeAsync(class std::function<void __cdecl(void)> &&)" (?invokeAsync@JSCallInvoker@Instance@react@facebook@@UEAAX$$QEAV?$function@$$A6AXXZ@std@@@Z). Try copying this portion of the error message?invokeAsync@JSCallInvoker@Instance@react@facebook@@UEAAX$$QEAV?$function@$$A6AXXZ@std@@@Zand adding it to the vnext/Desktop.DLL/react-native-win32.x64.def and vnext/Desktop.DLL/react-native-win32.x86.def files.
JSI Changes
- This integration: Integration 12/1 #12571 pulled in a JSI change that added a method to JSI. These are the step we took to solve it:
- Update node-jsi-api repo (all projects on RNW use the JSI from this repo) https://github.com/microsoft/node-api-jsi. Corresponding PRs: https://github.com/microsoft/node-api-jsi/pull/7/files and https://github.com/microsoft/node-api-jsi/pull/8/files
- Update RNW to use new published node-jsi-api repo
- Update RNW JSI files to include new JSI changes. See: fde6883
- Upgrade RNW JSI_Version to the new version from node-jsi-api repo: 58414e2
Note: This is all from the work Vlad did on this integration, if he's in the office, ask him for help! :)
JSI Change instructions as discussed on 10/16/2024
Steps to take
- See the changes in the https://github.com/facebook/hermes repo
- Assign a version to the change
- Update JSI files in https://github.com/microsoft/hermes-windows/
- Do all required changes to compile with the new and old versions
- Produce a new version of Hermes DLL if needed (changes were done to C API)
- Copy JSI files to https://github.com/microsoft/v8-jsi
- Do all required changes to compile with the new and old versions
- Produce a new version/branch of v8-jsi
- Copy JSI files to https://github.com/microsoft/node-api-jsi
- Make sure that the tests are passing
- Create a PR and new commit
- Update RNW https://github.com/microsoft/react-native-windows/
- Use new version of Hermes
- Use new version of V8-JSI
- Update
node-api-jsicommit number that looks like
<NodeApiJsiCommitHash>83cfef428a97627c9185c73da097e42742de56eb</NodeApiJsiCommitHash> - Update JSI for Chakra
- Update JsiAbi
- Update Jsi for JsiAbi
Supported JSI implementations
- JSI for Node-API
- JSI for V8
- JSI for Chakra
- JSI for JsiAbi
What we can do better in future?
- Keep only JSI for Node-API
- Ask Meta to support JSI versions