Commit Graph

3568 Commits

Author SHA1 Message Date
Andrew Coates 138c88c7da Fix warnings around mixing int and size_t usage in unsafe ways (#34889)
Summary:
react-native-windows builds treat a lot of c++ compiler warnings as errors.  Including ones that cause value truncation when assigning `size_t` values to an `int`.

This fixes the compiler warning, by using `size_t` as the type for `i`, which matches `size`.  I then modified the loop to avoid the value underflow that occurs when decrementing an unsigned zero value.

## Changelog
[Internal] [Changed] - Fix compiler warnings around mixing int and size_t usage in unsafe ways

Pull Request resolved: https://github.com/facebook/react-native/pull/34889

Test Plan: This code change was made in react-native-windows when integrating latest react-native changes.  -- our fabric implementation was able to run through this code without any issues.

Reviewed By: mdvacca

Differential Revision: D40158306

Pulled By: rozele

fbshipit-source-id: b6858cb953635b37fd63a88ed1a372eb3dc394f7
2022-10-06 16:25:44 -07:00
Samuel Susla 0857238633 Pass didUserCallbackTimeout argument to Scheduler's callback
Summary:
changelog: [internal]

RuntimeScheduler's callbacks previously did not pass down argument `didUserCallbackTimeout`. This was intentionally left out because React team intended to remove it. But, as it turns out, it was not removed and it is needed for Offscreen to not enter infinite render loop. In React, it is used here: https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactFiberWorkLoop.new.js#L1022-L1028

Reviewed By: ryancat

Differential Revision: D40060377

fbshipit-source-id: c45719fbbd0275ab2bcf9a2bbf0191aaa96010cc
2022-10-05 10:35:33 -07:00
Héctor Ramos 2a21d5a28e Exclude Hermes debugger in release builds
Summary:
Fixes Xcode release builds when Hermes is enabled.

The Hermes debugger is loaded by the Hermes executor only if HERMES_ENABLE_DEBUGGER is defined. The hermes-engine Pod would set `HERMES_ENABLE_DEBUGGER=0` in release builds, but of course this would satisfy the HERMES_ENABLE_DEBUGGER ifdef check, leading to build time issues due to missing `hermes::debugger` symbols.

Now, both the `hermes-engine` and `React-hermes` pods only set `HERMES_ENABLE_DEBUGGER=1` in debug builds. No gcc preprocessor definition is added by these pods in release builds.

Changelog:
[iOS] [Changed] - Do not load Hermes inspector in release builds

Reviewed By: cipolleschi

Differential Revision: D40077503

fbshipit-source-id: dd9ce148e8521fc4e43e47e90f29ba8f7c9b7e4a
2022-10-05 09:19:05 -07:00
Ruslan Shestopalyuk aa5d43fe54 Merge enablePropIteratorSetter flags into a single one in CoreFeatures (#34869)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34869

Changelog: [Internal]

This merges all instances of `enablePropIteratorSetter` into a single one.

Both `AccesibilityProps` and `BaseTextProps` had their own instances if it, which is now redundant.

Reviewed By: cipolleschi

Differential Revision: D40062555

fbshipit-source-id: b6ccf5a9538612dd731a6f9c4eaceeebcb6d95be
2022-10-05 05:09:37 -07:00
Gabriel Donadel Dall'Agnol 530dae8a45 chore: rename hermes-inspector-msggen to @react-native/hermes-inspector-msggen (#34850)
Summary:
This PR renames ` hermes-inspector-msggen` to `react-native/hermes-inspector-msggen`, moves it to  `packages/hermes-inspector-msggen` and makes the package private  as part of RFC480.

Related to https://github.com/facebook/react-native/issues/34692

## Changelog

[General] [Changed] - Move and rename `hermes-inspector-msggen` to `react-native/hermes-inspector-msggen`

Pull Request resolved: https://github.com/facebook/react-native/pull/34850

Test Plan: run `sh ReactCommon/hermes/inspector/tools/run_msggen`

Reviewed By: mattbfb

Differential Revision: D40060406

Pulled By: cortinico

fbshipit-source-id: e018fd88e8374a69fbd8737fbb9abe7565d4a003
2022-10-05 03:57:08 -07:00
Pearce Liang 108c876206 Fix comment typo 'layed out' to 'laid out' (#1061)
Summary:
Just a simple typo fix.

X-link: https://github.com/facebook/yoga/pull/1061

Reviewed By: javache

Differential Revision: D40059940

Pulled By: javache

fbshipit-source-id: 052a4a8fe80ff49e059a3096500dbe5bddcb73db
2022-10-04 10:54:16 -07:00
Lorenzo Sciandra 232e4474e6 chore: re-align version to be 1000.0.0 on main everywhere (#34817)
Summary:
While working on https://github.com/facebook/react-native/pull/34513 I noticed that on main branch the versioning is not really consistent everywhere. So this PR is an attempt at realigning so that on the main branch, RN is 1000.0.0 everywhere - in a way, it's cleaning up the room for the monorepo work to go flawlessly).

It's just a pass of `node scripts/set-rn-version.js --to-version 1000.0.0`.

There's the small chance that some versions where kept to 0.0.0 on purpose (build tools are weird), so we might just have to close this off. No big deal :)

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal] [Changed] -  re-align version to be 1000.0.0 on main everywhere

Pull Request resolved: https://github.com/facebook/react-native/pull/34817

Test Plan: CI is green and when imported, nothing breaks.

Reviewed By: cortinico

Differential Revision: D39926953

Pulled By: cortinico

fbshipit-source-id: ff66530382f891e17c00b35edf97c03591b6a9a8
2022-10-04 08:36:21 -07:00
Yannic Bonenberger 793ebf6812 Re-add support for using Yoga without exceptions (#1006)
Summary:
This is a partial rollback of 07c0d539bdb3a248762d0a06fd3f622b278a7ecb.

X-link: https://github.com/facebook/yoga/pull/1006

Reviewed By: yungsters

Differential Revision: D40032544

Pulled By: yungsters

fbshipit-source-id: 9ef9b80672eced86a98cfae66c81710bd3ee6f9b
2022-10-03 23:35:46 -07:00
Yurii Nakonechnyi c1363984f1 Added suppression for warnings about unused parameters in 'publish<Type E>()' func (#1141)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1141

Reviewed By: yungsters

Differential Revision: D40025354

Pulled By: yungsters

fbshipit-source-id: 6eaaa77b71db95ab0dbc0a4f459c9d85f7e36c42
2022-10-03 22:04:06 -07:00
DaeWook, Kim d9a5c66baa Export YGInteropSetLogger method (#960)
Summary:
When building and using C # libraries,
EntryPointNotFoundException thrown from YGInteropSetLogger.

so, I added YOGA_EXPORT on YGInteropSetLogger.

X-link: https://github.com/facebook/yoga/pull/960

Reviewed By: yungsters

Differential Revision: D40027238

Pulled By: yungsters

fbshipit-source-id: 6af584a16e66a31c91374a1bb64434888762e3c8
2022-10-03 21:26:05 -07:00
迷渡 619d115822 fix missing dll exports (#1127)
Summary:
When I use libyogacore.so in other programming languages, it crash with message as

> Could not obtain symbol from the library: dlsym(0x20b84d220, YGConfigIsExperimentalFeatureEnabled): symbol not found

This function is defined as `WIN_EXPORT bool YGConfigIsExperimentalFeatureEnabled` in yoga.h, but is not defined using `YOGA_EXPORT` in yoga.cpp.

X-link: https://github.com/facebook/yoga/pull/1127

Reviewed By: yungsters

Differential Revision: D40024450

Pulled By: yungsters

fbshipit-source-id: f6f01eadccb13d593c68300059e96f4b0bbc9fb6
2022-10-03 21:09:58 -07:00
Ruslan Shestopalyuk 00458637da Add Mapbuffer module to podspec (#34847)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34847

This fixes a missing intra-module dependency inside RN renderer core.

Changelog:
[iOS][Fixed] - Add missing react/renderer/mapbuffer module to podspec

Reviewed By: dmytrorykun

Differential Revision: D40020363

fbshipit-source-id: 5e9f3baab76536f1689f0aa5750fdb5a44d28942
2022-10-03 09:42:45 -07:00
Ruslan Shestopalyuk 9864586b21 Factor out feature flags for RN Fabric core
Summary:
A follow up to D38708718 (https://github.com/facebook/react-native/commit/403fea25f65a38f4b4d8e0edcf89741b29e62059) review, this factors feature flags for Fabric core code into a separate file, `CoreFeatures`.

Keeping them together is arguably better for maintenance and makes code easier to reason about.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D40007784

fbshipit-source-id: 1885d5d6200575c6015f063d8b05813b18b47ffb
2022-10-03 05:38:31 -07:00
Ruslan Shestopalyuk 110b191b14 Refactor ViewPropsMapBuffer -> general MapBuffer props mechanism
Summary:
Previously, ViewPropsMapBuffer conversions were hardcoded deep in Android infrastructrue. I've generalized this into a different mechanism to allow any Props struct to support MapBuffer props.

There are still some things that need to be cleaned up and this should be treated as experimental. One thing we likely want to do is remove the hardcoded IDs (fine for codegen'd code; less so for handwritten) and use compile-time-hashed IDs instead with human-readable string names.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D38708719

fbshipit-source-id: 64603dee7f21828be31346c555d99862dab304ea
2022-10-03 04:11:02 -07:00
Ruslan Shestopalyuk 2319f75c8e Support iterator-style prop parsing in ImageProps
Summary:
Support iterator-style prop parsing in ImageProps

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D38834100

fbshipit-source-id: 69274595cca8e6f40cd5e0ad9aac1582f57acc61
2022-10-02 03:38:07 -07:00
Ruslan Shestopalyuk 4766755420 Support iterator-style prop parsing in ParagraphProps
Summary:
Support iterator-style prop parsing in ParagraphProps

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D38833627

fbshipit-source-id: 31eac4e86c5855bb47f634da7cffaf2418273a36
2022-10-02 03:38:07 -07:00
Ruslan Shestopalyuk 7de2b6b415 Support iterator-style PropParsing for AndroidTextInput
Summary:
Support iterator-style PropParsing for AndroidTextInput

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D38833510

fbshipit-source-id: 4f424579a41e70fbe8c0eba430bd435dc60bfc04
2022-10-02 03:38:07 -07:00
Ruslan Shestopalyuk 403fea25f6 Refactor MapBuffer experimental setup: use one config for all Props, with a Trait to indicate support
Summary:
Instead of having a special flag just for View MapBuffer props, we now use one flag to indicate that MapBuffer should be used for all props; each XShadowNode must set a special trait indicating if that ShadowNode supports MapBuffer props.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D38708718

fbshipit-source-id: b398ec62a0db9c0ff23c0007c5503cf2838c4173
2022-10-02 02:46:25 -07:00
Nick Gerleman 87e7912b95 Add YGGutter Enum
Summary:
This adds the YGGutter enum, used to choose between row/column gap variants (row-gap, column-gap, gap).

This used later in changes from https://github.com/facebook/yoga/pull/1116, in the APIs which deal with setting gap on style on yoga node.

Note the original PR called this `YGGap`, but this ending up leading to a couple public method signatures that could appear ambiguous:
1. `SetGap(YGGap gap, float gapLength)`: Enums like `YGAlign` are the vaues for an `align` prop. `YGGap` controls the variant of the gap (like `YGEdge` does for left/right/top/bottom variants). So the enum reads as if it is the `gapValue`, and it looks like we have two of the same parameter.
2. `SetGap(YGGap gapDirection, float gap)`: This is misleading, because the direction gaps flow is the cross-axis of flex-direction.
3. `GetGap(YGGap gap)`: `gap` is the variant, but looks like an out param.

The [CSS Box Alignment](https://www.w3.org/TR/css-align-3/#column-row-gap) spec refers to these gaps as "Gutters", which removes the ambiguity.

Changelog:
[General][Added] - Add YGGutter Enum

Reviewed By: yungsters

Differential Revision: D39922412

fbshipit-source-id: 4b0baf800fecb3d03560a4267c7fb4c4330fd39e
2022-09-29 22:25:24 -07:00
Nick Gerleman 5f9689a0d0 Fixup Enum Generator
Summary:
https://github.com/facebook/yoga/pull/1116 adds a new enum. The enum generator is out of date with copyright header, and some codemods, but it also looks like there were manual changes, types added, etc since generation. I fixed up the script to incorporate generating the changes folks made manually, and also added an enum that was previously only added manually to the C ABI.

Changelog:
[General][Fixed] - Fixup Yoga Enum Generator

Reviewed By: yungsters

Differential Revision: D39922252

fbshipit-source-id: b678fa9a43a896873d8c434745bdaf3f16fd991f
2022-09-29 22:25:24 -07:00
Nicola Corti 427ce5f2d2 Expose folly flags and make folly_runtime available to be consumed via prefab
Summary:
This removes the old way of consuming `libfolly_runtime.so` from
`Android-prebuilt.cmake` to using Prefab which is natively supported
by the Android pipeline.

Moreover, I've exposed a `folly-flags.cmake` file which can be used by libraries
to know which lists of flags they need to use for Folly.

Changelog:
[Internal] [Changed] - Move `folly_runtime` to be consumed via prefab

Reviewed By: cipolleschi

Differential Revision: D39928571

fbshipit-source-id: 4864c37813ec681a6a464c97de6dfc078f5553f1
2022-09-29 07:44:56 -07:00
Nick Gerleman bf05df1723 Remove flexlayout from react-native
Summary: We have decided not to go forward yet with using flexlayout in react-native. This change removes it for now.

Reviewed By: JTYim

Differential Revision: D39822037

fbshipit-source-id: 726e8657b62e6b4e55e5f72be3ca5539d317348e
2022-09-27 07:46:55 -07:00
Tim Yung 63903af1f1 msggen: Dependencies Cleanup (#34782)
Summary:
Cleans up the dependencies in `ReactCommon/hermes/inspector/tools/msggen` by

- Analyzing and removing any dependencies that are never referenced.
- Upgrading all dependencies to their latest versions (by deleting `yarn.lock` and re-running `yarn`).
  - I only upgraded Babel dependencies to the same version used by the rest of `react-native`.

Notably, this resolves 13 vulnerabilities reported by Dependabot.

## Changelog

[Internal]

Pull Request resolved: https://github.com/facebook/react-native/pull/34782

Test Plan:
Ran the following successfully:

```
$ cd ReactCommon/hermes/inspector/tools/msggen
$ yarn
$ yarn test
$ yarn build
```

Reviewed By: cortinico, cipolleschi

Differential Revision: D39804478

fbshipit-source-id: c673e80b64fcf49c3f903c5d7f0a68c77d63a4bd
2022-09-26 07:43:13 -07:00
Tim Yung 5d2a400e99 JS: Update Flow Definitions for yargs to v17
Summary:
Changelog:
[Internal]

Reviewed By: GijsWeterings

Differential Revision: D39677869

fbshipit-source-id: 4495b0c6c5e245d20034906fff4547265c7cc157
2022-09-23 18:00:18 -07:00
Paige Sun 9a253d1864 Back out "Back out "[Venice][iOS] Fix: Install Fabric UIManager before main bundle execution""
Summary:
Changelog: [Internal][Bridgeless][iOS]

# Before diff
Be in Venice > run Metro > run FBiOS > navigate to any RN surface.

 `UIManagerBinding createAndInstallIfNeeded` happens After `ReactInstance loadScript -> evaluateJavaScript`: install Fabric UIManager before main bundle execution

Reviewed By: RSNara

Differential Revision: D39760231

fbshipit-source-id: f17bf02e9b1fb0f9b0ff24c86aa6dc9349c42192
2022-09-23 17:32:49 -07:00
Rubén Norte 30fe6b341b Restore flags to disable Fabric background executor
Summary:
We want to fix the order of execution of layout, layout effects and passive effects in React Native, but the use of the Fabric background executor for layout complicates this (and other things).

This brings back a flag to disable this background thread to do layout synchronously in JavaScript, before the execution of layout effects and passive effects.

This is expected to regress performance on some screens, so we need to address the antipatterns in those screens before shipping this.

Changelog: [internal]

Reviewed By: javache

Differential Revision: D39727131

fbshipit-source-id: 4323b089234d3304ca3bfe5697668fb44ac64c12
2022-09-23 05:51:36 -07:00
Samuel Susla 15dbd9121d Back out "Fix: Install Fabric UIManager before main bundle execution"
Summary:
Original commit changeset: 4491d6de1109

Original Phabricator Diff: D39493654 (https://github.com/facebook/react-native/commit/447be629091579b8656e1b10e365f3429a61bbf3)

changelog: [internal]

Reviewed By: javache

Differential Revision: D39727129

fbshipit-source-id: 412a7fc5e4bf8db26cde7d420e71cf1f314cdc93
2022-09-22 06:36:59 -07:00
Pieter De Baets eddff32b6f Update Hermes
Summary: Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D39657809

fbshipit-source-id: 21a4a39c5c21d3932db0e8513dad8f005ea46148
2022-09-21 07:16:37 -07:00
Tim Yung 527ac2f2c5 JS: Upgrade to yargs@^17.5.1
Summary:
Upgrades all of our JavaScript tooling to use `yargs@^17.5.1`.

Of all [release notes](https://github.com/yargs/yargs/releases), these are the major version notes:

- [v17.0.0](https://github.com/yargs/yargs/releases/tag/v17.0.0)
- [v16.0.0](https://github.com/yargs/yargs/releases/tag/v16.0.0)

A cursory inspection suggests that these breaking changes are unlikely to seriously impact our use cases (or can be fixed forward).

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D39550338

fbshipit-source-id: 5b2c5265f8c7a95ab0cc9bab62873f9e4355f32f
2022-09-16 08:25:34 -07:00
Christoph Purrer 9cb716ff76 Add additional Systrace support
Summary:
Adding support for application to hook into further tracing methods

## Changelog

[General][Added] - Add additional Systrace support

Reviewed By: NickGerleman

Differential Revision: D38673212

fbshipit-source-id: 55a90a0cd57809bca5f01da7acddcf253e5852ba
2022-09-14 16:29:20 -07:00
Paige Sun 447be62909 Fix: Install Fabric UIManager before main bundle execution
Summary:
Changelog: [Internal] Fix install Fabric UIManager before main bundle execution in Bridgeless

In iOS, fixed Bridgeless so that [UIManagerBinding::createAndInstallIfNeeded](https://github.com/facebook/react-native/blob/ce50c43986bae05ad62552be46f4d5bb4a46f097/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp#L24-L41) happens BEFORE the JS main bundle is evaluated.

Logic is unchanged in Android.

# Before
```
> UI [FBReactModule.mm:325] Initializing FBReactModule: start.
> UI [FBReactModule.mm:524] Initializing FBReactModule: end.
> UI [FBReactModule.mm:1839] Initializing RCTHost: start.
> UI [FBReactModule.mm:1891] Initializing RCTHost: end.
> UI[-[FBNavigationControllerObserver navigationController:willShowViewController:animated:]] <FBNewNavigationController: 0x7fd0e7859400> will show <FBReactRootViewController: 0x7fd0e7161a00; react_GemstoneHomeRoute> (animated: 1)
>   VJCPP ****** ReactInstance loadScript ->  evaluateJavaScript start      <--- loads Main Bundle
> UI[-[FBNavigationControllerObserver navigationController:didShowViewController:animated:]] <FBNewNavigationController: 0x7fd0e7859400> did show <FBReactRootViewController: 0x7fd0e7161a00; react_GemstoneHomeRoute> (animated: 1)
>   VJCPP ****** ReactInstance loadScript ->  evaluateJavaScript end
>   VJCPP ****** UIManagerBinding createAndInstallIfNeeded      <--- should happen BEFORE evaluateJavaScript

```

Reviewed By: RSNara

Differential Revision: D39493654

fbshipit-source-id: 4491d6de110966b2eb4f554ff4db8548899020e3
2022-09-14 14:51:27 -07:00
Paige Sun e2028a8cb8 Remove unused RuntimeExecutor from UIManagerBinding constructor
Summary:
Changelog: [Internal] Remove unused RuntimeExecutor from UIManagerBinding constructor

Since [UIManager is the class that has a reference to RuntimeExecutor](https://github.com/facebook/react-native/blob/ce50c43986bae05ad62552be46f4d5bb4a46f097/ReactCommon/react/renderer/uimanager/UIManager.h#L35-L36), there's no reason for `UIManagerBinding` to own a reference to RuntimeExecutor too.

The purpose of `UIManagerBinding` is to bind the Fabric `std::shared_ptr<UIManager>` in C++ to `global.nativeFabricUIManager` in JS.

Doing this cleanup to make the next diff easier.

Reviewed By: sammy-SC

Differential Revision: D39490927

fbshipit-source-id: 4c393dccc6985bef44e3b0afc32b9f79bea25f80
2022-09-14 14:51:27 -07:00
Pieter De Baets f44469076d Remove unused Hermes inspector auto-attach logic
Summary:
We already support attaching-on-reload when a debugger was a previously connected, and this connection logic seems to slow down app startup by 2 seconds in debug mode when running on device.

Changelog:
[Internal][Removed]

Reviewed By: jpporto

Differential Revision: D39272704

fbshipit-source-id: deb8651798cb9a13b81e1703920d3f9bd58869d2
2022-09-14 14:49:47 -07:00
Matt Blagden 4a0aa8f7c7 Simplify runtime type in Inspector Connection
Summary:
A previous change made the RuntimeAdapter contain a HermesRuntime (as opposed to an arbitrary JSI Runtime).

Now that it's known to be a HermesRuntime, expose that type information to the Inspector, so a runtime type check can be skipped (which is failing in some builds, despite the concrete type being what's expected).

Changelog: [internal]

Reviewed By: neildhar

Differential Revision: D39429109

fbshipit-source-id: ad5ae0604ac208da2002fd37e38d24319b45aebd
2022-09-13 08:43:43 -07:00
Andreas Eulitz 545366aea3 Pass execution context ID in Debugger.scriptParsed event (#34640)
Summary:
As generated by ReactCommon code, the CDP [Debugger.scriptParsed](https://chromedevtools.github.io/devtools-protocol/tot/Debugger/#event-scriptParsed) event carries a zero execution context ID. It should match the execution context ID contained in the []() argument of the [Runtime.executionContextCreated](https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#event-executionContextCreated) event. Tracking issue is RN:34639](https://github.com/facebook/react-native/issues/34639).

## Changelog

[General] [Changed] - Correct execution context ID in Debugger.scriptParsed event.

Pull Request resolved: https://github.com/facebook/react-native/pull/34640

Test Plan: Verified via packet tracer (Wireshark, Chrome DevTools protocol monitor) that Debugger.scriptParsed carries execution context ID.

Reviewed By: jpporto

Differential Revision: D39385622

Pulled By: mattbfb

fbshipit-source-id: 9060041cfa2a784adf4ad371fbe63f530e3362ad
2022-09-12 06:41:21 -07:00
Paige Sun 4e70376dc7 Modularlize RCTBridgeModule.h 3/n - Move RCTTurboModuleRegistry.h to its own file in ReactInternal target (#34514)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34514

Changelog: [Internal][iOS] Modularlize RCTBridgeModule.h 3/n -  Move RCTTurboModuleRegistry.h to its own file in ReactInternal target

# Why clean up RCTBridgeModule.h?
Clean up one unnecessary import of RCTBridgeModule.h.

RCTBridgeModule includes a lot of header files, and this header is imported everywhere. The ultimate goal is that files (especially React Native infra files) should only import only what they need and not import the entirety of RCTBridgeModule.h whenever possible.

This way, certain headers that are Bridge-only can be compiled out of the new architecture with a flag.

Reviewed By: RSNara

Differential Revision: D38971168

fbshipit-source-id: 3b1b23d422f965a5a14bc4178d32b844906f2c8b
2022-09-09 15:10:14 -07:00
Fabrizio Cucci 9788db0ae5 Comment unsupported flex prop
Summary:
Changelog:
[Internal] - Add comment on `flex` prop for visibility

Reviewed By: Andrey-Mishanin

Differential Revision: D39383844

fbshipit-source-id: 0fc64a2dd04a8ab0099389e7e5c49ee5816ba01f
2022-09-09 07:25:59 -07:00
Paige Sun 5745c1df26 Modularlize RCTConstants.h - Move Bridge-only constants into a separate file
Summary:
Changelog: [Internal] Move Bridge-only constants into a separate file

- Move Bridge only constants from RCTBridge.h into  RCTBridgeConstants.h.
- Move shared constants from RCTBridge.h into RCTConstants.h.

This way, new architecture does not need to import RCTBridge.h just for the constants.

Reviewed By: sammy-SC

Differential Revision: D39085713

fbshipit-source-id: 40177cbed72a326b40ec448c98751d1dd3464504
2022-09-08 19:56:22 -07:00
Kudo Chien 32d12e89f8 add debugging settings (#34489)
Summary:
For brownfield apps, it is possible to have multiple hermes runtimes serving different JS bundles. Hermes inspector currently only supports single JS bundle. The latest loaded JS bundle will overwrite previous JS bundle. This is because we always use the ["Hermes React Native" as the inspector page name](https://github.com/facebook/react-native/blob/de75a7a22eebbe6b7106377bdd697a2d779b91b0/ReactCommon/hermes/executor/HermesExecutorFactory.cpp#L157) and [the latest page name will overwrite previous one](https://github.com/facebook/react-native/blob/de75a7a22eebbe6b7106377bdd697a2d779b91b0/ReactCommon/hermes/inspector/chrome/ConnectionDemux.cpp#L77-L86).

This PR adds more customization for HermesExecutorFactory:
- `setEnableDebugger`: provide a way to disable debugging features for the hermes runtime
- `setDebuggerName`: provide a way to customize inspector page name other than the default "Hermes React Native"

## Changelog

[General] [Added] - Add more debugging settings for *HermesExecutorFactory*

Pull Request resolved: https://github.com/facebook/react-native/pull/34489

Test Plan:
Verify the features by RNTester.

1. `setEnableDebugger`

```diff
 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
@@ -10,10 +10,12 @@ package com.facebook.react.uiapp;
 import android.app.Application;
 import androidx.annotation.NonNull;
 import com.facebook.fbreact.specs.SampleTurboModule;
+import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
 import com.facebook.react.ReactApplication;
 import com.facebook.react.ReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.react.TurboReactPackage;
+import com.facebook.react.bridge.JavaScriptExecutorFactory;
 import com.facebook.react.bridge.NativeModule;
 import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.config.ReactFeatureFlags;
@@ -50,6 +52,13 @@ public class RNTesterApplication extends Application implements ReactApplication
           return BuildConfig.DEBUG;
         }

+        Override
+        protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
+          HermesExecutorFactory factory = new HermesExecutorFactory();
+          factory.setEnableDebugger(false);
+          return factory;
+        }
+
         Override
         public List<ReactPackage> getPackages() {
           return Arrays.<ReactPackage>asList(
```

after app launched, the metro inspector should return empty array.
Run `curl http://localhost:8081/json` and returns `[]`

2. `setDebuggerName`

```diff
 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
@@ -10,10 +10,12 @@ package com.facebook.react.uiapp;
 import android.app.Application;
 import androidx.annotation.NonNull;
 import com.facebook.fbreact.specs.SampleTurboModule;
+import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
 import com.facebook.react.ReactApplication;
 import com.facebook.react.ReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.react.TurboReactPackage;
+import com.facebook.react.bridge.JavaScriptExecutorFactory;
 import com.facebook.react.bridge.NativeModule;
 import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.config.ReactFeatureFlags;
@@ -50,6 +52,13 @@ public class RNTesterApplication extends Application implements ReactApplication
           return BuildConfig.DEBUG;
         }

+        Override
+        protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
+          HermesExecutorFactory factory = new HermesExecutorFactory();
+          factory.setDebuggerName("Custom Hermes Debugger");
+          return factory;
+        }
+
         Override
         public List<ReactPackage> getPackages() {
           return Arrays.<ReactPackage>asList(
```

after app launched, the metro inspector should return an entry with *Custom Hermes Debugger*
Run `curl http://localhost:8081/json` and returns

```json
[
  {
    "id": "2-1",
    "description": "com.facebook.react.uiapp",
    "title": "Custom Hermes Debugger",
    "faviconUrl": "https://reactjs.org/favicon.ico",
    "devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=%5B%3A%3A1%5D%3A8081%2Finspector%2Fdebug%3Fdevice%3D2 (https://github.com/facebook/react-native/commit/e5c5dcd9e26e9443f59864d9763b049e0bda98e7)%26page%3D1 (https://github.com/facebook/react-native/commit/ea93151f21003df6f65dd173dd5dcb3135b0ae94)",
    "type": "node",
    "webSocketDebuggerUrl": "ws://[::1]:8081/inspector/debug?device=2&page=1",
    "vm": "Hermes"
  }
]
```

Reviewed By: mdvacca

Differential Revision: D38982104

Pulled By: cipolleschi

fbshipit-source-id: 78003c173db55448a751145986985b3e1d1c71bb
2022-09-07 12:52:37 -07:00
Fabrizio Cucci 1f13811ff3 Add setPosition accepting Dimension
Summary:
Changelog:
[Internal][Added] - Add `setPosition` accepting `Dimension` in Yoga 2

Reviewed By: Andrey-Mishanin

Differential Revision: D39271414

fbshipit-source-id: af860078dec3db986d8357e4cf9ba867ba1e0532
2022-09-07 08:16:10 -07:00
Samuel Susla ce50c43986 Add more clang tidy rules
Summary:
changelog: [internal]

Add more clang tidy rules to prevent common class of bugs.

Reviewed By: javache

Differential Revision: D39245194

fbshipit-source-id: 5521c5c4653d7005b96ebba494e810ba5075afbc
2022-09-06 07:01:17 -07:00
Fabrizio Cucci 010cdcdc19 Add setMargin accepting Dimension
Summary:
Changelog:
[Internal][Added] - Add `setMargin` accepting `Dimension` in Yoga 2

Reviewed By: Andrey-Mishanin

Differential Revision: D39271039

fbshipit-source-id: ff98b23352377b16d353cd6922ee37e48c80e55b
2022-09-06 06:48:30 -07:00
Fabrizio Cucci 65db77d849 Add setPadding accepting Dimension
Summary:
Changelog:
[Internal][Added] - Add `setPadding` accepting `Dimension` in Yoga 2

Reviewed By: Andrey-Mishanin

Differential Revision: D39260889

fbshipit-source-id: 413367f193e5f5ae0f065f153a637778cdfb5ac4
2022-09-06 06:48:30 -07:00
Mitch Powell 1d3e5130f4 Back out "Mirror fbcode directory structure for container targets"
Summary:
build-break
overriding_review_checks_triggers_an_audit_and_retroactive_review

fbshipit-source-id: bd4b12f340a33160d84293c1b3d454360ec6b511
2022-08-30 21:42:26 -07:00
Janic Duplessis 81564c1a3d Fix hermes profiler (#34129)
Summary:
The hermes profiler doesn't work currently, I tracked down the problem to a couple of things.

- Need to call `registerForProfiling` to enable profiling for a specific runtime. I added the call at the same place where we enable the debugger.
- `runInExecutor` didn't work and call its callback. Not sure exactly why, but using `executor_->add` like we do in a lot of other places to run code on the executor works.
- `GetHeapUsageRequest` seems to cause some deadlocks. JS contexts were not detected reliably, I suspect this is related to deadlocks when trying to run on inspector executor. `GetHeapUsageRequest` doesn't actually need any data from the inspector so there is no need to run it on that queue. To fix it I moved the call to use `runInExecutor` instead.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Fixed] - Fix hermes profiler

Pull Request resolved: https://github.com/facebook/react-native/pull/34129

Reviewed By: cortinico

Differential Revision: D37669469

Pulled By: philIip

fbshipit-source-id: 6cf3b2857ac60b0a1518837b9c56b9c093ed222f
2022-08-30 19:22:51 -07:00
Mitch Powell 10ea6fb9a3 Mirror fbcode directory structure for container targets
Summary:
Mirrors the fbcode directory structure for the folly container subdirectory

skip-frl-buck-targeting

Reviewed By: mzlee

Differential Revision: D38632215

fbshipit-source-id: 93cf4ae018417803a84b3edc750feb4cf24e17a7
2022-08-30 10:04:49 -07:00
Pieter De Baets 202b17a149 Add key to prop conversion errors
Summary:
Improve errors thrown when prop conversion fails by adding the property being converted. Removes the specialization of convertRawProp for std::optional since we can handle that in a fromRawValue specialization instead.

To make this work, we need to remove noexcept from a number of calls. This noexcept behaviour was making these exceptions effectively uncatcheable. The original motivation of D23787492 (https://github.com/facebook/react-native/commit/57dd48b2464ac04b860f2f69cb4f131990fe4dbd) is correct, as we cannot reliably pass on exceptions to JS and assume that the state will be recoverable, so instead we log an error and carry on with the default value available. We should improve how the error gets reported to the user, as it will currently be hidden in logcat.

Changelog: [Internal]

Differential Revision: D39052812

fbshipit-source-id: 9692633930555e64a3769116fc484a19e534aa3f
2022-08-30 08:48:26 -07:00
Matt Blagden 4f486c7e4e Enable sampling profiler in Chrome Debug Server
Summary:
Configure the runtime to allow use of the sampling profiler in the Chrome Debug Server.

Note: this does not actually start and stop the profiler; this change just makes the sampling profiler available to the runtime.

Changelog: [Internal]

Reviewed By: neildhar

Differential Revision: D39100833

fbshipit-source-id: 60d1f4e5ea2191fdf88b7f2e733557fa6128e205
2022-08-30 06:25:11 -07:00
Matt Blagden 2b4390e15d Implement Runtime.compileScript
Summary:
Implement Runtime.compileScript, which is a dev tools request to compile a given script, optionally persisting the compiled result.

There are 3 main cases:
- Unsuccessful compilation, populates the exception details output. (We could retrieve the line and column number from the exception message, but it felt a bit too hacky.)
- Successful unpersisted output, returns an empty result, indicating success
- Successful persisted output, returns a result with a unique scriptID that identifies the prepared script.

The script IDs end with an index that can be used to infer the location in the vector storing persisted scripts.

Changelog: [Internal]

Reviewed By: jpporto

Differential Revision: D38761119

fbshipit-source-id: 504faad0149d1637682fa11d285f71736c3133e5
2022-08-29 14:17:51 -07:00
Shawn Shihang Wei 04ee52b867 Revert D38938632: Add key to prop conversion errors
Differential Revision:
D38938632 (https://github.com/facebook/react-native/commit/7909b913ef98b66c6c09b3cbe69e2c2f85658e02)

Original commit changeset: 1dc9a544ca67

Original Phabricator Diff: D38938632 (https://github.com/facebook/react-native/commit/7909b913ef98b66c6c09b3cbe69e2c2f85658e02)

fbshipit-source-id: ddfe699ebf2ec7b118079d9ecb9ce77f2bf4a2ac
2022-08-25 15:18:01 -07:00