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

3622 Коммитов

Автор SHA1 Сообщение Дата
Joshua Gross 47280de85e New Props parsing infrastructure for perf improvements: visitor pattern vs random-map-access pattern (ViewProps, minus YogaLayoutableShadowNode)
Summary:
Perf numbers for this stack are given in terms of before-stack and after-stack, but the changes are split up for ease of review, and also to show that this migration CAN happen per-component and is 100% opt-in. Most existing C++ components do not /need/ to change at all.

# Problem Statement

During certain renders (select critical scenarios in specific products), UIManagerBinding::createNode time takes over 50% of JS thread CPU time. This could be higher or lower depending on the specific product and interaction, but overall createNode takes a lot of CPU time. The question is: can we improve this? What is the minimal overhead needed?

The vast, vast majority of time is taken up by prop parsing (specifically, converting JS values across the JSI into concrete values on the C++ props structs). Other methods like appendChild, etc, do not take up a significant amount of time; so we conclude that createNode is special, and the JSI itself, or calling into C++, is not the problem. Props parsing is the perf problem.

Can we improve it? (Spoiler: yes)

# How does props parsing work today?

Today, props parsing works as follows:

1. The ConcreteComponentDescriptor will construct a RawPropsParser (one per component /type/, per application: so one for View, one for Image, one for Text... etc)
2. Once per component type per application, ConcreteComponentDescriptor will call "prepare" on the RawPropsParser with an empty, default-constructed ConcreteProps struct. This ConcreteProps struct will cause RawProps.at(field) for every single field.
3. Based on the RawProps::at calls in part 2, RawPropsParser constructs a Map from props string names (width, height, position, etc) to a position within a "value index" array.
4. The above is what happens before any actual props are parsed; and the RawPropsParser is now ready to parse actual Props.
5. When props are actually being parsed from a JSI dictionary, we now have two phases:
  1. The RawPropsParser `preparse`s the RawProps, by iterating over the JSI map and filling in two additional data structures: a linear list of RawValues, and a mapping from the ValueIndex array (`keyIndexToValueIndex_`; see step 3) to a value's position in the values list (`value_` in RawPropsParser/RawProps);
  2. The ConcretePropT constructor is called, which is the same as in step 2/3, which calls `fieldValue = rawProps.at("fieldName")` repeatedly.
  3. For each `at` call, the RawProps will look up a prop name in the Map constructed in step 3, and either return an empty value, or map the key name to the `keyIndexToValueIndex_` array, which maps to a value in `values_`, which is then returned and further parsed.

So, a few things that become clear with the current architecture:

1. Complexity is a property of the number of /possible/ props that /can/ be parsed, not what is actually used in product code. This violates the "only pay for what you use" principal. If you have `<View opacity={0.5} />`, the ViewProps constructor will request ~170 properties, not 1!
2. There's a lot of pre-parsing which isn't free
3. The levels of indirection aren't free, and make cache misses more likely and pipelining is more challenging
4. The levels of indirection also require more memory - minor, but not free

# How can we improve it?

The goal is to improve props parsing with minimal or zero impact on backwards-compability. We should be able to migrate over components when it's clear there's a performance issue, without requiring everything gets migrated over at once. This both (1) helps us prove out the new architecture, (2) derisks the project, (3) gives us time, internally and externally, to perfect the APIs and gradually migrate everything over before deleting the old infrastructure code entirely.

Thus, the goal is to do something that introduces a zero-cost abstraction. This isn't entirely possible in practice, and in fact this method slightly regresses components that do not use the new architecture /at all/, while dramatically improving migrated components and causing the impact of the /old/ architecture to be minimal.

# Solution

1. We still keep the existing system in place entirely.
2. After Props are constructed (see ConcreteComponentDescriptor changes) we iterate over all the /values/ set from JS, and call PropsT::setProp. Incidentally, this allows us to easily reuse the same prop for multiple values for "free", which was expensive in the old system.
3. It's worth noting that this makes a Props struct "less immutable" than it was before, and essentially now we have a "builder pattern" for Props. (If we really wanted to, we could still require a single constructor for Props, and then actually use an intermediate PropsBuilder to accumulate values - but I don't think this overhead would be worth for the conceptual "immutability" win, and instead a "Construct/Set/Seal" model works fine, and we still have all the same guarantees of immutability after the parsing phase)

# Implementation Details
# How to properly construct a single Prop value

Minor detail: parsing a single prop is a 3-step process. We imagine two scenarios: (1) Creating a new ShadowNode/Props A from nothing/void, so the previous Props value is just the default constructor. (2) Cloning a ShadowNode A->B and therefore Props A must be copied to Props B before parsing.

We will denote this as a clone from A->B, where A may or may not be a previous node or a default-constructed Props node; and imagine in particular that we're setting the "opacity" value for PropsB.

We must first (1) copy a value over from the previous version of the Props struct, so B.opacity = A.opacity; (2) Determine if opacity has been set from JS. If so, and there is a value, B.opacity = parse(JSValue). (3) If JS has passed in a value for the prop, BUT the value is `null`, it means that JS is resetting or deleting the prop, so we must set it BACK to the default. In this case we set PropsB.opacity = DefaultConstructedProps.opacity.

We must take care in general to ensure that the correct behavior is achieved here, which should help to explain some of the code below.

## String comparisons vs hash comparisons

In the previous system, a RawPropsKey is three `const char*` strings, concatenated together repeatedly /at runtime/. In practice, the ONLY reason we have the prefix, name, suffix Key structure is for the templated prop parsing in ViewProps and YogaStyableProps - that's it. It's not used anywhere else. Further, the key {"margin", "Left", "Width"} is identical to the key {"marginLeftWidth", null, null} and we don't do anything fancy with matching prefixes before comparing the whole string, or similar. Before comparison, keys are concatenated into a single string and then we use `strcmp`. The performance of this isn't terrible, but it's nonzero overhead.

I think we can do better and it's sufficient to compare hashed string values; even better, we can construct most of these /at compile time/ using constexpr, and using `switch` statements guarantee no hash collisions within a single Props struct (it's possible there's a collision between Props.cpp and ViewProps.cpp, for example, since they're different switch statements). We may eventually want to be more robust against has collisions; I personally don't find the risk to be too great, hash collisions with these keys are exceedingly unlikely (or maybe I just like to live dangerously). Thus, at runtime, each setProp requires computing a single hash for the value coming from JS, and then int comparisons with a bunch of pre-compiled values.

If we want to be really paranoid, we could be robust to hash collisions by doing `switch COMPILED_HASH("opacity"): if (strcmp(strFromJs, "opacity") == 0)`. I'm happy to do this if there's enough concern.

## Macros

Yuck! I'm using lots of C preprocessor macros. In general I found this way, way easier in reducing code and (essentially) doing codegen for me vs templated code for the switch cases and hashing prop names at compile-time. Maybe there's a better way.

Changelog: [Added][Fabric] New API for efficient props construction

Reviewed By: javache

Differential Revision: D37050215

fbshipit-source-id: d2dcd351a93b9715cfeb5197eb0d6f9194ec6eb9
2022-06-15 23:37:34 -07:00
Nikita Lutsenko 70788313fe react-native | Fix a crash on deserilization of props when using 'px'/'em' units.
Summary:
A huge set of props use YGValue directly, say something really basic like `margin`/`position`/`padding`/`border`.
All of these according to CSS spec actually support `number | "em" | "px" | %` units, but we are going to throw and hard crash on `em` and `px`, which are unsupported in React Native.

Using `tryTo` instead of `to` (noexcept vs throwing method) for conversion, and treating things like `margin: 50px` same way as we would treat `margin: false` which is not really supported.

Changelog:
    [General][Fixed] - Fixed a crash on deserialization of props when using 'px'/'em' units.

Reviewed By: bvanderhoof

Differential Revision: D37163250

fbshipit-source-id: 59cbe65a821052f6c7e9588b6d4a0ac14e344684
2022-06-15 00:12:58 -07:00
Pieter De Baets 34e51191e7 Optimize lookup of PlatformColor on Android
Summary:
We currently wrap colors in an object to make it look similar to a `PlatformColor` object, but since this is a hot codepath, let's just optimize it to a simple array of strings. The next step is to apply a layer of caching here, but this should be a simple improvement.

Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D31057046

fbshipit-source-id: f68e17167ddd5bba3b545d039600c7c9b40808f5
2022-06-10 16:20:22 -07:00
Kudo Chien c2088e1267 revert #33381 changes (#33973)
Summary:
https://github.com/facebook/yoga/pull/1150 is better than the tricky https://github.com/facebook/react-native/issues/33381 and fix the build error on react-native 0.69 with swift clang module. as https://github.com/facebook/yoga/pull/1150 is landed as 43f831b23c, i'm reverting the previous change, only leaving the necessary react_native_pods.rb change.

## Changelog

[iOS] [Changed] - Better fix for yoga + swift clang module build error

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

Test Plan: ci passed

Reviewed By: cortinico, cipolleschi

Differential Revision: D36998007

Pulled By: dmitryrykun

fbshipit-source-id: fa11bd950e2a1be6396f286086f4e7941ad2ff5b
2022-06-10 02:09:13 -07:00
Pieter De Baets 1b6584b9f5 Fix TurboModule binding improvements for TurboCxxModule
Summary:
TurboCxxModule doesn't use the the default JSI getter that TurboModule offers, and has custom behaviour for `getConstants` which broke the I18nAssets module in the binding experiment.

Changelog: [Internal]

Reviewed By: ryancat

Differential Revision: D37030917

fbshipit-source-id: 187f159abc76f792ad2c7045dc2852d216ea978d
2022-06-09 17:25:24 -07:00
Scott Kyle 68e4e91bd4 Support optional return types
Summary:
This fixes an issue in the C++ TurboModule codegen where optional return types would result in a compiler error because they were not being defaulted to `null` when converting to `jsi::Value`.

Changelog:
Internal

Reviewed By: javache

Differential Revision: D36989312

fbshipit-source-id: 525f9ce7a5638ba5a655fa69ba9647978030ab0b
2022-06-08 21:15:53 -07:00
Vincent Riemer 21a4c1f6d6 Add dispatch of pointerover/pointerout events
Summary: Changelog: [iOS][Internal] - Add dispatching of pointerover/pointerout events

Reviewed By: lunaleaps

Differential Revision: D36718156

fbshipit-source-id: c2fee2332ac52e617db938e321e3b38fd5c35ad3
2022-06-07 16:08:50 -07:00
Janic Duplessis 43f831b23c Make all headers public and add #ifdef __cplusplus (#1150)
Summary:
This change is mostly needed to support the new react-native architecture with Swift. Some private yoga headers end up being included in the swift build and result in compilation failure since swift cannot compile c++ modules. See https://github.com/facebook/react-native/pull/33381.

The most reliable fix is to include all headers as public headers, and add `#ifdef __cplusplus` to those that include c++. This is already what we do for other headers, this applies this to all headers.

Tested in the YogaKitSample, and also in a react-native app.

Changelog:
[iOS] [Changed] - Make all Yoga headers public and add #ifdef __cplusplus

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

Reviewed By: dmitryrykun

Differential Revision: D36966687

Pulled By: cortinico

fbshipit-source-id: a34a54d56df43ab4934715070bab8e790b9abd39
2022-06-07 07:42:49 -07:00
Joshua Gross b0c2b10cec Fix typo in width / height parsing
Summary:
Seems like an obvious typo! Whoops!

Not causing any known issues, but... this should be fixed.

Changelog: [Internal]

Reviewed By: genkikondo

Differential Revision: D36940476

