Repository navigation
Skip static view config verification without native view configs - #60361
meta-codesync[bot] merged 1 commit into
Conversation
chrfalch
left a comment
There was a problem hiding this comment.
Commenting rather than approving since this is still a draft.
One question: getWithFallback_DEPRECATED now calls hasViewManagerConfig, which in bridgeless mode goes through unstable_hasComponent (NativeComponentRegistryUnstable.js). That throws if global.__nativeComponentRegistry__hasComponent isn't registered, where the old path returned null. Since this applies to every bridgeless host without a runtime config provider, it's wider than the verification change the PR describes. Can you confirm the global is always installed in bridgeless mode (and ideally point to where), or guard the call so a missing binding still falls back to null?
|
Every bridgeless host in this repository installs it before running JavaScript:
Development builds already depend on it: |
4064e8d to
5e3c6b6
Compare
chrfalch
left a comment
There was a problem hiding this comment.
Thanks for the update, LGTM.
| global.RN$Bridgeless === true && | ||
| global.RN$LegacyInterop_UIManager_getConstants == null | ||
| ) { | ||
| return viewConfig; |
There was a problem hiding this comment.
Maybe add a warnOnce in development? verify was enabled but legacy interop is disabled.
There was a problem hiding this comment.
Good idea, added a dev-only warnOnce in f416ed4 when verify is enabled without the legacy view config interop binding, along with unit tests covering dev and non-dev behavior.
A bridgeless host that sets `setRuntimeConfigProvider(() => ({native: false, verify: true}))` and has no legacy view config interop binding logs a `console.error` the first time each native component is used:
[ReactNative Architecture][JS] 'getViewManagerConfig('RCTView')' is not available in the new React Native architecture. ...
Verification compares a component's static view config with its native one. In bridgeless mode, `UIManager.getViewManagerConfig` reads native view configs from `global.RN$LegacyInterop_UIManager_getConstants`. Native installs that binding only when `useNativeViewConfigsInBridgelessMode` is on, and an iOS build with `RCT_REMOVE_LEGACY_COMPONENT_INTEROP` never installs it. Without the binding, the call logs the error and returns null for every component, and verification then does nothing.
The flag is off in `ReactNativeFeatureFlagsDefaults`. The stock entry points turn it on (`RCTReactNativeFactory` on iOS, the new architecture defaults on Android), so RNTester as shipped is affected only when it is built with `RCT_REMOVE_LEGACY_COMPONENT_INTEROP`.
`NativeComponentRegistry.get` now skips verification when the binding is absent, logging a single `warnOnce` warning in development instead of a per-component error.
`getWithFallback_DEPRECATED` reaches the same error another way. With no runtime config provider set, it checks that a component exists with `getViewManagerConfig(name) != null`, which logs the error and returns the fallback for a component that exists. It now calls `hasViewManagerConfig(name)`, which is the same null check on the old architecture and asks the native component registry in bridgeless mode. That query throws if `global.__nativeComponentRegistry__hasComponent` is missing; every bridgeless host installs it before running JavaScript.
Signed-off-by: James Ide <ide@expo.dev>
5e3c6b6 to
f416ed4
Compare
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D135948468. |
christophpurrer
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
|
This pull request was successfully merged by @ide in 1db1ee7 When will my fix make it into a release? | How to file a pick request? |
Summary:
A bridgeless host can turn on static view config verification with
NativeComponentRegistry.setRuntimeConfigProvider(() => ({native: false, verify: true})). If the host has no legacy view config interop binding, each native component then logs aconsole.errorthe first time it is used:In bridgeless mode,
UIManager.getViewManagerConfigreads native view configs from the bindingglobal.RN$LegacyInterop_UIManager_getConstants. Without it, the call logs the error above and returns null, so verification does nothing. The binding is absent when:useNativeViewConfigsInBridgelessModeis off. It is off inReactNativeFeatureFlagsDefaults; the stock entry points turn it on (RCTReactNativeFactoryon iOS,ReactNativeNewArchitectureFeatureFlagsDefaultson Android), so this affects hosts that set up feature flags another way.RCT_REMOVE_LEGACY_COMPONENT_INTEROP, which compiles the binding out (RCTInstance.mm). RNTester, which turns verification on in bridgeless development builds, logs these errors only in that case.NativeComponentRegistry.getnow skips verification when the binding is absent. Nothing was verified in that case, so the only change is that the errors stop.getWithFallback_DEPRECATED, with no runtime config provider set, checks that a component exists withgetViewManagerConfig(name) != null, which without the binding logs the error and returns the fallback for a component that exists. It now callshasViewManagerConfig(name): the same null check on the old architecture, and a query of the native component registry in bridgeless mode. That query throws ifglobal.__nativeComponentRegistry__hasComponentis missing (NativeComponentRegistryUnstable.js), so the change reaches every bridgeless host; every host here installs it before running JavaScript (RCTInstance.mm,ComponentNameResolverBindingon Android,ReactHost.cppinReactCxxPlatform); development builds already callhasViewManagerConfigwhenAppContainer-dev.jsloadsDebuggingOverlay.js.Changelog:
[GENERAL] [FIXED] - Stop logging a
getViewManagerConfigerror for every component when static view config verification is on in bridgeless mode, and stopgetWithFallback_DEPRECATEDfrom returning the fallback for a registered component thereTest Plan:
NativeComponentRegistry-test.jsis new. WithNativeComponentRegistry.jsfrommain, the case for bridgeless mode without the binding fails (verification requests the native view config), and so does thegetWithFallback_DEPRECATEDcase (it returns the fallback for a registered component). Replacing either half of the new condition (global.RN$Bridgeless === true, or the check forglobal.RN$LegacyInterop_UIManager_getConstants) withtruefails the case that covers it. The tests set or remove the binding themselves.These pass, as do Flow, ESLint and Prettier. Not run: an app without the binding.