fix(Worklets): networking in Bundle Mode on some setups#9897
Draft
tjzel wants to merge 1 commit into
Draft
Conversation
Fix the folly/JSI header imports in WorkletsNetworking.mm so they resolve across setups: import folly convert via `react/utils/FollyConvert.h` (adding the React-utils iOS platform header path in the podspec), `jsi/JSIDynamic.h` directly, and `ReactCommon/RCTTurboModule.h` instead of `FBReactNativeSpec`. Drop the now-unused `FBReactNativeSpec` import from WorkletsModule.mm. Also eagerly `require` TurboModuleRegistry in `initializeNetworking` so `globalThis.TurboModules` is populated before it is used.
411587c to
354cdcb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In some setups networking didn't work with Worklets Bundle Mode. I made a few changes to fix it:
WorkletsNetworking.mm— I changed the folly / JSI / TurboModule imports so they resolve across setups where theReact-Core/React-jsi/FBReactNativeSpecmodule prefixes aren't reachable: I now import folly convert viareact/utils/FollyConvert.h,jsi/JSIDynamic.hdirectly, andReactCommon/RCTTurboModule.hinstead ofFBReactNativeSpec.RNWorklets.podspec— I added theReact-utilsiOS platform header path toHEADER_SEARCH_PATHSsoreact/utils/FollyConvert.hresolves.WorkletsModule.mm— I dropped the now-unusedFBReactNativeSpecimport from underWORKLETS_FETCH_PREVIEW_ENABLED.network.native.ts— I added an eagerrequire('react-native/Libraries/TurboModule/TurboModuleRegistry')at the top ofinitializeNetworking. In some setupsglobalThis.TurboModuleswasn't populated yet by the time we read it, so the mock TurboModules were never registered. RequiringTurboModuleRegistryfirst ensures the global is set up before we use it.Test plan
Enable Worklets Bundle Mode and use
fetchfrom a worklet on a setup where networking previously failed:WorkletsNetworkingfetch preview enabled (WORKLETS_FETCH_PREVIEW_ENABLED).WorkletsNetworking.mmnow compiles even where the folly/JSI headers aren't exposed under theReact-Core/React-jsiprefixes.fetch(...)from a Worklet Runtime and confirm the request completes instead of crashing on missing TurboModules.