fbshipit-source-id: d534ca3763b1f91e41c56953bf3d665e86db9e2b
2022-06-06 22:17:54 -07:00
Nicola Corti f1c614bd0e Build RN Tester with CMake (#33937)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33937

This moves the build of RNTester from Unix Make to CMake
This will serve as a blueprint for users that are looking into using CMake end-to-end in their buildls.

In order to make this possible I had to:
* Add an `Android-prebuilt.cmake` file that works similar to the `Android-prebuilt.mk` for feeding prebuilt .so files to the consumer build.
* Update the codegen to use `JSI_EXPORT` on several objects/classes as CMake has stricter visibility rules than Make
* Update the sample native module in `nativemodule/samples/platform/android/` to use CMake instead of Make

Changelog:
[Internal] [Changed] - Build RN Tester with CMake

Reviewed By: cipolleschi

Differential Revision: D36760309

fbshipit-source-id: b99449a4b824b6c0064e833d4bcd5969b141df70
2022-06-06 08:07:14 -07:00
Neil Dhar 0035cc9292 Fix throwing exceptions from asHostObject
Summary:
The current implementation of `throwJSError` places it in jsi.cpp, but
does not actually export it. This means that when JSI is being provided
by a dynamic library, `detail::throwJSError` will not be available.

To fix this, move the definition of `throwJSError` into jsi-inl.h,
similar to all of the other functions in the `detail` namespace. This
uses a roundabout implementation of `throwJSError` in order to avoid
directly using `throw`, which would fail to compile when exceptions are
turned off.

Changelog: [Internal]

Reviewed By: jpporto

Differential Revision: D36873154

fbshipit-source-id: bbea48e0d4d5fd65d67a029ba12e183128b96322
2022-06-03 15:04:46 -07:00
Joshua Gross 00751f64c7 Fix out-of-order prop parsing deoptimization in TextView/Paragraph
Summary:
See also D36889794. This is a very similar idea, except the core problem is that BaseTextProps is accessing the same props as ViewProps; and for ParagraphProps parsing, it first defers to ViewProps' parser and then BaseTextProps. RawPropsParser is optimized to access the same props in the same order, *exactly once*, so if we access a prop out-of-order, or for a second time, that access and the next access are deoptimized. Paragraph/Text, in particular, were quite bad because we did this several times, and each out-of-order access requires scanning /all/ props.

This fixes the issue, at least partially, by (1) pulling all the duplicate accesses to the beginning of BaseTextProps, and (2) accessing them all in the same order as ViewProps, relatively (some props are skipped, but that matters less).

Practically what this means is that now, all of Props' accesses have a cost of O(1) for lookup, or a total of O(n) for all of them; each access is at the n+1 position in the internal RawPropsParser array, so each access is cheap. BaseTextProps' duplicate accesses, even though there are only 4 of them: (1) the first one scans the entire array until we reach the prop in question; (2) the next accesses require scans, but not whole-array scans, since they're in order. (3) The BaseTextProps accesses /after/ the duplicate accesses are all O(1).

tl;dr is that before we had something like O(n*6) cost for BaseTextProps parsing and now it is O(n*2).

Similar to my summary in the last diff: we may want to revisit the RawPropsParser API... but I want to tread gently there, and this gets us a large improvement without major, risky changes.

Empirically, based on a couple of systraces, average time for a single UIManager::createNode called from JS thread, before this stack: 17us. After: 667ns (3% as long). On average, for every 60 createNode calls, we will save 1ms on the UI thread. The savings will be greater for certain screens that use many Views or Text nodes, and lesser for screens that use fewer of these components.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D36890072

fbshipit-source-id: 5d24b986c391d7bb158ed2f43d130a71960837d1
2022-06-02 23:36:54 -07:00
Joshua Gross 782e004e49 Fix pref deoptimizations due to out-of-order prop parsing
Summary:
Without getting into the weeds too much, RawPropParser "requires" that props be accessed in the same order every time a Props struct is parsed in order to most optimally fetch the values in a linear-ish fashion, basically ensuring that each rawProps.at() call is an O(1) operation, and overall getting all props for a particular component is O(n) in the number of props for a given struct. If props are called out of order, this breaks and worst-case we can end up with an O(n^2) operation.

Unfortunately, calling .at(x) twice with the same prop name triggers the deoptimized behavior. So as much as possible, always fetch exactly once and in the same order every time. In this case, we move initialization of two fields into the constructor body so that we can call .at() a single time instead of twice.

In the debug props of ViewProps I'm also reordering the fields to fetch them in the same order the constructor fetches them in, which will make this (debug-only) method slightly faster.

What's the impact of this? If you dig into the Tracery samples, the average/median RawPropsParser::at takes 1us or less. However, in /every single/ call to createNode for View components, there is at least one RawPropsParser::at call that takes 250+us. This was a huge red flag when analyzing traces, after which it was trivial (for View) to find the offending out-of-order calls. Since this is happening for every View and every type of component that derives from View, that's 1ms lost per every 4 View-type ShadowNodes created by ReactJS. After just 100 views created, that's 25ms. Etc.

There are other out-of-order calls lurking in the codebase that can be addressed separately. Impact scales with the size of the screen, the number of Views they render, etc.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D36889794

fbshipit-source-id: 91e0a7ca39ed10778e60a0f0339a4b4dc8b14436
2022-06-02 23:36:54 -07:00
Michael Lee (Engineering) 2d66bd4851 Rename the folly `headers_only` target to warn
Summary:
This target is not a good idea for a number of reasons:
1. It groups up multiple targets which breaks the dependency graph
2. It does not handle dependency remapping correctly
3. It has no mirror into fbcode

We should warn people this is a bad idea

Reviewed By: alexmalyshev

Differential Revision: D36519357

fbshipit-source-id: d60ca3237c7710118732578fecd1b2fc8903321b
2022-05-26 08:17:27 -07:00
Nicola Corti 26a54169f2 Remove unused Makefiles from React Native core
Summary:
This diff cleans up several Android Makefiles which we're not using anymore
as they've been replaced by CMake files.

There are still 3 Makefiles left, which I'm aiming to remove in the near future.

Changelog:
[Internal] [Changed] - Remove unused Makefiles from React Native core

Reviewed By: javache

Differential Revision: D36660902

fbshipit-source-id: 8afffac74d493616b0f9414567821cd69f4ef803
2022-05-25 07:54:06 -07:00
Pieter De Baets 5ae53cc051 Experiment with HostFunction caching in TurboModules
Summary:
Enables two new experiments (and the current behaviour as default) to speed up access to TurboModule methods from JS.

1) HostObject - Current behaviour
2) Prototype - Connect the TM HostObject via `__proto__`, and cache any methods accessed on the wrapper object.
3) Eager - Eagerly store all methods on the wrapper object, do not expose the HostObject to JS at all (TurboModules no longer need to be HostObjects in this scenario)

Changelog: [Internal]

Reviewed By: JoshuaGross, rubennorte, mdvacca

Differential Revision: D36590018

fbshipit-source-id: c9565eb239eb6aeee0f06b581ff8cd72a92073fc
2022-05-25 07:46:21 -07:00
Pieter De Baets d5045252f8 Cleanup TurboModuleBinding
Summary:
* Make constructor private, all access is through install()
* Use nullability of longLivedObjectCollection_ instead of separate bool disableGlobalLongLivedObjectCollection_

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D36592492

fbshipit-source-id: d65e779e1ac9fbe121937c5a20763aefcd589795
2022-05-25 07:46:21 -07:00
Rubén Norte 83631848d2 Permamently enable yielding in runtime scheduler
Summary: changelog: [internal]

Reviewed By: RSNara

Differential Revision: D36638658

fbshipit-source-id: 770d56abb2e2490684ab01e97e5cc7018f247fc8
2022-05-25 05:08:37 -07:00
Luna Wei 471907c047 PointerEvents: Mark when listened to for touch interactions
Summary: Changelog: [Internal] - Bypass dispatching an event if no view along the hierarchy is listening to it. Only applied for touch-based interactions. Next change will add optimization for mouse interactions

Reviewed By: vincentriemer

Differential Revision: D35739417

fbshipit-source-id: 134ffefef3bb4f97bf3e63b6bccc0caca464dfbd
2022-05-23 16:29:52 -07:00
Pieter De Baets 5451f890a1 Cache method IDs in JavaTurboModule
Summary:
Codegen a static field for every caller of `invokeJavaMethod` to cache the jmethodID that should be used for the method, which saves us a string-based name lookup at invocation time.

Changelog: [internal]

Reviewed By: genkikondo

Differential Revision: D36376056

fbshipit-source-id: 298430746a8f25a5337aba05b56876ba789e2344
2022-05-18 09:12:10 -07:00
Pieter De Baets d1541f169f Use fbjni boxed values for Java turbomodule arg conversion
Summary:
Simplify argument and result conversion by using existing fbjni helpers (which will cache class and method ID lookups already)

Changelog: [internal]

Reviewed By: RSNara

Differential Revision: D36312751

fbshipit-source-id: 16713642b2c5fb4c2b6447c30652d91ddbd88224
2022-05-18 09:12:10 -07:00
Pieter De Baets 56e9aa369f Avoid emitting mountitems for default values
Summary:
Noticed that we emit a large amount of (admittedly cheap) mountitems as part of node creation for values that are all zero (e.g. padding, overflowinset), which we can assume to be already initialised with these values on the native side.

There's a further opportunity to do this for State as well, as ReactImageComponentState exports just empty maps to Java.

Changelog: [Internal]

Reviewed By: genkikondo

Differential Revision: D36345402

fbshipit-source-id: 8d776ca124bdb9e1cd4de57a04e2785a9a0f918c
2022-05-18 05:44:11 -07:00
Pieter De Baets 3337add547 Pass string by ref in TurboModule lookup path
Summary:
Avoid unnecessary string copies

Changelog: [internal]

Reviewed By: nlutsenko

Differential Revision: D36312750

fbshipit-source-id: caf0985f988eb497de3be3c0526809593b01a9e2
2022-05-13 07:12:48 -07:00
Pieter De Baets a897314f82 Cleanup TurboModule constructor and headers
Summary:
Avoid copying of std::string and pass std::shared_ptr by reference where possible.

Changelog: [Internal]

Reviewed By: appden

Differential Revision: D36311151

fbshipit-source-id: b0cc791e5eb8353c172d256c69b166d2bdd0db27
2022-05-12 05:49:01 -07:00
Vincent Riemer 87d2a8d06e Only fire pointerEnter/Leave events if a view in the event path is listening to that event
Summary: Changelog: [iOS][Internal] - Only fire pointerEnter/Leave events if a view in the event path is listening to that event

Reviewed By: yungsters

Differential Revision: D35911045

