Граф коммитов

3372 Коммитов

Автор SHA1 Сообщение Дата
Scott Kyle 6e0fa5f15e Support optional types for C++ TurboModules
Summary:
Update C++ TurboModule codegen to wrap nullable types in `std::optional` whereas before the conversion would cause a crash.

Changelog:
Internal

Reviewed By: mdvacca, nlutsenko

Differential Revision: D35299708

fbshipit-source-id: 7daa50fe8b16879c5b3a55a633aa3f724dc5be30
2022-04-01 16:58:52 -07:00
Andrei Shikov 2a6a6851ec Rename C++ part of ReadableMapBuffer to JReadableMapBuffer
Summary:
Aligns naming with `JWritableMapBuffer` and other fbjni classes to indicate that it is a JNI binding.

Changelog: [Internal] - Rename C++ part of ReadableMapBuffer to JReadableMapBuffer

Reviewed By: mdvacca

Differential Revision: D35219323

fbshipit-source-id: a7eb644a700a35dc94fa18e4fb3cc68f2cfa3e99
2022-03-30 20:27:23 -07:00
Andrei Shikov cf6f3b680b MapBuffer interface and JVM -> C++ conversion
Summary:
Creates a `WritableMapBuffer` abstraction to pass data from JVM to C++, similarly to `ReadableMapBuffer`. This part also defines a Kotlin interface for both `Readable/WritableMapBuffer` to allow to use them interchangeably on Java side.

`WritableMapBuffer` is using Android's `SparseArray` which has almost identical structure to `MapBuffer`, with `log(N)` random access and instant sequential access.

To avoid paying the cost of JNI transfer, the data is only transferred when requested by native `JWritableMapBuffer::getMapBuffer`. `WritableMapBuffer` also owns it data, meaning it cannot be "consumed" as `WritableNativeMap`, with C++ usually receiving copy of the data on conversion. This allows to use `WritableMapBuffer` as JVM-only implementation of `MapBuffer` interface as well, e.g. for testing (although Robolectric will still be required due to `SparseArray` used as storage)

Changelog: [Android][Added] - MapBuffer implementation for JVM -> C++ communication

Reviewed By: mdvacca

Differential Revision: D35014011

fbshipit-source-id: 8430212bf6152b966cde8e6f483b4f2dab369e4e
2022-03-30 20:27:23 -07:00
Chris Olszewski ceae48c0f7 Add pfh labels to targets
Summary:
While it would be better to be able to do all of the ownership metadata at the Buck macro level, that proved to be more work than expected.

This diff adds the corresponding pfh label to all targets in `xplat/js/react-native-github` that have a Supermodule label. Once the migration is complete the Supermodules labels will be able to be removed.

Reviewed By: cortinico

Differential Revision: D35221544

fbshipit-source-id: d87d5e266dfb5e6ee087251dc34dff5db299bbaf
2022-03-30 14:37:03 -07:00
Scott Kyle 087624ccaf Add supportsFromJs and supportsToJs template variables
Summary:
These `constexpr` template variables make it really easy to test for bridging conversion to/from the specified types. The unit tests for this actually uncovered a bug with incompatible casts from lvalue references that was fixed in this diff as well.

Changelog:
Internal

Reviewed By: christophpurrer

Differential Revision: D35105398

fbshipit-source-id: 6e5f16e44ba99b296284970bf32c1f2f47201391
2022-03-30 09:14:39 -07:00
Chris Olszewski 75edd288cb Backout feature args
Reviewed By: jkeljo

Differential Revision: D35203884

fbshipit-source-id: 87d50b138aaa3dd16a24b5ff2795910c3644d418
2022-03-30 06:53:44 -07:00
Xin Chen 7e993a7a87 Add more context to systrace for event dispatching
Summary:
Adding more context for event dispatching process in systrace.

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D35208257

fbshipit-source-id: 4a70e15a0074d4a53a895066e6fa1e60a6ebda0d
2022-03-29 10:48:32 -07:00
CodemodService Bot 590ffad018 Annotate targets with feature xplat/js/react-native-github/ReactCommon/react/renderer/mapbuffer/BUCK -> xplat/js/tools/metro/packages/metro-runtime/src/polyfills/BUCK
Reviewed By: jkeljo

Differential Revision: D35178571