fbshipit-source-id: 8b3021619622c3e83c15acea46c23bfe3e0f9284
2022-05-10 15:43:28 -07:00
Anandraj Govindan 883a93871c Working around Long paths limitation on Windows (#33784)
Summary:
Cherry picking https://github.com/facebook/react-native/pull/33707 to main branch

This change is extending the changes made by alespergl to reduce the file paths and command lengths of ndk build commands
Essentially we are shortening the length of the source files by using relative paths instead of absolute paths as enumerated by the wildcard expression
This commit is extending the fix by including all the new modules introduced into RN for the new architecture, including the generated modules.
We are also reverting the ndk bump as ndk23 is crashing frequently when building RN with new arch. The reduced file paths lengths ensures the ndk bump is not required for relatively short application paths.

Fix building RN with new architecture on Windows boxes by using relative paths for C++ sources

## Changelog

Fix building RN with new architecture on Windows boxes by using relative paths for C++ sources

[CATEGORY] [TYPE] - Message

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

Test Plan: Verified building on windows box

Reviewed By: javache

Differential Revision: D36241928

Pulled By: cortinico

fbshipit-source-id: 1ce428a271724cbd3b00a24fe03e7d69253f169b
2022-05-09 04:42:53 -07:00
Sam Zhou 0c4c6ca319 Add annotations to unannotated variable declarations [manually-modified]
Reviewed By: panagosg7

Differential Revision: D35948108

fbshipit-source-id: 7d286c9dd66dbd25281e2d831691f8bb34504b5d
2022-04-27 19:15:55 -07:00
Baoshuo Ren dfc24fa1ed chore: remove git.io (#33715)
Summary:
All links on git.io will stop redirecting after April 29, 2022. So I removed it.

- https://github.blog/changelog/2022-04-25-git-io-deprecation/

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

Reviewed By: GijsWeterings

Differential Revision: D35933602

Pulled By: cortinico

fbshipit-source-id: 656282f3e506b984f4a72e7449320a8241e569c5
2022-04-27 03:34:02 -07:00
Ramanpreet Nara b4ebc98e51 Log error when TMMDelegate getModuleForClass returns nil
Summary:
Ideally, the application should always be able to create the TurboModule object given an ObjC class. This debugging information will help track down these classes of issues, when they surface.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D35945399

fbshipit-source-id: 1621a4a64bc8fb0411123fb1470bbb52ccf0edcf
2022-04-26 16:30:29 -07:00
Ramanpreet Nara 7f3cc256b5 Prevent Nullptr segfault in TurboModule init path
Summary:
During the TurboModule init path, the TurboModuleManager asks the application to create the TurboModule object, given its class.

If the application is unable to create the TurboModule object, what should we do?
0. **What we do now:** Continue executing TurboModule init path.
1. Silently return nil early.
2. Silently return nil early, and RCTLogError.

If we Continue executing the TurobModule init path, we'll run into a segfault, because we'll call objc_setAssociatedObject(nil, ...).

This diff prevents that segfault, by doing a silent return of nil.

Changelog: [iOS][Fixed] - Prevent Nullptr segfault in TurboModule init path

Reviewed By: fkgozali

Differential Revision: D35942323

fbshipit-source-id: 7755800379c4bc733502314f3af3f401e9b04872
2022-04-26 16:30:29 -07:00
Nicola Corti 59385e8e90 Expose private node management methods in UIManager (#33688)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33688

These methods used to be public in the legacy implementation, and hiding them significantly reduces amount of customization available to other clients outside Fabric core.

Changelog: [Internal] Allow external callers to call UIManager methods

Reviewed By: cipolleschi

Differential Revision: D35818114

fbshipit-source-id: 4dc4177c82b5db9ae3d136a1a83f5ec3123b971f
2022-04-26 05:11:05 -07:00
Nicola Corti 54db5f2012 Expose UIManager from Scheduler (#33545)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33545

Exposes `UIManager` instance for access from third-party modules.

Changelog: [Changed] Exposes `UIManager` instance for third-party access.

Reviewed By: javache

Differential Revision: D35314058

fbshipit-source-id: 1922c2afc37b105b153a82f45e5bac9c0b0cdfae
2022-04-26 05:11:05 -07:00
Nicola Corti e51e19ecc1 Add event listeners to Scheduler
Summary:
Minimal set of changes to intercept events in external modules. Current intended use-case is for Reanimated to handle events for the Animated properties.

Changelog: [Added] Add listeners to allow intercepting events in C++ core.

Reviewed By: cipolleschi

Differential Revision: D35312534

fbshipit-source-id: ec924b57fd0c0dabf7be7b886dbef23bf3170d6c
2022-04-26 05:11:05 -07:00
Oleksandr Melnykov fc1f5bbb92 Ensure correct instance for transaction telemetry
Summary:
Ensures that transaction telemetry modified by transaction controller is the same as sent in the view callbacks.

Changelog: [Internal]

Reviewed By: cortinico, cipolleschi

Differential Revision: D35827347

fbshipit-source-id: 123ae01d4a7fe1a9c97ebccae3ae248f7f2cf654
2022-04-25 04:14:39 -07:00
Oleksandr Melnykov 3a721f48b1 Pass mutation list to RCTMountingTransactionObserving callbacks
Summary:
Re-land of previous reverted commit.

Changelog: [Internal]

Reviewed By: cortinico, cipolleschi

Differential Revision: D35843710

fbshipit-source-id: 3adde4fba2f2702ad5b85b3b52b2f68843c6c9f2
2022-04-25 04:14:39 -07:00
MaeIg db284ae037 Don't capitalize words starting by a number (fabric renderer) (#33629)
Summary:
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

Few month ago, I created a [pull request](https://github.com/facebook/react-native/pull/32774) to unify the behavior of capitalize style between Android and IOS.

But, I found out that it doesn't work when fabric is enabled. We have the old behavior :
| Android | IOS |
| ------------- | ------------- |
| <img width="458" alt="capitalize_android_fabric" src="https://user-images.githubusercontent.com/40902940/163182082-4061003c-230b-46f7-9e93-c34b66dbf3d2.png"> | <img width="476" alt="capitalize_ios_fabric" src="https://user-images.githubusercontent.com/40902940/163182124-b6dee450-46e3-41a3-b5bb-553d7c2662e6.png"> |
(source: rn-tester, last commit: dac56ce)

As fabric is now live since v0.68, we should fix this behavior for fabric aswell.

I don't know why there is so much duplicated code between `ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm` and `Libraries/Text/RCTTextAttributes.m` because I don't know the architecture of the project very well. But if you see missing tests or some refacto to do I'm open to suggestions!

## 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] [Fixed] - Don't capitalize the first letter of a word that is starting by a number (Fabric renderer)

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

Test Plan:
I manually tested these changes on rn-tester (react-native `main` branch):
| Fabric ? | Android | IOS |
| ------------- | ------------- | ------------- |
| YES | <img width="458" alt="capitalize_android_fabric" src="https://user-images.githubusercontent.com/40902940/163182082-4061003c-230b-46f7-9e93-c34b66dbf3d2.png"> | <img width="476" alt="capitalize_ios_fabric_after" src="https://user-images.githubusercontent.com/40902940/163184277-6c58c117-7144-4f6b-98ea-0c1db654f27b.png"> |
| NO | <img width="458" alt="android_nf_after" src="https://user-images.githubusercontent.com/40902940/163190263-9d801f6a-09c2-4ec6-a841-3dca115a5ef7.png"> | <img width="476" alt="ios_nf_after" src="https://user-images.githubusercontent.com/40902940/163190333-7e9eac6a-3f28-4826-8ef9-bcf45bf870a9.png"> |

Reviewed By: cortinico

Differential Revision: D35611086

Pulled By: GijsWeterings

fbshipit-source-id: 0c43807dcddb30e65921eb1525c0fe440162ec32
2022-04-22 06:15:21 -07:00
Oleksandr Melnykov 2f5a1e6124 Back out "Pass mutation list to RCTMountingTransactionObserving callbacks"
Summary:
https://fb.workplace.com/groups/fbapp.commerce.engsupport/permalink/2074812256012212/

Back out "[react-native][PR] Pass mutation list to RCTMountingTransactionObserving callbacks"

Original commit changeset: f40afc512f2c

Original Phabricator Diff: D35214478 (91fc2c0091)

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D35825832

fbshipit-source-id: b53b616dca39c84b3a8e8e4cbaa4a45834e53fe3
2022-04-21 16:27:57 -07:00
Krzysztof Magiera 91fc2c0091 Pass mutation list to RCTMountingTransactionObserving callbacks (#33510)
Summary:
This PR updates `RCTMountingTransactionObserving` protocol to accept full `MountingTransaction` object as an argument to its methods as opposed to just `MountingTransactionMetdata` which contained only some subset of information.

This change makes it possible for components implementing the protocol to analyze the list of mutations and hence only take action when certain mutations are about to happen.

One of the use cases for `RCTMountingTransactionObserving` protocol is to allow for Modal to take view snapshot before it is closed, such that an animated close transition can be performed over the snapshotted content. Note that when modal is removed from the view hierarchy its children are gone too and therefore the snapshot mechanism makes it possible for children to still be visible while the animated closing transition is ongoing. A similar use-case to that can be seen in react-native-screens library, where we use the same snapshot mechanism for views that are removed from navigation stack.

Before this change, we'd use `mountingTransactionDidMountWithMetadata` to take a snapshot. However, making a snapshot of relatively complex view hierarchy can be expensive, and we'd like to make sure that we only perform a snapshot when the given modal is about to be removed. Because the mentioned method does not provide an information about what changes are going to be performed in a given transaction, we'd make the snapshot for every single view transaction that happens while the modal is mounted.

In this PR we're updating `RCTMountingTransactionObserving` protocol's methods, in particular, we rename methods to no longer contain "Metadata" in them and to accept `MountingTransaction` as the only argument instead of `MountingTransactionMetadata` object. With this change we are also deleting `MountingTransactionMetadata` altogether as it has no uses outside the protocol. Finally, we update the two uses of the protocol in `RCTScrollViewComponentView` and `RCTModalHostViewComponentView`.

## Changelog

[iOS][Fabric] - Update RCTMountingTransactionObserving protocol to consume MountingTransaction objects

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

Test Plan:
As there are not that many uses of `RCTMountingTransactionObserving` protocol during testing I focused on checking if the updated method is called and if the provided objects contains the proper data. Unfortunately, despite code for the modal protocol being present in OSS version it does seem like some parts of modal implementation are still missing and the component only renders an unimplemented view (checked this with rn-tester). I only managed to verify the use in `RCTScrollViewComponentView` with the following steps:
1. Build for iOS
2. Put a breakpoint in mountingTransactionDidMount method in `RCTScrollViewComponentView.mm`
3. Verify that the program stops on the breakpoint when a scrollview is rendered (use any screen on rn-tester app)
4. Inspect the provided object in the debugger (ensure the list of transactions is not empty)

Outside of that we verified the transactions can be processed in `mountingTransactionDidMount` after the changes from this PR are applied in FabricExample app in [react-native-screens](https://github.com/software-mansion/react-native-screens/tree/main/FabricExample) repo.

Reviewed By: cipolleschi

Differential Revision: D35214478

Pulled By: ShikaSD

fbshipit-source-id: f40afc512f2c8cfa6262d2fb82fb1ccb05aa734c
2022-04-21 05:10:21 -07:00
Richard Howell 7d4f6840f6 add casts for implicit int to float
Summary: Apply //fbobjc/Tools/cAST:implicit_conversion to existing warnings

Reviewed By: adamjernst

Differential Revision: D35692786

fbshipit-source-id: 13fb4f8a6b6e701c324b00c682943a4b3d80de72
2022-04-18 11:51:50 -07:00
Anand Bashyam da48d0dc63 Back out "Revert D35705825: [JSI] Fix typo in Value's constructor with a Symbol"
Summary:
During the sheriff shift, incorrectly reverted a diff. fixing it by reverting the revert.

Original commit changeset: b5a6c9f6f576
Original Phabricator Diff: D35705825 (a7a0f86a73)

See : https://fb.workplace.com/groups/mobile.sheriffs/posts/8461935673854973/?comment_id=8462686143779926

The current JSI implementation is converting a Symbol to String when creating a jsi Value.
Changelog: [General][Fixed]

Reviewed By: neildhar

Differential Revision: D35710710

fbshipit-source-id: d36667001002032a37569c9bc5288d10b9bc7011
2022-04-18 10:08:22 -07:00
Anand Bashyam 82f2b1d4e9 Revert D35705825: Fix typo in Value's constructor with a Symbol
Differential Revision:
D35705825 (a7a0f86a73)

Original commit changeset: 3bee0a02bb77

Original Phabricator Diff: D35705825 (a7a0f86a73)

fbshipit-source-id: b5a6c9f6f576ea1771dca8977b394bd90064c669
2022-04-17 12:51:12 -07:00
John Porto a7a0f86a73 Fix typo in Value's constructor with a Symbol
Summary:
The current JSI implementation is converting a Symbol to String when creating a jsi Value.

Changelog: [General][Fixed]

Reviewed By: neildhar

Differential Revision: D35705825

fbshipit-source-id: 3bee0a02bb77643c6a33031b4d98ac9a7e126303
2022-04-17 11:53:12 -07:00
NikoAri 3f98c8e4c2 Avoid full copy of large folly::dynamic objects by switching to std::move semantics (#33621)
Summary:
Problem:
Current creation of ModuleConfig does a full copy of folly::dynamic object, which for large objects can cause 1000's of memory allocations, and thus increasing app's memory footprint and speed.

Fix:
Use std::move semantics to avoid copy of folly::dynamic, thus avoiding memory allocations.

## Changelog

[General] [Fixed] - Avoid full copy of large folly::dynamic objects by switching to std::move semantics

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

Test Plan:
Compiled React Native for Windows
Consumed into Microsoft Excel App
Tested functionality through Microsoft Office Excel App
Viewed Memory Allocations in Debugger

Reviewed By: cortinico

Differential Revision: D35599759

Pulled By: RSNara

fbshipit-source-id: 095a961422cca4655590d2283f6955472f1f0410
2022-04-13 16:26:55 -07:00
Hugo Cuvillier 52d8a797e7 Use logical operator instead of bit operation
Summary:
I guess it's the same since we're working on a `bool` but... this causes some compilation error.

Changelog:
[General][iOS] - Fix compilation warning in yoga

Reviewed By: Andrey-Mishanin

Differential Revision: D35438992

fbshipit-source-id: 22bb848dfee435ede66af0a740605d4618585e18
2022-04-12 09:27:25 -07:00
Alex Landau 9bac0b77d0 Fix warnings about inconsistent override keyword
Summary:
The `override` keyword was used for some overriden methods and was not
used for others. This caused the `-Winconsistent-missing-destructor-override`
warning to show up, and since in some cases we build with `-Werror`, this broke
the build.

This diff adds the missing `override` keyword in a few places.

Changelog:
[Internal][Fixed] - Build issues

Reviewed By: kodafb

Differential Revision: D35513149

fbshipit-source-id: 92bca699f1be163189487d50c1050402df2ff038
2022-04-11 16:19:51 -07:00
Vincent Riemer c5cb707ba8 Add basic onPointerEnter/Leave event emitting to iOS
Summary: Changelog: [Internal] Add basic onPointerEnter/Leave event emitting to iOS

Reviewed By: lunaleaps

Differential Revision: D35414116

fbshipit-source-id: dd62cf7736c466e328b9ebbf51bf010610f4bd92
2022-04-11 15:49:30 -07:00
Kudo Chien 65abc361bf Fix ios build error when podfile generate_multiple_pod_projects=true and fabric is on (#33381)
Summary:
there are build errors happened when in [`generate_multiple_pod_projects`](https://blog.cocoapods.org/CocoaPods-1.7.0-beta/#multiple-xcodeproj-generation) mode and fabric is on. since we have multiple pod projects, there are something breaks.

### `-DRCT_NEW_ARCH_ENABLED=1` does not pass to `RCTAppSetupUtils.mm`

because `installer.pods_project` is targeting `Pods.xcodeproj` but not `React-Core.xcodeproj`. we should use ` installer.target_installation_results.pod_target_installation_results` to deal with `generate_multiple_pod_projects` mode.

### fatal error: 'CompactValue.h' file not found

```
In file included from /path/to/react-native/packages/rn-tester/build/generated/ios/react/renderer/components/rncore/Props.cpp:11:
In file included from /path/to/react-native/packages/rn-tester/Pods/Headers/Private/React-Codegen/react/renderer/components/rncore/Props.h:13:
In file included from /path/to/react-native/packages/rn-tester/Pods/Headers/Private/React-Fabric/react/renderer/components/view/ViewProps.h:11:
In file included from /path/to/react-native/packages/rn-tester/Pods/Headers/Private/React-Fabric/react/renderer/components/view/YogaStylableProps.h:10:
/path/to/react-native/packages/rn-tester/Pods/Headers/Public/Yoga/yoga/YGStyle.h:16:10: fatal error: 'CompactValue.h' file not found
#include "CompactValue.h"
         ^~~~~~~~~~~~~~~~
1 error generated.
```

`Props.cpp` -> `YogaStylableProps.h` -> `YGStyle.h` -> `CompactValue.h`
[`CompactValue.h` is internal private header for Yoga pod](4eef075a58/ReactCommon/yoga/Yoga.podspec (L54-L56)) where `React-Codegen` project cannot access to.

~there are some solutions toward this problem. one way is to make other yoga headers as public headers. i am not sure whether this solution would introduce any side effects. so i only make necessary projects to search yoga private headers.~

Update: a solution is to expose all yoga headers publicly.  however, CocoaPods will put all public headers to module umbrella header. this will break YogaKit (swift) integration because swift module doesn't support c++. my pr is trying to expose all yoga headers to `$PODS_ROOT/Headers/Public/Yoga/yoga`, but use custom `module_map` to control which headers should be exposed to the swift module. CocoaPods's custom module_map has some limitation where cannot well support for both `use_frameworks!` mode and non use_frameworks! mode. there's a workaround to use `script_phase` copying the umbrella header to right place.

## Changelog

[iOS] [Fixed] - Fix iOS build error when Podfile `generate_multiple_pod_projects=true` and Fabric is on

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

Test Plan:
verify with rn-tester

1. add `generate_multiple_pod_projects`

```diff
 --- a/packages/rn-tester/Podfile
+++ b/packages/rn-tester/Podfile
@@ -5,7 +5,7 @@ platform :ios, '11.0'

 # Temporary solution to suppress duplicated GUID error.
 # Can be removed once we move to generate files outside pod install.
-install! 'cocoapods', :deterministic_uuids => false
+install! 'cocoapods',  :generate_multiple_pod_projects => true, :deterministic_uuids => false

 USE_FRAMEWORKS = ENV['USE_FRAMEWORKS'] == '1'

```

2. pod install and build rn-tester from xcode

Reviewed By: cortinico

Differential Revision: D34844041

Pulled By: dmitryrykun

fbshipit-source-id: 93311b56d8e44491307a911ad58442f267c979eb
2022-04-11 06:04:20 -07:00
Vincent Riemer 179c24e255 Emit touch-equivalent W3C pointer events on iOS
Summary: Changelog: [Internal] Emit touch-equivalent W3C pointer events on iOS

Reviewed By: lunaleaps

Differential Revision: D35295104

fbshipit-source-id: 1c1d5a4159bbfed92df151f7e12a4973ec44e970
2022-04-07 14:07:58 -07:00
Chris Olszewski daa105aba5 Fixup typo in pfh labels
Summary:
Now that the PFH node has been renamed this updates the pfh label.

Produced via `xbgs -l -e '"pfh:ReactNative_CommonInfrastructurePlaceholde"' | xargs sed -i 's/"pfh:ReactNative_CommonInfrastructurePlaceholde"/"pfh:ReactNative_CommonInfrastructurePlaceholder"/'`

Reviewed By: jkeljo

Differential Revision: D35374087

fbshipit-source-id: 61590f69de5a69ec3b8a0478f6dd43409de3c70b
2022-04-05 12:15:05 -07:00
John Porto fefa7b6ac8 Add support for devtools' profiler
Summary:
Add support for analyzing sampling profiler data in devtools' JavaScript Profiler tab.

Changelog: [Added]

Reviewed By: neildhar

Differential Revision: D34114709

fbshipit-source-id: 1bf02ce02a250f68af1189c6516fb79795a8e887
2022-04-01 23:03:55 -07:00
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
David Vacca 3fb3ce4fa2 Delete TextMeasurement destructor
Summary:
TextMeasurement destructor is not necessary, we are deleting it

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D34246015

fbshipit-source-id: 6ca4803fafc8b195828d546ba8fb45353257f383
2022-02-27 22:23:48 -08:00
David Vacca 926ab6ca26 Mark TextLayoutManager as not copyable / not movable
Summary:
TextLayoutManger should be not copyable / not movable

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D34246013

fbshipit-source-id: dc20db2ad9e2709ddca5bef5218356bd2b292c2d
2022-02-27 22:23:48 -08:00
Paige Sun 6e03945c7f Use @synthesize viewRegistry_DEPRECATED for Keyframes to remove RCTWeakViewHolder hack
Summary:
Changelog: [iOS][Internal] Use synthesize viewRegistry_DEPRECATED for Keyframes to remove RCTWeakViewHolder

Remove the `RCTWeakViewHolder` hack, since it can be replaced with `viewRegistry_DEPRECATED viewForReactTag`.

Reviewed By: RSNara

Differential Revision: D34468082

fbshipit-source-id: be41ed2df6ee195409724f6069fd99a793dca01a
2022-02-25 13:45:22 -08:00
Paige Sun 34c953f398 4/5 Attach @synthesize ivars to RCTViewManagers using RCTBridgeModuleDecorator in Bridgeless mode
Summary:
Changelog: [iOS][Internal] 4/5 Attach synthesize ivars to RCTViewManagers using RCTBridgeModuleDecorator in Bridgeless mode

- In RCTInstance, insert RCTBridgeModuleDecorator into RCTInstance into contextContainer
- In LegacyViewManagerInteropComponentDescriptor.mm, unwrap RCTBridgeModuleDecorator from contextContainer
- Then pass RCTBridgeModuleDecorator from LegacyViewManagerInteropComponentDescriptor to RCTLegacyViewManagerInteropCoordinator
- In RCTLegacyViewManagerInteropCoordinator, call `RCTBridgeModuleDecorator attachInteropAPIsToModule` to attach synthesize ivars to all RCTViewManagers.

This does not affect Bridge mode.

Reviewed By: RSNara

Differential Revision: D34439950

fbshipit-source-id: d814c56a52f226e3a2c96fea01efb51afc571721
2022-02-25 08:50:34 -08:00
Pieter De Baets dc50308994 Remove default usages of enable_exceptions/rtti
Summary: Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D34379947

fbshipit-source-id: abff08ec99cff60d16ff82b7c0422d72caffd59b
2022-02-25 07:46:11 -08:00
Pieter De Baets 4b1c8584e1 Remove size_ field from RawPropsParser
Summary:
`size_` will always match `keys_.size()` so we don't have to keep track of it.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D34391445

fbshipit-source-id: f6c9316c989137425abfb7b3d72b571d08240f34
2022-02-25 04:08:01 -08:00
Andrei Shikov 78f6cdf2be Fix OSS native Android build (#33167)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33167

The build is failing with:

```
error: undefined reference to 'folly::SharedMutexImpl<false, void, std::__ndk1::atomic, folly::SharedMutexPolicyDefault>::unlock_shared()'
```

Indicating missing link to `folly_futures`.

Changelog: [Internal]

Reviewed By: cortinico, GijsWeterings

Differential Revision: D34419236

fbshipit-source-id: ca777e0c3a13c2f23791a94b13de18911c93edd5
2022-02-23 09:23:21 -08:00
Andrei Shikov 1953f6f02e Exclude raw props from view shadow nodes
Summary:
With the `MapBuffer`-based props calculated from C++ props, there's no need to keep `rawProps` around for Android views.

This change makes sure that the `rawProps` field is only initialized under the feature flag that is responsible for enabling `MapBuffer` for prop diffing, potentially decreasing memory footprint and speeding up node initialization as JS props don't have to be converted to `folly::dynamic` anymore.

For layout animations, props rely on C++ values, so there's no need to update `rawProps` values either.

Changelog: [Internal][Android] - Do not init `rawProps` when mapbuffer serialization is used for ViewProps.

Reviewed By: mdvacca

Differential Revision: D33793044

fbshipit-source-id: 35873b10d3ca8b152b25344ef2c27aff9641846f
2022-02-22 17:23:05 -08:00
Andrei Shikov 733f228506 Diff C++ props for Android consumption
Summary:
Creates a mapbuffer from two ViewProp objects. This MapBuffer is used later instead of bag of props from JS to set the properties with platform ViewManager.

Changelog: [Internal] - Added MapBuffer diffing for ViewProps

Reviewed By: mdvacca

Differential Revision: D33735246

fbshipit-source-id: 10ad46251ea71aa844586624c888f5223fa44e57
2022-02-22 08:23:40 -08:00
Andrei Shikov da72b5d02c Add accessibility and view props required for Android to C++ layer
Summary:
Parses a set of props previously missing from C++ representation (they weren't required for iOS and core processing before).

Changelog: [Internal] - Added missing fields for Android to C++ view props

Reviewed By: sammy-SC

Differential Revision: D33797489

fbshipit-source-id: 1625baa0c1a592fcef409a5f206496dff0368912
2022-02-22 08:23:40 -08:00
Samuel Susla b8662f8f8a Remove mobile config remove_outstanding_surfaces_on_destruction_android
Summary:
changelog: [internal]

fewer flags = fewer problems.

Reviewed By: javache

Differential Revision: D34380114

fbshipit-source-id: c7213bd31e253fabeefc2514c7b51611d7c47e4e
2022-02-22 07:23:16 -08:00
Pieter De Baets d31c0c9109 Avoid string copy in RawPropsKey comparison
Summary:
Small performance improvement since we don't need to copy the char * into a string just for the sake of comparison.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D34351387

fbshipit-source-id: 10163164f6e95ab0737e8f865c37d8f0c3500662
2022-02-22 03:23:12 -08:00
Samuel Susla bb7214b9c4 Allow tests to be executed in platform agnostic environment
Summary:
changelog: [internal]

Make ManagedObjectWrapper compile in platform independent environment.

Reviewed By: ryancat

Differential Revision: D34302957

fbshipit-source-id: 50bf296983525c48cda1e532934b9998077c9fbf
2022-02-18 09:23:27 -08:00
Samuel Susla 5e88223d85 Add support for nested components in legacy interop
Summary: changelog: [internal]

Reviewed By: ShikaSD

Differential Revision: D34173837

fbshipit-source-id: 09fbf12e9d8eb13a170ff92afff97f203d0ef805
2022-02-18 07:11:44 -08:00
Pieter De Baets 45af635b1e Fix some nits/typos in MapBuffer
Summary:
Was trying out some behaviour when using the MapBuffer experiment and fixed some small issues.

Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D34108859

fbshipit-source-id: 550ca0847419006ec17472cc4b70d38fc8d05396
2022-02-15 14:06:42 -08:00
Neil Dhar 9010bfe457 Add PropNameID::fromSymbol
Summary:
Changelog:
[General][Added] - Add ability to access properties with symbol keys through JSI

Reviewed By: mhorowitz

Differential Revision: D33830544

fbshipit-source-id: 8de366b4c7d5ea9d2fd5df70dfb776a056e23806
2022-02-14 22:29:16 -08:00
Genki Kondo 49f3f47b1e Support color animation with native driver for iOS
Summary:
Adds support for Animated.Color with native driver for iOS. Reads the native config for the rbga channel AnimatedNodes, and on update(), converts the values into a SharedColor.

Followup changes will include support for platform colors.

Ran update_pods: https://www.internalfb.com/intern/wiki/React_Native/Preparing_to_Ship/Open_Source_Pods/

Changelog:
[iOS][Added] - Support running animations with AnimatedColor with native driver

Reviewed By: sammy-SC

Differential Revision: D33860583

fbshipit-source-id: 990ad0f754a21e3939f2cb233bcfa793ef12eb14
2022-02-10 11:18:39 -08:00
Andrei Shikov 980c52de41 Disable view flattening when the view has event handlers on Android
Summary:
The views with touch event props are currently flattened by Fabric core, as we don't take event listeners into account when calculating whether the view should be flattened. This results in a confusing situation when components with touch event listeners (e.g. `<View onTouchStart={() => {}} /> `) or ones using `PanResponder` are either ignored (iOS) or cause a crash (Android).

This change passes touch event props to C++ layer and uses them to calculate whether the view node should be flattened or not. It also refactors events to be kept as a singular bitset with 32 bit (~`uint32_t`).

Changelog: [Changed][General] Avoid flattening nodes with event props

Reviewed By: sammy-SC

Differential Revision: D34005536

fbshipit-source-id: 96255b389a7bfff4aa208a96fd0c173d9edf1512
2022-02-10 06:07:39 -08:00
John Porto b467094f18 Add StringPrimitive::create for UTF8 strings
Summary:
This is pre-work for adding the v8 stack trace API support.

Changelog: [Internal]

Reviewed By: kodafb

Differential Revision: D34048366

fbshipit-source-id: 9d2b469767f7669cb428c61b215f193894892c03
2022-02-10 05:00:32 -08:00
Chiara Mooney 42b391775f Fix ReactCommon Break for Windows (#33047)
Summary:
Changes to MapBuffer code in aaff15c...d287598 broke build for Windows. Errors included incompatible type conversions, the use of `__attribute__(__packed__)` which is only supported by GCC and Clang, and the usage of designated initializers which are only supported on C++20.

Changes here restore build on Windows.

## 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 build break on Windows with ReactCommon

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

Test Plan: React Native project built on Windows and passes react-native-windows repository pipeline. These edits are currently merged into the main branch of react-native-windows.

Reviewed By: ShikaSD

Differential Revision: D34101367

Pulled By: philIip

fbshipit-source-id: 1596365c2e92f377c6375805b33de5e1c7b78e66
2022-02-09 13:03:10 -08:00
Andrei Shikov 3112238b14 De-duplicate conversion of SharedColor to Android int value
Summary:
Removes duplicated code in SharedColor conversions. The original copy was done for the MapBuffer experiment, as the method was returning `folly::dynamic` instead of integer. Nothing prevents us from returning integer here directly, so we can keep one implementation.

Changelog: [Internal] - Removed duplicated SharedColor conversion for Android

Reviewed By: javache

Differential Revision: D33797490

fbshipit-source-id: 196657f0616e6cb7e987225b76328fe77fd6c28a
2022-02-09 10:26:30 -08:00
Pieter De Baets a75bbe7552 Fix docs in ModalHostView headers
Summary:
Copy-paste error

Changelog: [Internal]

Reviewed By: genkikondo

Differential Revision: D34077530

fbshipit-source-id: 04ab17ba9308762361d993b7ed1b372af400b8d1
2022-02-09 03:03:09 -08:00
CodemodService FBSourceClangFormatLinterBot e737270d11 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D34099214

fbshipit-source-id: 7a1fc8550968d8b87f016e4bf706252bf03e4483
2022-02-08 19:15:34 -08:00
Neil Dhar 5b66bb90c6 Add missing symbol handling in kindToString
Summary: Changelog: [Internal]

Reviewed By: kodafb

Differential Revision: D34062869

fbshipit-source-id: 08fed59d62b0d0a46e0868874a89b125731a44e5
2022-02-08 15:18:15 -08:00
Raphael Herouart 669cd0257c Test Chrome DevTools Notifications
Summary:
Some test to make sure hermes engine follows the Chrome DevTools Protocol for all implemented Debugger Notifications
Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D34055503

fbshipit-source-id: 8c2dd1066ba2b68e395226f15954d303894d0365
2022-02-08 06:46:31 -08:00
Raphael Herouart 921ed737eb Test Chrome DevTools Protocol Responses Format
Summary:
Some test to make sure hermes engine follows the Chrome DevTools Protocol for all implemented Debugger Responses
Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D34052619

fbshipit-source-id: d213ed41335b64bf3168a43ce043f2c57f05fc52
2022-02-08 06:46:30 -08:00
Samuel Susla d79f658016 Rename RuntimeScheduler::callImmediates to RuntimeScheduelr::callExpiredTasks
Summary:
changelog: [internal]

Rename method so it does not collide with immediates that already exist in React Native.

Reviewed By: javache

Differential Revision: D34041418

fbshipit-source-id: 0ae75b683983c3be50320b195a7068d7178b0ed8
2022-02-07 10:06:07 -08:00
Raphael Herouart 31a92b008d Add some tests for compliance to the Chrome DevTools Protocol
Summary:
Some test to make sure hermes engine follows the Chrome DevTools Protocol for all implemented Debugger Messages

Changelog: [Internal]

Reviewed By: ShikaSD

Differential Revision: D34042008

fbshipit-source-id: 3a074e9840706ca977ff86d050e67b0dcea5c7ef
2022-02-07 09:06:31 -08:00
Samuel Susla ee454e4f0b Add description to ConcreteComponentDescriptor::adopt
Summary: changelog: [internal]

Reviewed By: javache

Differential Revision: D34041312

fbshipit-source-id: 3b6d650034481813273f67444426e2fa5cb7d59f
2022-02-07 09:03:56 -08:00
Andrei Shikov 2bc883e6b7 Back out "Implement Runtime.getHeapUsage for hermes chrome inspector"
Summary:
The new messages are breaking SparkAR VSCode debugger
Original commit changeset: 49d863e6a58d
Original Phabricator Diff: D33616658 (3568a72987)
Changelog: [Internal]

Reviewed By: the-over-ape

Differential Revision: D34003669

fbshipit-source-id: 5327820cda60d5f58521da56e2e1f5d824bf861d
2022-02-04 07:20:31 -08:00
Samuel Susla 5e933fdd2a Yield for each access to the runtime
Summary:
changelog: [internal]

With multiple requests to the runtime, we need to make sure they are all granted before React continues with rendering. A boolean is not enough to track this. The first lambda that has VM will set it to false and subsequent requests will have to wait for React to finish rendering.

To prevent this, we can count how many lambdas are pending access to the runtime.

Reviewed By: ShikaSD

Differential Revision: D33792734

fbshipit-source-id: f785fae3575470179dd69acc6a466211b79b633b
2022-02-03 10:20:33 -08:00
Samuel Susla 491c4231db Pass raw ShadowNode instead of shared_ptr
Summary:
changelog: [internal]

pass raw ShadowNode instead of shared_ptr. Ownership is not transferred, shared_ptr is misleading.

Reviewed By: javache

Differential Revision: D33917010

fbshipit-source-id: 4d9fdd4b4e0376149f1719ad160b957de4afdce3
2022-02-03 04:30:10 -08:00
Janic Duplessis 3568a72987 Implement Runtime.getHeapUsage for hermes chrome inspector (#32895)
Summary:
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/32895

Test Plan:
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: christophpurrer

Differential Revision: D33616658

Pulled By: ShikaSD

fbshipit-source-id: 49d863e6a58d4a92d4c86f9a288ac33ed8d2cb0d
2022-02-02 10:37:06 -08:00
John Porto eb08af57a9 Implement Runtime.callFunctionOn
Summary:
[Hermes][Inspector] Implement the CDP API for calling a function on an object.

Changelog: [Internal]

Reviewed By: avp

Differential Revision: D33722301

fbshipit-source-id: da26e865cf29920be77c5c602dde1b443b4c64da
2022-02-01 16:50:14 -08:00
Felipe Perez 3552ff0562 Back out "Delete RuntimeScheduler yielding mobile config"
Summary:
D33740360 (16ed62a850) broke Explore VR on React Native. The app would go into a loop on boot and not finish mounting. This is probably a product code issue, but it's not a trivial issue to solve. Unlanding to unblock the RN migration.

Changelog:

[internal] internal

Reviewed By: mdvacca

Differential Revision: D33918026

fbshipit-source-id: cc77c70ece9994d82c91f7ae8783e959629e9cfb
2022-02-01 15:17:14 -08:00
Samuel Susla 6351064b75 Introduce RuntimeScheduler::callImmediates
Summary:
changelog: [internal]

React on web uses microtasks to schedule a synchronous update for discrete event. Microtasks are not yet available in React Native and as a fallback, React uses native scheduler and task with immediate priority. Until Microtasks are in place, React Native needs to make sure all immediate tasks are executed after it dispatches each event.

I tried to stay as close to [microtask standard](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask) as I reasonably could.

Once microtasks on RN are shipped, this code can be removed.

Reviewed By: mdvacca

Differential Revision: D33742583

fbshipit-source-id: eddebb1bd5131ee056252faad48327a70de78a4a
2022-01-28 16:35:18 -08:00
John Porto d2f5044c37 Catch exceptions thrown by user callbacks
Summary:
Calls to Inspector::evaluate() and Inspector::executeIfEnabled()
take a user-provided callback which are not try-guarded. This
means that, should the user code throw, the inspector's process
will likely die due to the unhandled exception. This change
makes sure that, if the user provided callback throws, then
the promise attached to those methods will be fulfilled by
an exception.

Change: [internal]

Reviewed By: avp

Differential Revision: D33852073

fbshipit-source-id: 7fbb6662b28d393a5d5b494c004aa9521e23ebb6
2022-01-28 13:38:27 -08:00
Xin Chen 8aa87814f6 Consider transform when calculating overflowInset values
Summary:
The fix in this diff seems simple, but it took some time to understand why this change fixed the issue that views animated use native driver out from their parent's layout are not getting touch events.

We introduced `overflowInset` to RN Android a while back to give each shadow node extra information to cover all its children's layout. These values (left, top, right, bottom extensions from the view's own layout) help us improve hit-testing algorithm used in touch events. We could ignore all subtrees that the touch point not in their parent's overflowInset box.

However, this was not working for native animation. When `userNativeDriver` is on, all animation happens without Fabric knows anything about them. The overflowInset is out of date with the final animated layout, which caused the issue that we ignored the animated view as we thought it's not under the pointer.

Here is a playground demo (P476407654) for the issue:

https://pxl.cl/1XfPL

We've tried to fix this by passing the final animated values via `passthroughAnimatedPropExplicitValues` added in D32539976. This is a prop that will get merged into `style` prop for [animation component](https://fburl.com/code/jybzfgu5). The transform values were already applied when measuring layout in [Pressability](https://fburl.com/code/5mect2k3), which uses [LayoutableShadowNode](https://fburl.com/code/qh8fufrw). However, this is not the case for overflowInset calculation. Hence, the fix here is to apply the transform matrix in Yoga before calculating the overflowInset.

Changelog:
[Android][Fixed] - Fix overflowInset calculation by using transform values

Reviewed By: ShikaSD

Differential Revision: D33806030

fbshipit-source-id: e438618e3d6e5b0333cff9ff9919b841d73b2e9d
2022-01-28 10:37:34 -08:00
David Vacca 4b7face721 Move pointerEvents from formsStacking -> formsView
Summary:
This was a bug, we are fixing it.

Move pointerEvents from formsStacking -> formsView and we are also removing "onLayout" from formsStackingContext

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D33846660

fbshipit-source-id: 6b65a9a7815972e34dafbc48b3d732d9b02d5e9f
2022-01-28 09:30:17 -08:00
Pieter De Baets 20b9ed91c0 Remove FBREMAP experiment
Summary:
The flag was removed in https://www.internalfb.com/diff/D28467996 (2c5f68df46) but the code was not removed yet.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D33792884

fbshipit-source-id: 0ae5d904ca2ca94437ca63b495d41e47585fde33
2022-01-27 12:02:19 -08:00
Pieter De Baets 86fa2a5106 Emit warning when dispatching event to null target
Reviewed By: ShikaSD

Differential Revision: D33767454

fbshipit-source-id: c2f10b6b857544c06780fb13b66417d12f9b8d2c
2022-01-26 11:24:32 -08:00
Samuel Susla b856465e3a Add missing header and initialisation in RuntimeSchedulerTest
Summary: changelog: [internal]

Reviewed By: ShikaSD

Differential Revision: D33789519

fbshipit-source-id: 395c0cc7ddd1d63fbe57efb8f3212e5f5647e2bd
2022-01-26 09:23:08 -08:00
Samuel Susla 9bf533e6b8 Remove shared_ptr from RuntimeScheduler::cancelTask interface and add comments
Summary:
Changelog: [internal]

Add comments and avoid using shared_ptr unnecessarily.

Why note shared_ptr? Using shared_ptr suggests we are transferring ownership of object, which we are not.

Reviewed By: javache

Differential Revision: D33741836

fbshipit-source-id: 56ebb098e6185793f05e2bb587005bb0f093c0c9
2022-01-26 09:23:08 -08:00
Samuel Susla 16ed62a850 Delete RuntimeScheduler yielding mobile config
Summary:
changelog: [internal]

Yielding in RuntimeScheduler is shipped. This diff removes the gating around it.

Reviewed By: sshic

Differential Revision: D33740360

fbshipit-source-id: 267372e81e66dda96e451435954a7c3546cc6fbe
2022-01-26 09:23:08 -08:00
Andrei Shikov 3c86e82a02 Namespace MapBuffer structs and typealiases by moving them into class
Summary:
Refactors MapBuffer-related `primitives.h` to be namespaced with `MapBuffer` class, to avoid name collisions and confusion later on.
Most of the size constants are moved to relevant .cpp files or updated to use `sizeof`.

Additionally, adds a little bit of documentation about `MapBuffer` serialization format.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33662487

fbshipit-source-id: 5a7a2b1c7f2bb13ee1edfc5fae51ba88c34f0d3c
2022-01-20 12:57:22 -08:00
Andrei Shikov adb2167640 Serialize and assert type information in mapbuffer
Summary:
Serializes type information along with key/value in MapBuffer, asserting the data type on Java side during read. At the moment, accessing value with incorrect will result in a crash.

Other changes:
Adds a `getType` method to verify types before accessing them.
Removes `null` as a type, as just not inserting value and checking for its existence with `hasKey` is more optimal.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33656841

fbshipit-source-id: 23a78daa0d84704aab141088b5dfe881e9609472
2022-01-20 12:57:22 -08:00
Andrei Shikov d287598d23 Allow random stores and accesses to MapBuffer values
Summary:
Removes the need to store keys in incremental order by sorting them after before inserting into MapBuffer.
Updates MapBuffer to support random access on C++ side, actually retrieving values by keys and not bucket index.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33611758

fbshipit-source-id: c81e970613c8ecc688bfacb29ba038bf081a0c0f
2022-01-20 12:57:22 -08:00
Andrei Shikov b173bf3c0e Minor MapBuffer renames for consistency
Summary:
Rename `_header` to `header_` to align with the C++ naming scheme we use.
Rename `readKey` to `readUnsignedShort` as purpose of the method have changed.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D33637127

fbshipit-source-id: a82f4d6c1b753b21e0567fbe919af98e4c78105d
2022-01-18 18:00:07 -08:00
Andrei Shikov c338fff521 Cast MapBuffer bytes to struct to read header
Summary:
The struct is copied directly to the buffer, so it is safe to read it back.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D33624036

fbshipit-source-id: 7ee2b28b815690ab471832c0c622a075b5dd7d78
2022-01-18 08:04:54 -08:00
Andrei Shikov 5b489d5f95 Use vector for dynamic data in MapBufferBuilder
Summary:
Replaces dynamic manually managed array with a vector of bytes, removing the need for managing memory manually.

This approach is a little bit slower than before, as vector is allocating memory more conservatively. This can be improved in the future by providing an estimate for the data size.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D33611759

fbshipit-source-id: a0e5e57c4e413206a9f891cd5630ecc9088a9bf7
2022-01-17 13:15:49 -08:00
Andrei Shikov b1ef4405ee Use struct for building mapbuffer buckets
Summary:
Instead of copying integer values into key/value data array, this implementation keeps a structured vector of `Bucket` structs (which is sized to be serialized later).

This approach provides multiple benefits to modify and access buckets (e.g. sort them based on the key, allowing for out of order inserts (D33611758))

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D33601231

fbshipit-source-id: 62ace1374936cb504836d6eae672e909ea404e3f
2022-01-17 13:15:49 -08:00
Andrei Shikov 0b48ef7ca8 Add more complex perf test for the mapbuffer
Summary:
Benchmarks performance/correctness of mapbuffer with several different types of data

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33608299

fbshipit-source-id: 81b1e195aecac60ad1cc3ca416d1cf7b09feab32
2022-01-16 23:07:40 -08:00
Andrei Shikov ea712f825a Use reference when copying strings into mapbuffer
Summary:
This method can produce unnecessary copy of the string, replacing it with reference to optimize.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33607765

fbshipit-source-id: e04eddffec063c0c8e173bfdf690e7b8e1050525
2022-01-16 23:07:40 -08:00
Andrei Shikov f33892081a Cleanup ReadableMapBuffer
Summary:
Cleans up `ReadableMapBuffer` APIs and migrates to use `std::vector` instead of raw pointer array.

Also uses `fbjni` utility to allocate the bytes instead of making manual JNI calls.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D33513027

fbshipit-source-id: afe7d320d12830503de4c9994117d849f0b25245
2022-01-12 08:13:32 -08:00
Andrei Shikov aaff15c2c8 Use std::vector to manage MapBuffer storage
Summary:
Replaces raw array pointer inside `MapBuffer` with `std::vector`, which is more conventional "safer" way of storing dynamically sized arrays.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D33512115

fbshipit-source-id: d875a2240f7938fd35c4c3ae0e7e91dc7456ff32
2022-01-12 08:13:32 -08:00
Moses DeJong 5baf6875f7 TurboModules: use weakSelf for block sent to main thread
Summary:
TurboModules: use weakSelf for block sent to main thread.

Changelog:
[iOS][Fixed] - Use weakSelf in objc block instead of self.

Reviewed By: RSNara

Differential Revision: D33488938

fbshipit-source-id: d03c98fb59fbd1fc4b67686251ebec541e5d3e6c
2022-01-11 23:21:51 -08:00
Samuel Susla bdd25ed6a3 Clean up ShadowTree::progressState
Summary:
changelog: [internal]

Use std::vector access operator without bounds checking.

Trying to resolve T108113554 and discovered this inefficiency.

Reviewed By: mdvacca

Differential Revision: D33349619

fbshipit-source-id: e9000a054ba9e7e6835105b7558dbf1a9a04deff
2022-01-05 09:10:06 -08:00
Samuel Susla 681ed402de Turning on clang tidy performance-*
Summary:
changelog: [internal]

Enable performance related clang tidy rules.

Reviewed By: javache

Differential Revision: D33350556

fbshipit-source-id: 486446ed0a1ac88af21b691ac6905b4f2359dafc
2022-01-05 05:53:13 -08:00
Samuel Susla d639fe1f3d Make iterators const in LayoutAnimationKeyFrameManager
Summary:
changelog: [internal]

Just making more stuff const.

Reviewed By: mdvacca

Differential Revision: D33254016

fbshipit-source-id: 9a170b025c065845432933bd851148599124b525
2022-01-04 11:42:16 -08:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Samuel Susla 8c6a98400e Introduce TextInput.onChangeSync
Summary:
changelog: [internal]

Add experimental `TextInput.onChangeSync` which delivers onChange event synchronously.

Reviewed By: ShikaSD

Differential Revision: D33188083

fbshipit-source-id: 1e1dcd0d71c7eec98d3d5f69967659e07ac4e6a6
2021-12-30 06:38:50 -08:00
Samuel Susla f85273d484 Enable modernize-use-transparent-functors clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-transparent-functors.html

Reviewed By: rubennorte

Differential Revision: D33297509

fbshipit-source-id: 4b5c38e6fe0eab9aa39131f0200cf9c5654ec19f
2021-12-23 10:21:10 -08:00
Samuel Susla b76a488199 Enable modernize-use-using clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-using.html

Reviewed By: rubennorte

Differential Revision: D33297576

fbshipit-source-id: 1124c410f0b950b0eb37e1b0e950ba9e76925dce
2021-12-23 10:21:10 -08:00
Samuel Susla 8d9101e578 Enable modernize-use-override clang tidy rule
Summary:
changelog: [internal]

You can read more about this on https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-override.html

Reviewed By: rubennorte

Differential Revision: D33297524

fbshipit-source-id: 259aa6f0b3ceb0ef065497199f72760449634ffc
2021-12-23 10:21:10 -08:00
Samuel Susla 1d0495e0a2 Enable modernize-use-equals-delete clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-delete.html

Reviewed By: rubennorte

Differential Revision: D33296068

fbshipit-source-id: 72e7ae199da39527476494729b1ab862e7e989e4
2021-12-23 10:21:10 -08:00
Samuel Susla 76af846c1d Enable modernize-use-noexcept clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-noexcept.html

Reviewed By: rubennorte

Differential Revision: D33296107

fbshipit-source-id: 5a27b3e1c9e2da71a0eee149f25d9d70ca83b443
2021-12-23 10:21:10 -08:00
Samuel Susla 52b7828cdc Enable modernize-use-default-member-init clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-default-member-init.html

Reviewed By: rubennorte

Differential Revision: D33296545

fbshipit-source-id: e6813542b76e50db0a4b3ae9fdfafde2dbd8ac5b
2021-12-23 10:21:10 -08:00
Samuel Susla d8d4e95697 Enable modernize-use-nullptr clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html

Reviewed By: rubennorte

Differential Revision: D33296118

fbshipit-source-id: ba9de4611c0f0459db9cea56722385e2541b155e
2021-12-23 10:21:09 -08:00
Samuel Susla bf9872a7b5 Enable modernize-use-equals-default clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html

Reviewed By: rubennorte

Differential Revision: D33295116

fbshipit-source-id: d7da62c35e141fc2bf5a83c28f80f4f8d355c4cb
2021-12-23 10:21:09 -08:00
Samuel Susla 1251b2f993 Enable modernize-shrink-to-fix clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-shrink-to-fit.html

Reviewed By: rubennorte

Differential Revision: D33280814

fbshipit-source-id: f7b17e57b540cf4461dca1f3fa266b02f24ce455
2021-12-23 10:21:09 -08:00
Samuel Susla 9c5518f77e Enable modernize-use-emplace clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-emplace.html

Reviewed By: rubennorte

Differential Revision: D33295156

fbshipit-source-id: 91a7bd34d689506ea9a68462b050c41fdb3faa4e
2021-12-23 10:21:09 -08:00
Samuel Susla 6c7581c6b3 Enable modernize-unary-static-assert clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-unary-static-assert.html#:~:text=The%20check%20diagnoses%20any%20static_assert,%2B%2B17%20and%20later%20code.

Reviewed By: rubennorte

Differential Revision: D33281759

fbshipit-source-id: 0399229947dce5f9297c4f65567b299dc0dca7ba
2021-12-23 10:21:09 -08:00
Samuel Susla b9cbd5a104 Enable modernize-replace-random-shuffle clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-replace-random-shuffle.html

Reviewed By: rubennorte

Differential Revision: D33279255

fbshipit-source-id: 0802cbafee448cfd5eed7f866a44ae3f3c5eb0fd
2021-12-23 10:21:09 -08:00
Samuel Susla 9419bebb98 Enable modernize-use-bool-literals clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-bool-literals.html

Reviewed By: feedthejim

Differential Revision: D33295106

fbshipit-source-id: 34e68153a6796d5b9120166aeca6461ae0936e1e
2021-12-23 07:53:50 -08:00
Samuel Susla 474682dab7 Enable modernize-replace-auto-ptr clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-replace-auto-ptr.html

Reviewed By: fkgozali

Differential Revision: D33279163

fbshipit-source-id: b04c7fb4ff4caa0320c312ae187a7bcfe42cb3d3
2021-12-23 07:53:49 -08:00
Samuel Susla 028fb20e4b Enable modernize-raw-string-literal clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-raw-string-literal.html

Reviewed By: fkgozali

Differential Revision: D33277859

fbshipit-source-id: 2a1c980f72fee36451cc84ee0255c2e90a8f810a
2021-12-23 07:53:49 -08:00
Samuel Susla 5fa6c5a941 Enable modernize-pass-by-value clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-pass-by-value.html

# Isn't it wasteful to copy? Isn't reference more efficient?

This rule of thumb is no longer true since C++11 with move semantics. Let's look at some examples.

# Option one

```
class TextHolder
{
public:
   TextBox(std::string const &text) : text_(text) {}
private:
   std::string text_;
};
```

By using reference here, we prevent the caller from using rvalue to and avoiding copy. Regardless of what the caller passes in, copy always happens.

# Option two

```
class TextHolder
{
public:
   TextBox(std::string const &text) : text_(text) {}
   TextBox(std::string &&text) : text_(std::move(text)) {}
private:
   std::string text_;
};
```
Here, we provide two constructors, one for const reference and one for rvalue reference. This gives the caller option to avoid copy. But now we have two constructors, which is not ideal.

# Option three (what we do in this diff)

```
class TextHolder
{
public:
   TextBox(std::string text) : text_(std::move(text)) {}
private:
   std::string text_;
};
```
Here, the caller has option to avoid copy and we only have single constructor.

Reviewed By: fkgozali, JoshuaGross

Differential Revision: D33276841

fbshipit-source-id: 619d5123d2e28937b22874650366629f24f20a63
2021-12-23 07:53:48 -08:00
Samuel Susla 70b346fb9c Enable modernize-make-unique clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-make-unique.html

Reviewed By: feedthejim

Differential Revision: D33255905

fbshipit-source-id: a0c354dec37515db11633fb039de09bc97d6c228
2021-12-23 05:53:31 -08:00
Samuel Susla 6d1d2fe2b8 Enable modernize-use-auto clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html

Reviewed By: mdvacca

Differential Revision: D33281781

fbshipit-source-id: 8e23becb74305e282993fe6b3996fa1a5878cf98
2021-12-23 03:55:16 -08:00
Samuel Susla 4febfd9491 Enable modernize-return-braced-init-list clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-return-braced-init-list.html

Reviewed By: mdvacca

Differential Revision: D33279829

fbshipit-source-id: 3969eda9f0f3ed37c262d495c8e31bb4f5326eab
2021-12-23 03:55:16 -08:00
Samuel Susla c270b48f68 Enable modernize-redundant-void-arg clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-redundant-void-arg.html

Reviewed By: mdvacca

Differential Revision: D33278172

fbshipit-source-id: 5c3c6123290bd23edc7da4085277803d8745a3dd
2021-12-23 03:55:16 -08:00
Samuel Susla 5763133984 Enable modernize-make-shared clang tidy rule
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-make-shared.html

Reviewed By: ShikaSD

Differential Revision: D33254590

fbshipit-source-id: 1f5f9e7ec8e7d938490b10e880ba10a64c5ada7f
2021-12-22 08:22:44 -08:00
Samuel Susla 26fffe8cbf Enable modernize-loop-convert rule in clang-tidy
Summary:
changelog: [internal]

You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-loop-convert.html

Reviewed By: ShikaSD

Differential Revision: D33253673

fbshipit-source-id: db2ec74cc584f2e8eb74ce54c4f50986d8168387
2021-12-22 08:22:44 -08:00
Samuel Susla bcc4ab35da Remove use of TextLayoutManager::Shared and SharedTextLayoutManager
Summary:
changelog: [internal]

For some reason, using `TextLayoutManager::Shared` in `TextInputShadowNode` trips up clang tidy linter. We have a plan to move away from `*::Shared` anyway, so let's remove it from `TextInputShadowNode` now.

Why do we want to move away from `*::Shared`?
Using `TextLayoutManager::Shared` is confusing for people unfamiliar with Fabric's codebase. It expresses a concept of immutability but uses term `shared`. Term shared is already used in C++  `std::shared_ptr`.

Reviewed By: fkgozali

Differential Revision: D33186422

fbshipit-source-id: 10ee588735997f5fedc372a1d1e3d9cd9684178a
2021-12-22 04:20:42 -08:00
Kevin Gozali f142bfed45 Butter C++: clarify goals/intent in the comment
Summary:
Just clarifying the purpose of this library.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D33245053

fbshipit-source-id: b4325415774ca33b34b5ba53d222a19f88e2175f
2021-12-20 23:38:52 -08:00
Kevin Gozali 6a93c07485 Butter C++: fixed clangtidy config
Summary:
Added missing `InheritParentConfig: true` per internal clang config.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D33244729

fbshipit-source-id: 9ae8f8265c202902447c8b784206f6c00222c43d
2021-12-20 23:38:52 -08:00
Kevin Gozali fb39d45ed5 C++ - better => butter
Summary:
Renaming the `better` utilities to `butter`:
- to prevent claims that this library is superior to others - it really depends on use cases
- to indicate ease of use throughout the codebase, easily spread like butter

Changelog: [C++][Changed] Renaming C++ better util to butter, used by Fabric internals

Reviewed By: JoshuaGross

Differential Revision: D33242764

fbshipit-source-id: 26dc95d9597c61ce8e66708e44ed545e0fc5cff5
2021-12-20 22:25:14 -08:00
Samuel Susla 8c3b839625 Enable modernize-deprecated-ios-base-aliases in clang-tidy
Summary:
changelog: [internal]

You can find more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-deprecated-ios-base-aliases.html#:~:text=Detects%20usage%20of%20the%20deprecated,have%20a%20non%2Ddeprecated%20equivalent.

Reviewed By: ShikaSD

Differential Revision: D33237586

fbshipit-source-id: acc497fb3427f5ac2c7436af3d9627fbaed3d777
2021-12-20 11:22:43 -08:00
Samuel Susla b3fe2d40e8 Remove unused arguments
Summary:
changelog: [internal]

Linter was not happy about this.

Reviewed By: ShikaSD

Differential Revision: D33235690

fbshipit-source-id: 389a49afe2c828f60bfbfb1c6e92d2c74f676600
2021-12-20 11:22:43 -08:00
Samuel Susla eb35e4a4f6 Enable modernize-deprecated-headers rule in clang-tidy
Summary:
changelog: [internal]

You can find more about this rule on https://releases.llvm.org/6.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/modernize-deprecated-headers.html

Reviewed By: ShikaSD

Differential Revision: D33235582

fbshipit-source-id: 28d38b4eab4ad535d87468bc8d64dc87c4b0aeca
2021-12-20 11:22:43 -08:00
Samuel Susla f7c96c000a Enable modernize-avoid-c-arrays in clang tidy
Summary:
changelog: [internal]

In an effort to make our codebase more approachable, I'm enabling more clang-tidy rules.

Read more about modernize-avoid-c-arrays in https://clang.llvm.org/extra/clang-tidy/checks/modernize-avoid-c-arrays.html

Reviewed By: ShikaSD

Differential Revision: D33187162

fbshipit-source-id: c6b3888f67d095274bb492a01132985ae506c0d5
2021-12-20 11:22:43 -08:00
Samuel Susla dc5cae5a6f Enable modernize-avoid-bind in clang tidy
Summary:
changelog: [internal]

I will be enabling more clang tidy rules in Fabric to make it easier for new contributors and standardise the codebase. \
You can read more about the rule in https://clang.llvm.org/extra/clang-tidy/checks/modernize-avoid-bind.html

Reviewed By: ShikaSD

Differential Revision: D33162192

fbshipit-source-id: b4bb332f3134c42c49559a8baf10aeb7a7fdd87f
2021-12-20 04:30:52 -08:00
Luna Wei 3204c55981 Remove usages of bump-oss-version from generated scripts
Summary: Changelog: [Internal] - Update the source of the changes in generated files, no longer bump-oss-version but set-rn-version

Reviewed By: sota000

Differential Revision: D33110408

fbshipit-source-id: 8cd5004f5d40dde82fe4d6271d5b8598cd27ca31
2021-12-17 18:37:37 -08:00
Samuel Susla 6568bc4bb2 Execute only necessary minimum in sync mode in RuntimeScheduler
Summary:
changelog: [internal]

Only execute tasks that are expired when in synchronous mode.

Reviewed By: philIip

Differential Revision: D33062746

fbshipit-source-id: 1825cb572202d1f5dc18eb2b481dd3c20e8e91ba
2021-12-17 10:34:29 -08:00
Samuel Susla fd18225767 Add unit tests for RuntimeScheduler::executeNowOnTheSameThread
Summary: Changelog: [internal]

Reviewed By: philIip

Differential Revision: D33062204

fbshipit-source-id: f37375400fea645f5540b85c3c1ef6343e64be2e
2021-12-16 06:45:34 -08:00
Julio C. Rocha 1d45b20b6c Set CxxModule instance before retrieving Method vector (#32719)
Summary:
Allows `CxxModule` objects to set their `instance_` member before `getMethods()` is invoked, allowing for the `Method` callbacks to capture a weak reference to `getInstance()` if needed.

## 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] - Set CxxModules' Instance before retrieving their Method vector.

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

Test Plan: Ensure this statement swap does not break any scenarios with existing CI validation.

Reviewed By: JoshuaGross

Differential Revision: D32955616

Pulled By: genkikondo

fbshipit-source-id: fd7a23ca2c12c01882ff1600f5aef86b1fe4a984
2021-12-15 14:37:37 -08:00
Samuel Susla d902a89b40 Move surface registry code out of UIManagerBinding
Summary:
changelog: [internal]

Just moving code that doesn't belong to UIManagerBinding out of the class.

Reviewed By: philIip

Differential Revision: D33060412

fbshipit-source-id: 2d54929072cef14fd1fa6b70bde382ae21ecff45
2021-12-15 10:52:15 -08:00
Samuel Susla 34c4fdb8e2 Remove implicity type conversions from LayoutAnimations
Summary: changelog: [internal]

Reviewed By: philIip

Differential Revision: D33058920

fbshipit-source-id: 6d39e26c369dad409f5141dceae7554fe65daaba
2021-12-15 07:19:51 -08:00
David Vacca 8f6aee0df5 Create experiment to increase size of TextMeasureCache and enable in RNPanel apps
Summary:
Fabric uses a cache where it stores the result of the text measurement in C++ (to avoid unnecessary text measurement that are very costly). This cache has a "max size" of 256 and this size is not enough to store all the texts we have in the screen

In my tests, the amount of texts being measured are ~290 and after scrolling many times they increase to 611.

This diff increases the size of the TextMeasure to 1024 for users in the experiment. As a result this improves performance of HoverEvents by +5x times (see test plan)

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D33112788

fbshipit-source-id: e15feecf0f54da62b252892d37a64fb4ead29e22
2021-12-14 19:33:09 -08:00
Andrei Shikov 0088c22b3d Clang-tidy uimanager/scheduler modules
Summary:
Applies suggestions from default preset that make sense in our codebase

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D33010231

fbshipit-source-id: 6bc9edf01fd9bd9938d211e3494dd1a127b24eaa
2021-12-14 10:27:30 -08:00
Janic Duplessis 20b0eba581 Static link for hermes-inspector (#32694)
Summary:
Follow up to https://github.com/facebook/react-native/issues/32683 to also link hermes-inspector statically.

## Changelog

[Android] [Fix] - Static link for hermes-inspector

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

Test Plan: Tested a clean build and made sure hermes-inspector.so doesn't exist anymore.

Reviewed By: cortinico

Differential Revision: D32791208

Pulled By: ShikaSD

fbshipit-source-id: 6076b263469b9e2c6176d488d13292d4f1731dcc
2021-12-13 07:48:39 -08:00
Samuel Susla b30ff9853c Simplify construction of UIManagerBinding
Summary:
changelog: [internal]

Provide `UIManager` to `UIManagerBinding` in constructor to make the API safer.

Reviewed By: philIip

Differential Revision: D32668892

fbshipit-source-id: a15cd295196a60c3f46997e59c05c4f90503e18d
2021-12-13 06:52:37 -08:00
Andrei Shikov 1d4e7f6d40 Use reference for command args
Summary:
The IDE warning suggests that passing folly::dynamic by value will create a copy on each call.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D32978154

fbshipit-source-id: a47a60c332a9d299eb2110d3537dfab0bc2398b6
2021-12-09 09:47:38 -08:00
Samuel Susla f5f6fd70f2 Introduce TextInput.onKeyPressSync
Summary:
changelog: [internal]

Introduce a way to execute `onKeyPress` synchronously. This feature is experimental and will be changed in the future. It is not decided if marking native events as "sync" is going to be path forward with synchronous access.

NOTE: This is experimental API.

Reviewed By: ShikaSD

Differential Revision: D32882092

fbshipit-source-id: 68c66a9bb7c97758219e085c88a77f3c475c1eb3
2021-12-07 13:42:18 -08:00
Samuel Susla 69acb9569e Remove unused method from TextInputEventEmitter
Summary:
changelog: [internal]

Event `onChangeText` does not exist in TextInput. Let's remove this method to avoid confusion.

Reviewed By: philIip

Differential Revision: D32882056

fbshipit-source-id: 37eb260b84dd7d6cce412ce1bc39c0cbf9cab112
2021-12-07 13:42:18 -08:00
Samuel Susla fcda1ac514 Add support for synchronous completeRoot
Summary:
changelog: [internal]

Exposes a new flag on RuntimeScheduler: `unstable_getIsSynchronous`. Flag indicates if the current code is run synchronously and therefore commit phase should be synchronous.

Unit tests will be added later, to keep this diff short. This code path is not executed yet.

Reviewed By: mdvacca, ShikaSD

Differential Revision: D32677814

fbshipit-source-id: e01d4fff7e716d627ff99fe104965851138c3aef
2021-12-07 12:11:24 -08:00
Andrei Shikov c0710244b3 Clean up AndroidTextInputEventEmitter
Summary:
This class is not used and can be safely deleted

Changelog: [Internal] Delete unused Android event emitter

Reviewed By: mdvacca

Differential Revision: D32916706

fbshipit-source-id: 6dceb6b6ed9d201d96454bf0d646853c5c893d59
2021-12-07 11:09:22 -08:00
Samuel Susla 387e79f8aa Remove background_executor flag
Summary:
changelog: [internal]

Background executor has been shipped on both platforms for a long time.
I've kept the flag around because I wanted to run tests and compare Concurrent Mode vs Background Executor. The intention was to see if we can get rid of Background Executor to simplify the threading model.

Since then, React team has moved away from Concurrent Mode towards more gradual rollout of concurrent rendering and it no longer makes sense to do this comparison. Right now, we don't have a concern with concurrent rendering and Background Executor. If we ever want to run the an experiment, this gating will need to be added again.

Reviewed By: javache

Differential Revision: D32674798

fbshipit-source-id: a1e51c9c5b8e48efa4cb0f25379d58e7eb80ccd9
2021-12-02 15:32:28 -08:00
Samuel Susla 9e2ec4d3dd Make UIManager::animationTick const
Summary:
changelog: [internal]

UIManager::animationTick is thread safe. Let's make it obvious by marking the method const.

Reviewed By: javache

Differential Revision: D32669102

fbshipit-source-id: 49e35d0f0a5c5d1b03baa1cbf9cdece082909e85
2021-12-02 07:54:09 -08:00
Janic Duplessis b2cf24f41c Make hermes-executor-common a static lib (#32683)
Summary:
I've been seeing a couple crashes related to missing hermes-executor-common.so, seems to happen on specific android versions, but can't repro. I investigated this so file more and noticed it is incorrectly linked as a static library here b8f415eb6c/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/Android.mk (L20). There doesn't seem to be any reason for this to be a shared lib so I changed it to be compiled as a static lib.

## Changelog

[Android] [Fixed] - Make hermes-executor-common a static lib

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

Test Plan:
- Verify there is no more hermes-executor-common-{release,debug}.so
- Test locally in an app to make sure it build and run properly.
- Verify that the crash happening on play store pre-launch report doesn't happen anymore.

Reviewed By: ShikaSD

Differential Revision: D32754968

Pulled By: cortinico

fbshipit-source-id: cb57e2d81edb4cbdb1f003dab45c53e594a5a62a
2021-12-01 11:19:23 -08:00
Felipe Perez 79d20a1717 Fix fromRawValue(EdgeInsets) from single float case falling through to float array
Summary:
If `value` is of type `float`, it will still fall through to the `react_native_assert` below, exploding. The `map` type is handled correctly.

Changelog: [Internal][Fixed] Fix fromRawValue(EdgeInsets) from single float case falling through to float array and exploding

Reviewed By: javache

Differential Revision: D32648848

fbshipit-source-id: e70cddd291a8f52d6ee3de5fef11b0bb7aee92cd
2021-11-30 10:38:22 -08:00
Andrei Shikov 041398a775 Compile platform Android components into static libraries
Summary:
Removes extra .so files by merging built-in components into libfabricjni.so
These components shouldn't be referenced in outside modules, so merging them is trivial atm.

Changelog:
[Internal][Android] - Compile native components into static libraries

Reviewed By: cortinico

Differential Revision: D32677572

fbshipit-source-id: fc1a6c5a2832ee49e438c30856562f85677514ea
2021-11-30 08:31:44 -08:00
Andrei Shikov 7eb1ff5048 Rename reactconfig module to react_config to align naming
Summary:
title

Changelog:
[Internal][Android] - Rename reactconfig c++ module

Reviewed By: cortinico

Differential Revision: D32677571

fbshipit-source-id: 41b4313a1f7c75da7204cf829ae3d0d700151eba
2021-11-30 08:03:27 -08:00
Samuel Susla a9815286c2 Remove redundant parameter from ShadowTreeRegistry::enumerate
Summary:
Changelog: [internal]

Nothing was using `stop` parameter, let's get rid of it.

Reviewed By: philIip

Differential Revision: D32669018

fbshipit-source-id: dc2d52048a2f7dd3785dd959270087001c778962
2021-11-30 04:32:02 -08:00
Nicola Corti b8f415eb6c Update LOCAL_SHARED_LIBRARIES to be a multiline string
Summary:
We have `LOCAL_SHARED_LIBRARIES` that are getting longer and are
making reviewing them on Diffs quite hard.
Having all the list of the dependency on a single line is suboptimal
and it makes hard to find duplicated entries.
I've updated the longest `LOCAL_SHARED_LIBRARIES` to be multilines and
I've sorted the entries here.

Changelog:
[Internal] [Changed] - LOCAL_SHARED_LIBRARIES

Reviewed By: ShikaSD

Differential Revision: D32695127

fbshipit-source-id: f5b381c501ddff083ef9f4baaca6c4c8c9523368
2021-11-29 13:01:51 -08:00
Nawbc 0872e220cf fix: Link incompatible target in debug mode (#32595) (#32648)
Summary:
Build from source crash in debug mode on other linux distributions except ubuntu

Changelog:  Link incompatible target in debug mode (https://github.com/facebook/react-native/issues/32595)

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

Reviewed By: ShikaSD

Differential Revision: D32642360

Pulled By: cortinico

fbshipit-source-id: 6b35c560aca3d2e8d30b24a3b800ebfd9b35bda2
2021-11-25 00:27:27 -08:00
Nicola Corti a5469f9d7f Update libruntimeexector to be a shared lib rather than a static lib
Summary:
AGP 7.x is changing the path where we can find
the precompiled static libraries. Therefore is getting complicated
to share prebuilt `.a` files. I'm updating `libruntimeexecutor` to be
a shared library instead so this will solve this issue for now.

Changelog:
[Internal] [Changed] - Update libruntimeexector to be a shared lib rather than a static lib

Reviewed By: ShikaSD

Differential Revision: D32646112

fbshipit-source-id: ce42e930076c1d3b5f54f3d8adcca1c38909d0fb
2021-11-24 10:58:54 -08:00
Samuel Susla c10dc49368 Fix typo in TextInputEventEmitter::onScroll
Summary:
changelog: [internal]

Fix JS Exception "unsupported top level event type".

Reviewed By: ShikaSD

Differential Revision: D32649068

fbshipit-source-id: bc65722ff1d4f6237074ca246906fcb6604411d3
2021-11-24 10:07:05 -08:00
Paige Sun 160807d112 Add ReactMarker::LogTaggedMarkerBridgeless, to replace LogTaggedMarkerWithInstanceKey
Summary:
# Issue in iOS
Before this diff, [Venice would override](https://www.internalfb.com/code/fbsource/[08e6e7a37f9ac1d33e14fc14ed763c0f8716f73a]/fbobjc/Apps/Internal/Venice/Core/RCTPerformanceLoggerUtils.mm?lines=52%2C57) the static function ReactMarker::LogTaggedMarker [created in CxxBridge](https://www.internalfb.com/code/fbsource/[08e6e7a37f9ac1d33e14fc14ed763c0f8716f73a]/xplat/js/react-native-github/React/CxxBridge/RCTCxxBridge.mm?lines=179%2C183). This means that in mixed mode they would share the Bridgeless instance of RCTPerformanceLogger [owned by Venice-only RCTInstance](https://www.internalfb.com/code/fbsource/[08e6e7a37f9ac1d33e14fc14ed763c0f8716f73a]/fbobjc/Apps/Internal/Venice/Core/RCTInstance.mm?lines=65%2C73).

This is wrong because Bridge is supposed to use the instance of RCTPerformanceLogger [owned by RCTBridge](https://www.internalfb.com/code/fbsource/[73ab70b2d9e28569171b62f60e9f25744461d4d9]/xplat/js/react-native-github/React/Base/RCTBridge.m?lines=353).

# Fix iOS and refactor Android

1) Add LogTaggedMarkerBridgeless to use the bridgeless RCTPerformanceLogger.

2) Use LogTaggedMarkerBridgeless to replace logTaggedMarkerWithInstanceKey.
- Remove logTaggedMarkerWithInstanceKey because it always clear from the code that instanceKey is 0 for Bridge, and 1 for Bridgeless,
- iOS doesn't use instanceKey and keeps separate instances of FBReactBridgeStartupLogger, FBReactWildePerfLogger, and RCTPerformanceLogger instead. This is better than using instanceKey because they are all [deallocated when Bridgeless is invalidated](https://www.internalfb.com/code/fbsource/[ea436e5ea6ae4ebc5e206197c4900022be867135]/fbobjc/Apps/Wilde/FBReactModule2/FBReactModuleAPI/FBReactModuleAPI/Exported/FBReactModule.mm?lines=1160%2C1167%2C1170).
- logTaggedMarkerWithInstanceKey is only called from Venice's ReactInstance.cpp so it's easy to remove.

Reviewed By: sshic

Differential Revision: D32588327

fbshipit-source-id: 3151a44c9796da88fef4459b9b56946861514435
2021-11-23 12:55:56 -08:00
Phillip Pan 6a344fe900 introduce removePrerenderedSurfaceWithRootTag:
Summary:
similar to android, we want to handle removing dropped surfaces. in this diff, we add the API to do so.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D32557069

fbshipit-source-id: 2487c459df3f1f412ad0da77568d6c0ab0a1298c
2021-11-23 02:01:25 -08:00
Samuel Susla 19bca222dc Remove asserts in EventTarget
Summary: changelog: [internal]

Reviewed By: philIip

Differential Revision: D32393073

fbshipit-source-id: 9e228000291d67f3a0cedaa152c0376e11d7dcf6
2021-11-22 04:21:55 -08:00
David Vacca 26e30a5ee9 Fix incorrect ViewFlattening for views that were listening for a JS event
Summary:
This diff prevents view flattening for views that are handling some events in the JS side

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D32253124

fbshipit-source-id: acda2b12287f0a9c39a810b23a101765093ba217
2021-11-19 15:48:15 -08:00
David Vacca 34a5158ec8 Update Fabric to suport onEnter/onExit/onMove events
Summary:
This diff updates the internals of Fabric to add support for onEnter/onExit/onMove events.

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D32253128

fbshipit-source-id: 5b30e927bda0328ba1332801f66a6caba77f949b
2021-11-19 15:48:14 -08:00
Phillip Pan 9822464c99 add onScroll event to TextInputEventEmitter
Summary:
resolving issue in https://fb.workplace.com/groups/rn.support/permalink/7241260632589156/

we didn't hook up the onScroll event to the fabric text input component yet, so this stack does that

in this diff, we add the onScroll event to the event emitter

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D32479450

fbshipit-source-id: 3ac0e6f87a4bf391e3ceee24b5765e3e41ecc59d
2021-11-18 12:42:13 -08:00
Marc Horowitz d123a6fae4 Stop forcing /usr/bin to the front of the path
Summary:
This messes with python version selection. At least based on
the comments, it is no longer needed, as /opt/local/bin appears to be
empty on my devserver and on a sandcastle host.

D32337004 revealed the problem.  T105920600 has some more context.  I couldn't repro locally, so D32451858 is a control (which I expect to fail tests) to confirm that this fixes the test failures.

#utd-hermes

Reviewed By: neildhar

Differential Revision: D32451851

fbshipit-source-id: 4c9c04571154d9ce4e5a3059d98e043865b76f78
2021-11-16 19:37:36 -08:00
Christoph Purrer 5dcad6a116 jsi.h Fix typo
Summary:
Changelog:
[Internal][Fixed] - I have been reading this header file recently and discovered some typos

Reviewed By: kodafb

Differential Revision: D32455214

fbshipit-source-id: c27291943476014b787ee1641fd8642056bdbc5a
2021-11-16 08:56:53 -08:00
Pieter De Baets 79cf25bdbe Fix JSInspector build error on windows (#32585)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32585

D31631766 (b60e229d7f) unified compiler flags for all RN targets, which also enabled `-Werror`  for this target. This causes issues on Windows where some warnings are extremely noisy and unhelpful and causes our Hermes+JSInspector build to fail

Reviewed By: rshest

Differential Revision: D32244577

fbshipit-source-id: 7cda346c46d21ff03490bae705759c502f6cf29f
2021-11-15 11:44:37 -08:00
Nicola Corti 2ae06df58f Let react_native_assert really abort the app
Summary:
Fixed a bug in `react_native_assert` that was not effectively letting the app
call `abort()`. The app was actually printing on log twice.
Ref: https://developer.android.com/ndk/reference/group/logging#__android_log_assert

Changelog:
[Android] [Changed] - Let react_native_assert really abort the app

Reviewed By: JoshuaGross

Differential Revision: D32204080

fbshipit-source-id: ca16c50aaf4e41a2318277c233be0e944b2ad8f1
2021-11-11 08:57:59 -08:00
Ken Tominaga 9b059b6709 Remove iOS 11 availability check (#32488)
Summary:
This pull request aims to remove iOS 11 availability check which is no longer needed.

The minimum iOS deployment target for React Native is iOS 11 but we still have iOS 11 version check like below.

```
if (available(iOS 11.0, *)) {
```

This is a continuation pull request of https://github.com/facebook/react-native/pull/32151

## 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] [Changed] - Remove iOS 11 availability check

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

Reviewed By: yungsters

Differential Revision: D32006312

Pulled By: ryancat

fbshipit-source-id: 0ee6579e433a15d3d220a52d2ccd6931b0513971
2021-11-03 09:06:06 -07:00
Tim Yung 77ecc7ede1 JS: Format with Prettier v2.4.1 [3/n]
Summary:
Changelog:
[General][Internal]

Reviewed By: zertosh

Differential Revision: D31883447

fbshipit-source-id: cbbf85e4bf935096d242336f41bf0cc5d6f92359
2021-11-02 22:14:16 -07:00
Sota Ogo 9c4c12722a Fix a build issue where codegen order is incorrect (#32480)
Summary:
D31809012 (f7e4c07c84) introduced a condition where codegen files weren't generated in a correct order so the build fails in `yarn test-ios` if it was a first time to run the command. So it broke ci/circleci: test_ios_unit_hermes.

In this diff

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

Changelog: [intermal]

Reviewed By: cortinico

Differential Revision: D31953580

fbshipit-source-id: db854d6cfed8167dc4aae2667d379738bc261cfe
2021-10-27 09:45:25 -07:00
Sota Ogo f7e4c07c84 Move codegen output out of node_modules
Summary:
In this diff, it moves the codegen output location out of node_modules and to build/generated/ios folder.

A temp pod spec will be created so that those files will be included in the Xcode project.

Changelog: [Internal]

Reviewed By: hramos, cortinico

Differential Revision: D31809012

fbshipit-source-id: ba1c884c8024306ba0fd2102837b7dbebc6e18ac
2021-10-25 20:48:24 -07:00
Phillip Pan def7dd857d use new instead of alloc init
Summary:
i saw this a lot in the codebase, it's not optimal bc we're using two selectors when we only need one.

  fastmod --extensions m,mm '\[\[(.*) alloc] init]' '[${1} new]' --dir xplat/js/react-native-github/*

i manually updated the callsites that this codemod couldn't handle (e.g., where there were more than one of these instances in a single line)

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D31776561

fbshipit-source-id: 1b16da240e8a79b54da67383d548921b82b05a9f
2021-10-20 22:18:38 -07:00
CodemodService FBSourceClangFormatLinterBot a110de9b0e Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D31785584

fbshipit-source-id: 6e73901bdeaec659fbf46f1a5559f18cd09ae091
2021-10-19 21:16:42 -07:00
Joshua Gross d291a7efdd Allow disabling RTTI/exceptions for android builds; disable by default on Android
Summary:
For fbandroid builds only, disable RTTI and exceptions by default.

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D31632757

fbshipit-source-id: cfe0e43486df19fcaacc2b5b818b9d00ec2d427f
2021-10-19 17:17:30 -07:00
Rob Hogan 61755aced1 Merge textDecoration(LineStyle|LinePattern) into textDecorationStyle
Summary:
The [first implementation of `TextAttributes` in Fabric](62576bcb78) included two separate props instead of `textDecorationStyle`: `textDecorationLineStyle` (single, double, ...) and `textDecorationLinePattern` (dot, dash, dotdash, ...). These two props were implemented in C++ and iOS but never supported in JS.

Pre-Fabric (and CSS) on the other hand use a single prop `textDecorationStyle: 'solid' | 'double' | 'dotted' | 'dashed'`.

This diff implements this same API in Fabric, and removes the unused `textDecorationLineStyle` and `textDecorationLinePattern` props.

Changelog:
[iOS][Fixed] - Implement `textDecorationStyle` on iOS and remove unused `textDecorationLineStyle` and `textDecorationLinePattern` from Fabric.

Reviewed By: dmitryrykun

Differential Revision: D31617598

fbshipit-source-id: f5173e7ecdd31aafa0e5f0e50137eefa0505e007
2021-10-18 02:16:03 -07:00
Joshua Gross 6525f9b082 Stop using RTTI features in Fabric core and components
Summary:
These dynamic_casts aren't really giving us much (they have never fired once in dev! and don't run in prod anyway). They also prevent us from disabling RTTI. So, let's get rid of them.

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D31634895

fbshipit-source-id: 4a9b259837127feb324f64fa3e9e23eb1cc481a6
2021-10-14 19:23:09 -07:00
Joshua Gross b60e229d7f Remove compiler_flags from BUCK modules
Summary:
Nearly all of these are identical and these compiler_flags are now centralized in rn_defs.bzl. This should have NO CHANGE on build configuration, the flags have just moved for now.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D31631766

fbshipit-source-id: be40ebeb70ae52b7ded07ca08c4a29f10a0ed925
2021-10-14 15:34:29 -07:00
Neil Dhar aae93553d0 Remove libstdc++ dependency (#32247)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32247

I don't think we need both libc++ and libstdc++.

allow-large-files

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D30950943

fbshipit-source-id: d0669815ff59c3e9ac45954a4a11930d1bc3959f
2021-10-08 14:16:54 -07:00
Samuel Susla 27304fcd0b Add error handling to RuntimeScheduler
Summary:
changelog: [internal]

Catch JavaScript errors and forward them to `ErrorUtils` in *RuntimeScheduler*. This makes sure that JS errors are handled by ErrorUtils and do not bubble up to bridge.

Reviewed By: philIip

Differential Revision: D31429001

fbshipit-source-id: 50f865872e4cd3ba180056099ff40f5962ee7a77
2021-10-07 15:23:11 -07:00
Samuel Susla ea53d3a9c2 Pass reference instead of shared_ptr to getInspectorDataForInstance
Summary:
changelog: [internal]

This is a pre-condition to get rid of `shared_ptr` from `EventEmitterWrapper`. Also saves us a few copies of shared_ptr, this is negligible though.

Reviewed By: mdvacca

Differential Revision: D31307048

fbshipit-source-id: b84654bed2359b66faf3995795e135e88fe51cb6
2021-10-01 17:47:20 -07:00
Andrei Shikov bf4c6b3606 Expose RawEvent::Category to Java callsites
Summary:
For iOS, event category deduction is done from the C++ code, but the touch events are handled on Java layer in Android. This change exposes the category parameter through the `EventEmitterWrapper` called from Java, allowing to define category for events in the future.

Changelog:
[Internal] - Expose event category through JNI

Reviewed By: mdvacca

Differential Revision: D31205587

fbshipit-source-id: f2373ce18464b01ac08eb87df8f421b33d100be2
2021-09-29 06:53:49 -07:00
Samuel Susla ea3e244668 Add option to use RuntimeScheduler in TurboModules
Summary: changelog: [internal]

Reviewed By: RSNara

Differential Revision: D31145372

fbshipit-source-id: b1d9473d5006d055d1116f71f65899293fb85c56
2021-09-28 09:23:57 -07:00
Samuel Susla 18697adec4 Add option to use RuntimeScheduler in TurboModules
Summary: changelog: [internal]

Reviewed By: RSNara

Differential Revision: D31108093

fbshipit-source-id: 941abf334cc89391641131475725a3eeb790b822
2021-09-25 15:31:21 -07:00
Joshua Gross 10fe09c456 Back out "Send unix timestamp for touch events instead of systemUptime"
Summary:
Original commit changeset: 2acd52ae5873

This original change was made in D26705430 (b08362ade5) and D26705429 (69feed518d). The intention was to change the timestamp definition to make touch telemetry easier, but this is (1) unnecessary and (2) causes other issues.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D31183734

fbshipit-source-id: 6af669bb5696896b43fa4508af1171446d62c6d6
2021-09-24 18:11:33 -07:00
Samuel Susla 382e78e0f0 Cleanup react_fabric_marketplace_home_android_universe.enable_props_forwarding
Summary: changelog: [internal]

Reviewed By: GijsWeterings, ShikaSD

Differential Revision: D30835467

fbshipit-source-id: 6ce2a9dd64eb8a3711370fd07c1b0703b7b3345b
2021-09-24 05:09:58 -07:00
Pieter De Baets 6025611bd0 Use real propsParserContext in LayoutAnimation
Summary: Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D31053819

fbshipit-source-id: 8ec21012500f3bfc7e8aea018b5ca72323da2d9e
2021-09-21 04:24:28 -07:00
Pieter De Baets 9b97c09612 Short-circuit evaluation of formsView
Summary:
Changelog: [Internal]

Small optimization, we can avoid evaluating some properties if `formsStackingContext` is already set, because the end-result is always true.

Reviewed By: sammy-SC

Differential Revision: D30990925

fbshipit-source-id: 08f500aa4b75446a6c644e8821f84dbfccbfebb6
2021-09-17 07:25:54 -07:00
Kevin Gozali b0c8a4eee8 Link RCT-Folly against libc++abi
Summary:
Folly now depends on libc++abi. This solves linker error for RCT-Folly.podspec like this:

```
Undefined symbols for architecture arm64:
  "___cxa_increment_exception_refcount", referenced from:
      folly::exception_ptr_get_type(std::exception_ptr const&) in libRCT-Folly.a(Exception.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

See https://github.com/react-native-community/releases/issues/251

Note: RNTester was not affected by this bug for some reason, so the only way to verify is via the new app generated via `npx react-native init`.

Changelog: [Fixed][iOS] Unbreak Folly linker error

Reviewed By: lunaleaps

Differential Revision: D30950944

fbshipit-source-id: 3eb146e23faa308a02363761d08849d6801e21ca
2021-09-16 22:24:10 -07:00
Tim Yung 2f8cb57406 RN: Resolve `set-value@^4.1.0` Dependency
Summary:
Addresses this security vulnerability: https://github.com/advisories/GHSA-4jqc-8m5r-9rpr

Changelog:
[Internal]

Reviewed By: mdvacca

Differential Revision: D30976326

fbshipit-source-id: cb6ead029673774a5a6866d7b6014ab305669047
2021-09-15 18:11:01 -07:00