fbshipit-source-id: b8b6fcd49459e37152c02db8c7a6cfed167248a9
2022-03-28 13:22:38 -07:00
CodemodService Bot 8eddec9ff4 Annotate targets with feature xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/views/drawer/BUCK -> xplat/js/react-native-github/ReactCommon/callinvoker/BUCK
Reviewed By: jkeljo

Differential Revision: D35178416

fbshipit-source-id: 17e4228f6792048edd2e927ed7a3447a977a1183
2022-03-28 13:05:14 -07:00
Krzysztof Magiera 58a2eb7f37 Fix dynamic_cast (RTTI) by adding key function to ShadowNodeWrapper and related classes (#33500)
Summary:
This PR fixes RTTI (run-time type information) for ShadowNodeWrapper and ShadowNodeListWrapper classes, i.e., calls to dynamic_cast and dynamic_pointer_cast that are called via JSI's getHostObject calls.

The fix is simply to add a so-called "key function" in a form of virtual destructor. Key functions needs to be a virtual non-pure and non-inlined functions that points the compiler as to which library contains the vtable/type information for a given class (see https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-vtable and https://developer.android.com/ndk/guides/common-problems#rttiexceptions_not_working_across_library_boundaries)

Without the "key function", calls to dynamic_cast for ShadowNodeWrapper instances won't work across library boundaries because the class will have separate definitions in each separate library, therefore objects created in one of those libraries won't be recognized as the same type by the other library. This has been a problem in reanimated and gesture-handler libraries where we call `object.getHostObject<ShadowNodeWrapper>(rt)` (this is a method from JSI) in order to access ShadowNode instance from a handle we have in JS. I think, this issue is going to be relevant to more libraries that cope with view instances. In this scenario, we have a separate library, say "libreanimated.so" that calls to `getHostObject` which is an inline function that calls `dynamic_cast` for the `ShadowNodeWrapper` class. On the other hand, the instances of `ShadowNodeWrapper` are created by the code from `libreact_render_uimanager.so`. Because of that `dynamic_cast` fails even though it is called on instance of `ShadowNodeWrapper` because the class has separate vtable/type info: one in `libreanimated.so` and one in `libreact_render_uimanager.so` (by "fails" I mean that it actually returns `nullptr`).

This problem has been documented here: https://developer.android.com/ndk/guides/common-problems#rttiexceptions_not_working_across_library_boundaries where the solution is for the class to have a so-called "key function". The key function makes it so that compiler sees that one of the implementation for a given class is missing and therefore can safely assume that a vtable/type info for a given class is embedded into some library we link to.

This change adds a virtual destructor that is declared in the header file but defined in file that gets compiled as a part of `libreact_render_uimanager`. As a result, the compiler only creates one vtable/type info and calls to dynamic_cast works as expected in all libraries for `ShadowNodeWrapper` and `ShadowNodeListWrapper` classes.

This issue would only surface on Android, because on iOS all libraries by default are bundled together via Pods, whereas on Android each library is loaded separately using dynamic loading.

## Changelog

[Fabric][Android specific] - Fix dynamic_cast (RTTI) for ShadowNodeWrapper and similar classes when accessed by third-party libraries.

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

Test Plan:
1. In order to test this you need to add a library that'd include  `<react/renderer/uimanager/primitives.h>` (i.e. use this branch of reanimated library: https://github.com/software-mansion/react-native-reanimated/tree/fabric)
2. After compiling the app inspect libreact_render_uimanager.so and libreanimated.so artifacts with `nm` tool
3. Notice that symbols like `vtable for facebook::react::ShadowNodeWrapper` and `typeinfo for facebook::react::ShadowNodeWrapper` are only present in the former and not in the latter library (before this change you'd see them both)

Reviewed By: ShikaSD

Differential Revision: D35143600

Pulled By: javache

fbshipit-source-id: 5fb25a02365b99a515edc81e5485a77017c56eb8
2022-03-28 05:01:47 -07:00
Andrei Shikov e3830ddffd CMake setup for ReactAndroid (#33472)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33472

Changes native build of ReactAndroid to CMake instead of ndk-build. Removes a few workarounds around AGP issues with ndk-build which seems to be working with CMake by default.

Changelog: [Changed][Android] - Use CMake to build ReactAndroid module

Reviewed By: cortinico

Differential Revision: D35018803

fbshipit-source-id: af477937ed70a5ddfafef4e6260a397ee9911580
2022-03-23 11:18:54 -07:00
Joachim Reiersen 12a32549f4 Fix jsi test compilation under gtest 1.10
Summary: Changelog: [Internal] - Fix test compilation with gtest 1.10

Reviewed By: jiawei-lyu

Differential Revision: D35058207

fbshipit-source-id: 2cbcfad00992fee646d3c2d701af9ebdfb7b4f2e
2022-03-22 14:35:57 -07:00
Andrei Shikov d63bf4add3 Align ReadableMap and MapBuffer measure methods in ViewManager
Summary:
Aligns two codepaths for measure, making sure we can use both MapBuffer and ReadableMap for measuring components.

Changelog: [Internal] - Align measure interface for MapBuffer experiment

Reviewed By: javache, mdvacca

Differential Revision: D34960317

fbshipit-source-id: a39eb84a0abb4414717463f2f1741e470be3531f
2022-03-18 00:36:07 -07:00
Andrei Shikov 69e8d3d883 Build Fabric with CMake
Summary:
More CMake configurations mirroring Android.mk in place.

Changelog: [Internal] - Build fabricjni with CMake

Reviewed By: cortinico

Differential Revision: D34927238

fbshipit-source-id: 929763ec79a7c168e300e065709a49e4b373326a
2022-03-17 17:08:24 -07:00
Christoph Purrer 7d527e0fc8 Export bridging header from testlib
Summary:
Export bridging for testlib BUCK target

Changelog:
[General][Fixed] - Export bridging for testlib BUCK target

Reviewed By: appden

Differential Revision: D34866694

fbshipit-source-id: c2dfbdb98d3c32f70192329a8df139f344a847b7
2022-03-17 16:24:09 -07:00
Tatiana Kapos 2d64d1d693 Fix RawPropsParser for Windows (#33432)
Summary:
Changes in 7cece3423...189c2c895 broke build for Windows because of a conversion from size_t to int. Adds a static cast to int to fix the error and restore windows build

Error Message
```
##[error]node_modules\react-native\ReactCommon\react\renderer\core\RawPropsParser.cpp(100,42): Error C2220: the following warning is treated as an error
     3>D:\a\_work\1\s\node_modules\react-native\ReactCommon\react\renderer\core\RawPropsParser.cpp(100,42): error C2220: the following warning is treated as an error [D:\a\_work\1\s\vnext\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]
##[warning]node_modules\react-native\ReactCommon\react\renderer\core\RawPropsParser.cpp(100,42): **Warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data**
     3>D:\a\_work\1\s\node_modules\react-native\ReactCommon\react\renderer\core\RawPropsParser.cpp(100,42): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data [D:\a\_work\1\s\vnext\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj]
```

## Changelog

[General] [Fixed] - Restore Windows build with RawPropsParser.cpp

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

Test Plan: Tested locally and changes pass in the react-native-windows pipeline, change is being merged into the main branch of react-native-windows.

Reviewed By: philIip

Differential Revision: D34907928

Pulled By: javache

fbshipit-source-id: 8b76cbef0b637f2d607a8aefd2998322c3245713
2022-03-17 03:58:57 -07:00
Phillip Pan 982ca30de0 bump iOS and tvOS from 11.0 to 12.4 in cocoapods
Summary:
Changelog: [iOS][Deprecated] Deprecating support for iOS/tvOS SDK 11.0, 12.4+ is now required

allow-large-files

Reviewed By: sammy-SC

Differential Revision: D34547333

fbshipit-source-id: a24bb09d03939a092de4198efb1aa4a44c69f718
2022-03-16 21:08:01 -07:00
Andrei Shikov bc53279a56 Rename String.h to AString.h in bridging module
Summary:
String.h conflicts with system headers in cocoapods build, causing build error.

Changelog: [Internal]

Reviewed By: appden

Differential Revision: D34936511

fbshipit-source-id: 4c25f7e755e53dec736ac7ed6217f6cd111d9288
2022-03-16 15:30:58 -07:00
Andrei Shikov e5874d90e2 Folly_runtime for CMake
Summary:
Ports improvements from Android.mk setup to CMake, replacing folly_json and futures with runtime where plausible

Changelog: [Internal] - CMake folly_runtime setup

Reviewed By: cortinico

Differential Revision: D34854295

fbshipit-source-id: fa882a9cd0b78feb20f8abcc9350c27702375def
2022-03-16 08:10:55 -07:00
Andrei Shikov 6c5bd6d790 Hermes executor migration to CMake
Summary:
Adds CMake files to configure hermes-executor build, with the same setup as we have in Android.mk

Changelog: [Internal] - CMake build config for hermes executor

Reviewed By: cortinico

Differential Revision: D34811909

fbshipit-source-id: 2df6dbaf46131db87a25e26c83b38ba44f29d1d3
2022-03-16 01:47:05 -07:00
Nicola Corti 0d2ee7c17c Re-apply main changes to CMake files
Summary:
This Diff re-applies some of the changes that landed on main
to the CMake files we currently landed so far.

Changelog:
[Internal] [Changed] - Re-apply main changes to CMake files

Reviewed By: ShikaSD

Differential Revision: D34859685

fbshipit-source-id: 772a3aed05f56b6fbb2942bf9d1a5bd4581b48d5
2022-03-15 08:14:07 -07:00
Pieter De Baets 6c9de5543e Cleanup ScriptTag helpers on Instance
Summary:
We were opening the file multiple times just to read the same couple of bytes.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D34835972

fbshipit-source-id: 9de899f37a9193db4ab72e69e02e8d41e5515da0
2022-03-15 05:58:52 -07:00
Pieter De Baets be0ff779b1 Fix parseTypeFromHeader for Hermes bytecode
Summary: Changelog: [Internal] Fix bug where Hermes bytecode bundles were not always recognized

Reviewed By: motiz88

Differential Revision: D34718511

fbshipit-source-id: 5bbebe49962d098988d99153b0938fbb5d449ae6
2022-03-15 05:58:52 -07:00
Nicola Corti e12bc9cf62 Setup Globbing with CONFIGURE_DEPENDS inside CMake files.
Summary:
This Diff moves from specifying a list of files to use file(GLOB) with
CONFIGURE_DEPENDS on several CMakefiles.
I've updates those where we use globbing also inside buck.

Changelog:
[Internal] [Changed] - Setup Globbing with CONFIGURE_DEPENDS inside CMake files

Reviewed By: ShikaSD

Differential Revision: D34826311

fbshipit-source-id: 8fc654626c897cdc4cdd79c699ce19f1e5e1212f
2022-03-15 01:55:27 -07:00
Andrei Shikov 5d5addd661 Separate folly into runtime + folly_futures specific for hermes inspector
Summary:
Rearranges folly_futures configuration into a static library only required for `hermes-inspector` + `folly_runtime` which merges `folly_json` and mutex-related implementations `folly_futures` was used for. As `hermes-executor-debug` is removed by `vmCleanup` configurations later, it allows to shave additional 300KB from the release APK size.

Changelog: [Internal] - Rearrange folly build to reduce APK size

Reviewed By: cortinico

Differential Revision: D34342514

fbshipit-source-id: b646680343e6b9a7674019506b87b96f6007caf2
2022-03-13 15:15:21 -07:00
Andrei Shikov 0a004927ad Extract mapbuffer from reactutils module
Summary:
`MapBuffer` is not used in RN utils for anything shared for now, so we can remove it from the build config by reordering methods, shaving 20KB in APK size for each architecture.

Also applies clang-tidy rules to `MapBuffer`/`folly::dynamic` configurations.

Changelog: [Internal] - Remove `mapbuffer` dependency from `Android.mk` of reactutilsjni

Reviewed By: javache, cortinico

Differential Revision: D34620455

fbshipit-source-id: ad3717448f5c20fd071f71d436bb9dd00efe7eb0
2022-03-12 11:19:57 -08:00
Nicola Corti a3d9892ed9 Build Hermes from Source (#33396)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33396

This commit fully unplugs the `ReactAndroid` from using hermes from the NPM package and plugs the usage of Hermes via the `packages/hermes-engine` Gradle build.

I've used prefab to share the .so between the two builds, so we don't need any extra machinery to make this possible.

Moreover, I've added a `buildHermesFromSource` property, which defaults to false when RN is imported, but is set to true when RN is opened for local development. This should allow us to distribute the `react-native` NPM package and users could potentially toggle which source to use (but see below).

Changelog:
[Android] [Changed] - Build Hermes from Source

Reviewed By: hramos

Differential Revision: D34389875

fbshipit-source-id: 107cbe3686daf7607a1f0f75202f24cd80ce64bb
2022-03-11 15:23:36 -08:00
Scott Kyle 31f0796237 Add codegen for C++ TurboModule automatic type conversions
Summary:
This adds the *option* for C++ TurboModules to use a `*CxxSpec<T>` base class that extends the existing (and unchanged) corresponding `*CxxSpecJSI` base class with code-generated methods that use `bridging::calFromJs` to safely convert types between JSI and C++. If a type conversion cannot be made, then it will fail to compile.

Changelog:
[General][Added] - Automatic type conversions for C++ TurboModules

Reviewed By: christophpurrer

Differential Revision: D34780512

fbshipit-source-id: 58b34533c40652db8e3aea43804ceb73bcbe97a5
2022-03-11 12:47:51 -08:00
Scott Kyle 6697b7bb90 Add callFromJs bridging API
Summary:
This adds `bridging::callFromJs` that can call class instance methods with JSI arguments and will automagically convert types to the types expected by the method, or otherwise will fail to compile. The same type conversion back to JSI applies as well for the return value, if there is one.

This will allow C++ TurboModules to more easily define their interface in terms of C++ types instead of having to interact with JSI directly for everything, though it remains possibles for JSI values to pass through if that's what a given method wants.

Changelog:
Internal

Reviewed By: christophpurrer

Differential Revision: D34780511

fbshipit-source-id: 1f9caadeefa6d4023f679e95f3decc64d156b3f0
2022-03-11 12:47:51 -08:00
Scott Kyle 30cb78e709 New bridging API for JSI <-> C++
Summary:
This adds  `bridging::toJs` and `bridging::fromJs` functions that will safely cast to and from JSI values and C++ types. This is extensible by specializing `Bridging<T>` with `toJs` and/or `fromJs` static methods. There are specializations for most common C++ and JSI types along with tests for those.

C++ functions and lambdas will effortlessly bridge into JS, and bridging JS functions back into C++ require you to choose `SyncCallback<R(Args...)>` or `AsyncCallback<Args...>` types. The sync version allows for having a return value and is strictly not movable to prevent accidentally moving onto another thread. The async version will move its args onto the JS thread and safely call the callback there, but hence always has a `void` return value.

For promises, you can construct a `AsyncPromise<T>` that has `resolve` and `reject` methods that can be called from any thread, and will bridge into JS as a regular `Promise`.

Changelog:
[General][Added] - New bridging API for JSI <-> C++

Reviewed By: christophpurrer

Differential Revision: D34607143

fbshipit-source-id: d832ac24cf84b4c1672a7b544d82e324d5fca3ef
2022-03-11 12:47:51 -08:00
Scott Kyle 6a9497dbbb Move some classes to new bridging library (#33413)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33413

This moves `CallbackWrapper` and `LongLivedObject` into a new "bridging" library. This library is mostly intended for use by the native module system, but can also be used separately to "bridge" native and JS interfaces through higher-level (and safer) abstractions than relying JSI alone.

Changelog:
Internal

Reviewed By: christophpurrer

Differential Revision: D34723341

fbshipit-source-id: 7ca8fa815537152f8163920513b90313540477e3
2022-03-11 12:47:51 -08:00
Nicola Corti b676ca560d First Round of CMake files for React Android
Summary:
This is the first round of CMake files to support the React Native build on Android.
They're supposed to eventually replace the various Android.mk files we have around in the codebase.

So far we're not actively using them. This is the first step towards migrating our
setup to use CMake

Changelog:
[Internal] [Changed] - First Round of CMake files for React Android

Reviewed By: ShikaSD

Differential Revision: D34762524

fbshipit-source-id: 6671e203a2c83b8874cefe796aa55aa987902a3b
2022-03-11 11:39:23 -08:00
Arthur Kushka 009d80bf5a Dropped `using namespace` from TurboModuleUtils.h
Summary:
using namespace in header file is a bad practice due to many reasons as well as discouraged by `-Wheader-hygiene` compiler flag which is default for many apps

https://stackoverflow.com/questions/5849457/using-namespace-in-c-headers

Changelog:
[General][Fixed] - Fixed compilation warning due to `using namespace` being used as part of header

Reviewed By: nlutsenko

Differential Revision: D34788523

fbshipit-source-id: 2a50fbf2ac3371ff5670c600c7f5ad9055060ad2
2022-03-11 06:56:10 -08:00
Xavier Deguillard ece1dd4ed9 BUCK: define GLOG_NO_ABBREVIATED_SEVERITIES everywhere
Summary:
This is only defined on Windows, and thus code that compiles on all platforms
may successfully build on Linux/macOS, but not on Windows, making it
potentially harder to detect and debug. Let's unify all platforms to solve
this.

Changelog: [Internal]

Reviewed By: chadaustin

Differential Revision: D34648154

fbshipit-source-id: b2549bb3eb120e6207cab8baaafced8b1b18e6a7
2022-03-08 12:35:48 -08:00
John Porto c8067f1ffd Misc MsgGen fixes
Summary:
Fix a few issues with msggen:
1. run_msggen: fully-qualified path to clang-format
1. Updated the license for autogenerated files

Changelog: [Internal]

Reviewed By: neildhar

Differential Revision: D34114718

fbshipit-source-id: 831d4b20bfdc39cfa1226e2a32dcb445c8086ff3
2022-03-08 10:22:28 -08:00
Samuel Susla e97e3499c3 Avoid string copy in event dispatching
Summary:
Changelog: [internal]

To avoid unnecessary string copy in event pipeline, use move semantics.

Event pipeline has ownership of event type. Passing it by reference ends up in a copy when `RawEvent` object is constructed. To avoid this, pass string by value through each layer and use move semantics to avoid extra copies.

Reviewed By: javache

Differential Revision: D34392608

fbshipit-source-id: c11d221be345665e165d9edbc360ba5a057e3890
2022-03-08 04:28:51 -08:00
caioagiani 8200063ac6 fix: typos (#33040)
Summary:
Fix typos in:

- `Libraries/Renderer/implementations/ReactFabric-dev.js`: transfered -> **transferred**
- `Libraries/Renderer/implementations/ReactNativeRenderer-dev.js`: transfered -> **transferred**
- `ReactAndroid/src/main/java/com/facebook/react/modules/network/ProgressiveStringDecoder.java`: remainderLenght -> **remainderLength**
- `ReactAndroid/src/main/jni/first-party/yogajni/jni/ScopedGlobalRef.h`: Transfering -> **Transferring**
- `ReactCommon/react/renderer/graphics/Transform.h`:  tranformation -> **transformation**
- `packages/rn-tester/js/examples/ToastAndroid/ToastAndroidExample.android.js`: occured -> **occurred**

## 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
-->

[Internal] [Fixed] - fix typos

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

Test Plan: Considering this only changes code comments, I don’t think this pull request needs a test plan.

Reviewed By: cortinico, pasqualeanatriello

Differential Revision: D34003812

Pulled By: dmitryrykun

fbshipit-source-id: 5c8699f8efcc4354854190a9aade30dbc5c90fdb
2022-03-08 03:58:58 -08:00
Richard Barnes 3b61f2108d use gmock 1.10 instead of 1.8
Summary: See D34622171 for details

Reviewed By: lehecka

Differential Revision: D34688121

fbshipit-source-id: 09a3c749e0803810dcdca362c4e58a3e6b99dd8a
2022-03-07 17:33:06 -08:00
Daniel Andersson e1dc9a756b Silence some warnings in xcode 13.3
Summary:
Silence some warnings in xcode 13.3 by explicitly defining some copy constructors in JSI and adding a compiler flag in Hermes.

Changelog:
[Internal][Fixed] - Build issues

Reviewed By: jpporto

Differential Revision: D34526541

fbshipit-source-id: 7029e3d20b9209007cf7e9f4c935338513ee1dd0
2022-03-07 11:52:51 -08:00
Diego Pasquali 7b05b091fd Integrated iOS-only `accessibilityLanguage` prop (#33090)
Summary:
This PR fixes https://github.com/facebook/react-native/issues/30891

This PR is going to add an `accessibilityLanguage` prop to all the available components. This props is currently working only on iOS and should follow the [guidelines of the relative configuration](https://developer.apple.com/documentation/objectivec/nsobject/1615192-accessibilitylanguage).

I'm in no way an expert on native programming (especially Objective-C) so I'm open to changes / improvements 🙂

## 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
-->

[iOS] [Added] - Integrated the `accessibilityLanguage` prop to all the available components. The prop is available for any platform but it will work only on iOS.

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

Test Plan:
This has been tested using both the Simulator, checking for the `Language` attribute, and using a physical device with the Voice Over enabled.

<img width="1083" alt="Screenshot 2022-02-11 at 13 17 32" src="https://user-images.githubusercontent.com/5963683/153590415-65fcb4ff-8f31-4a0f-90e5-8eb1aae6aa3d.png">

Reviewed By: philIip

Differential Revision: D34523608

Pulled By: rh389

fbshipit-source-id: b5d77fc0b3d76ea8ed8f30c8385459ba98122ff6
2022-03-07 09:43:30 -08:00
Nikita Lutsenko 1f87729697 rn | cxx | Move the definitions of TurboModule virtual methods to declaration, to allow for use in context with RTTI.
Summary:
Not having this disallows including turbo module and extending in places where RTTI is enabled.
There is no additional includes or implementation changes - it merely allows for things to nicely link with other libraries.

Changelog: [General][Fixed] - Allow including TurboModule.h in mixed rtti/no-rtti environment, even if TurboModule.h/cpp is compiled without RTTI.

Reviewed By: appden

Differential Revision: D34637168

fbshipit-source-id: 2e5d9e546bdc5652f06436fec3b12f1aa9daab05
2022-03-04 19:04:36 -08:00
Scott Kyle 603620b739 Add asBool() method
Summary:
Changelog:
[General][Added] - Add asBool() method to JSI

Reviewed By: mhorowitz

Differential Revision: D34630901

fbshipit-source-id: 3007784618fcc0f7828eee42de5cbf2bd71258c5
2022-03-04 08:02:17 -08:00
Samuel Susla a159416333 Use std::optional instead of butter::optional
Summary: changelog: Use std::optional instead of butter::optional

Reviewed By: fkgozali

Differential Revision: D33352680

fbshipit-source-id: 45a53fec181a6ffb6218909bc23348f7c9f21ec4
2022-03-04 07:25:59 -08:00
Samuel Susla c2e4ae39b8 Add support for C++17 in OSS
Summary: changelog: Add support for C++17

Reviewed By: cortinico

Differential Revision: D34612257

fbshipit-source-id: 88a0307a750f2e0793a639b7a2b670a4571332fe
2022-03-04 07:25:59 -08:00
Gilson Takaasi Gil eb434c1c76 Revert D34351084: Migrate from googletest 1.8 to googletest 1.10
Differential Revision:
D34351084 (94891ab5f8)

Original commit changeset: 939b3985ab63

Original Phabricator Diff: D34351084 (94891ab5f8)

fbshipit-source-id: 2fd17e0ccd9d1f1d643f4a372d84cb95f5add1f8
2022-03-03 04:41:46 -08:00
Dimitri Bouche 94891ab5f8 Migrate from googletest 1.8 to googletest 1.10 (#67)
Summary:
X-link: https://github.com/facebookincubator/hsthrift/pull/67

Updating `googletest` from `1.8.0` to `1.10.0`

Reviewed By: mzlee, igorsugak, luciang, meyering, r-barnes

Differential Revision: D34351084

fbshipit-source-id: 939b3985ab63a06b6d511ec8711c2d5863bdfea8
2022-03-03 03:46:03 -08:00
Gal Shirin cfb11ca2f6 Fix xcodebeta build failure
Summary:
Changelog:
[iOS][Changed] - Removed methodName parameter that was used only for a warning message and moved the warning parameter to be calculated inline.

Reviewed By: fkgozali

Differential Revision: D34551444

fbshipit-source-id: 6ceba425b64df37b0dca7e222072f1836f151d83
2022-03-01 23:56:55 -08:00
Xin Chen 0975e96d53 Fix transform when calculate overflowInset
Summary:
This diff fixes overflowInset calculation when a shadow node has transform matrix from a transfrom prop in JS. Specifically, this fixed the use case when transform directly used on a view component. When using Animated.View, it will create an invisible wrapper which will behave correctly with existing logic. This diff bring both use cases to work properly.

When a shadow node has transform on it, it will affect the overflowInset values for its parent nodes, but won't affect its own or any of its child nodes overflowInset values. This is obvious for translateX/Y case, but not for scale case. Take a look at the following case:

```
     ┌────────────────┐                 ┌────────────────┐                      ┌────────────────┐
     │Original Layout │                 │  Translate AB  │                      │    Scale AB    │
     └────────────────┘                 └────────────────┘                      └────────────────┘
                                                        ─────▶           ◀─────                  ─────▶
┌ ─ ─ ─ ┬──────────┐─ ─ ─ ─ ┐     ┌ ─ ─ ─ ┬──────────┐─ ─ ─ ─ ─ ┐      ┌ ─ ─ ─ ─ ─ ┬──────────┐─ ─ ─ ─ ─ ┐
        │ A        │                      │ A        │                             │ A        │
│       │          │        │     │       │          │          │      ├ ─ ─ ─ ─ ─ ┼ ─ ─┌─────┤─ ─ ─ ─ ─ ┤
 ─ ─ ─ ─│─ ─ ─┌───┐┼ ─ ─ ─ ─              │          │                   ◀─ ─ ─    │    │AB   │  ─ ─ ─▶
│       │     │AB ││        │     │ ┌ ─ ─ ┼ ─ ─ ─ ┬──┴┬ ─ ─ ─ ─ ┤      │           │    │     │          │
        └─────┤   ├┘                      └───────┤AB │                            └────┤     │
│             │┌──┴─────────┤     │ │             │   │         │      │ │              │ ┌───┴──────────┤
              ││ABC         │                     │┌──┴─────────┐                       │ │ABC           │
│             │└──┬─────────┤   │ │ │             ││ABC         │    │ │ │              │ │              │
┌───ABD───────┴─┐ │             │                 │└──┬─────────┘    │   ▼              │ └───┬──────────┘
├─────────────┬─┘ │         │   │ │ ├───ABD───────┴─┐ │         │    │ ├────────────────┴──┐  │          │
 ─ ─ ─ ─ ─ ─ ─└───┘─ ─ ─ ─ ─    ▼   └─────────────┬─┘ │              ▼ │      ABD          │  │
                                  └ ┴ ─ ─ ─ ─ ─ ─ ┴───┴ ─ ─ ─ ─ ┘      ├────────────────┬──┘  │          │
                                                                        ─ ─ ─ ─ ─ ─ ─ ─ ┴─────┴ ─ ─ ─ ─ ─
```

For the translate case, only view A has change on the overflowInset values for `right` and `bottom`. Note that the `left` and `top` are not changed as we union before and after transform is applied.

For the scale case, similar things are happening for view A, and both `left`, `right`, and `bottom` values are increased. However, for View AB or any of its children, they only *appear* to be increased, but that is purely cosmetic as it's caused by transform. The actual values are not changed, which will later be converted during render phase to actual pixels on screen.

In summary, overflowInset is affected from child nodes transform matrix to the current node (bottom up), but not from transform matrix on the current node to child nodes (top down). So the correct way to apply transform is to make it only affect calculating `contentFrame` during layout, which collects child nodes layout information and their transforms. The `contentFrame` is then used to decide the overflowInset values for the parent node. The current transform matrix on parent node is never used as it's not affecting overflowInset for the current node or its child nodes.

This diff reflects the context above with added unit test to cover the scale and translate transform matrix.

Changelog:
[Android/IOS][Fixed] - Fixed how we calculate overflowInset with transform matrix

Reviewed By: sammy-SC

Differential Revision: D34433404

fbshipit-source-id: 0e48e4af4cfd5a6dd32a30e7667686e8ef1a7004
2022-03-01 14:33:04 -08:00
Janic Duplessis cff9590864 Implement Runtime.getHeapUsage for hermes chrome inspector (#33173)
Summary:
Reland of https://github.com/facebook/react-native/issues/32895 with fix for optional params object.

Original description:

I was looking at the hermes chrome devtools integration and noticed requests to `Runtime.getHeapUsage` which was not implemented. When implemented it will show a summary of memory usage of the javascript instance in devtools.

<img width="325" alt="image" src="https://user-images.githubusercontent.com/2677334/149637113-e1d95d26-9e26-46c2-9be6-47d22284f15f.png">

## Changelog

[General] [Added] - Implement Runtime.getHeapUsage for hermes chrome inspector

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

Test Plan:
I was able to reproduce the issue that caused the initial PR to be reverted using the resume request in Flipper. Pausing JS execution then resuming it will cause it to crash before this change, and works fine after.

Before

<img width="912" alt="image" src="https://user-images.githubusercontent.com/2677334/149637073-15f4e1fa-8183-42dc-8673-d4371731415c.png">

After

<img width="1076" alt="image" src="https://user-images.githubusercontent.com/2677334/149637085-579dee8f-5efb-4658-b0a8-2400bd119924.png">

Reviewed By: jpporto

Differential Revision: D34446672

Pulled By: ShikaSD

fbshipit-source-id: 6e26b8d53cd88cddded36437c72a01822551b9d0
2022-03-01 10:09:05 -08:00
David Vacca be9cf17316 Move TextLayoutManager constructor to Cpp file
Summary:
Move TextLayoutManager constructor to Cpp file

changelog: [internal] internal

Reviewed By: genkikondo

Differential Revision: D34246014

fbshipit-source-id: a85e144b05e2cefad8cb1757dad14bedacbb8d74
2022-02-27 22:23:48 -08:00