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

2600 Коммитов

Автор SHA1 Сообщение Дата
Valentin Shergin d5e244bcee Fabric: `SurfaceTelemetry` now contains/records recent transaction telemetry points
Summary:
Now SurfaceTelemetry records the last 16 full transaction telemetries. We will use it info to report to our trackers.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D22887633

fbshipit-source-id: 0d88adff757e4bc5a701b51d4d06d85e1f51f10f
2020-08-01 21:31:40 -07:00
David Vacca 1ae76bf0dd Remove inner folders of react/renderer/core
Summary:
This diff removes the inner folder of react/renderer/core, moving all its files into react/renderer/core

This is necessary to simplify the compilation of Fabric in OSS

More details: https://fb.quip.com/amaRA631DX3K

changelog: [internal] Internal

Reviewed By: fkgozali, JoshuaGross

Differential Revision: D22875854

fbshipit-source-id: e2d969c3ec67eab1bbdc9288e5a4285c740fa944
2020-08-01 13:31:03 -07:00
Ramanpreet Nara 111aab590e Forward the NativeModule schema jsi::Value to TMM
Summary:
If `__turboModuleProxy` is called with a second argument, we'll now forward that `jsi::Value` to TurboModuleManager on iOS and Android, so that the TurboModuleManager can eventually use this `jsi::Value` to read data required to perform method invocation on the TurboModule object.

**Note:** This diff is basically a no-op right now.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22828838

fbshipit-source-id: 19db2adcae6a58b4885fcd11bef23f9d5882bfce
2020-07-31 15:29:49 -07:00
David Vacca 3093010ea5 move fabric to ReactCommon/react/renderer
Summary:
This diff moves fabric C++ code from ReactCommon/fabric to ReactCommon/react/renderer
As part of this diff I also refactored components, codegen and callsites on CatalystApp, FB4A and venice

Script: P137350694

changelog: [internal] internal refactor

Reviewed By: fkgozali

Differential Revision: D22852139

fbshipit-source-id: f85310ba858b6afd81abfd9cbe6d70b28eca7415
2020-07-31 13:34:29 -07:00
Ramanpreet Nara 3741134bfb Instrument JavaTurboModule::invokeJavaMethod
Summary:
This diff instruments the following markers:
- ASYNC_METHOD_CALL
- ASYNC_METHOD_CALL_EXECUTION
- SYNC_METHOD_CALL

Changelog: [Internal]

Reviewed By: PeteTheHeat, JoshuaGross

Differential Revision: D22609409

fbshipit-source-id: 2e6752c46cb5a046a3c205b0f0ca5902275839cf
2020-07-31 12:49:14 -07:00
Ramanpreet Nara d22a121cb3 Implement asyncMethodCallFail
Summary:
The async NativeModule method call event can fail if something goes wrong when we're about do dispatch the method call.
Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D22609410

fbshipit-source-id: 699eeb78edfbefa85e417fd82318ae8e4f6f7d90
2020-07-31 12:49:14 -07:00
Ramanpreet Nara 9c35b5b8c4 Dispatch promise methods to the NativeModules thread
Summary:
In D17480605 (689233b018), I made all methods with void return types dispatch to the NativeModules thread. This diff makes the same change to methods with promise return types.

**Note:** The changes are disabled for now. I'll add an MC so that we can test this in production in a later diff.

Changelog:
[Android][Fixed] - Make promise NativeModule methods dispatch to NativeModules thread

Reviewed By: PeteTheHeat

Differential Revision: D22489338

fbshipit-source-id: d5b030871f9f7b3f48eb111225516521493cb05e
2020-07-31 12:49:14 -07:00
Jiayan Zhuang 0d3e535978 Add full support for AccessibilityState prop
Summary:
Changelog:[Fabric][iOS] Add full support for AccessibilityState

Since the AccessibilityState checked, busy or expanded only exist in Android and they don't have corresponding AccessibilityTrait to set, so we could just ignore the implementation in RCTViewComponentView.mm. What I did is to update the AccessibilityState values in AccessibilityPrimitives.h and accessibilityPropsConversions.h in order to enable further implementation in Android.

Reviewed By: shergin

Differential Revision: D22807584

fbshipit-source-id: f3ef048055d11314bc833357d8ca061e0fe219a4
2020-07-30 09:24:29 -07:00
Will Holen e1fa53af2e Implement Debugger.setBreakpointsActive
Summary:
Changelog: [Internal][Added] Support for toggling all breakpoints in Chrome debuggers

This implements the Debugger.setBreakpointsActive CDP message, allowing
users in Chrome to toggle all exceptions on and off.

As with V8/Chrome, setting a breakpoint will automatically re-activate
all breakpoints.

#utd-hermes-ignore-android

Reviewed By: avp

Differential Revision: D22825209

fbshipit-source-id: bda2cc59aba04443280bca46126c19bb0cdb58d7
2020-07-29 17:51:26 -07:00
Jiayan Zhuang 9b11cb6f1f Replace folly::Optional with better::optional in Fabric C++ files (#29518)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/29518

Changelog:
[Internal] - Replace folly::Optional with better::optional in Fabric C++ file

Reviewed By: shergin

Differential Revision: D22696909

fbshipit-source-id: c9b97403ac620789922fd1b5dbcbe5d3d910ed52
2020-07-28 17:28:26 -07:00
Patrik Tomas Chamelo 1b362f9f76 Fix ratio for color conversion
Summary: As part of our usage color detection that relies on precise values of colors, it appears that the ration used was 256, but RBGA scale is 0-255

Reviewed By: shergin

Differential Revision: D22785378

fbshipit-source-id: 87a6f9b4611ceaadbbbb75a4566f4cf9b8285b68
2020-07-27 23:40:39 -07:00
Samuel Susla cd6e2b468d Back out "Back out "[RN][Fabric] Introducing LayoutableShadownode::getContentOriginOffset and use it in ScrollView""
Summary:
This diff reverts a revert of D22456266 (0060b5de55) and fixes the reason why it was reverted. Reverted in D22532594 (c0e7e1bd9c).

For reason why it was introduced in the first place, please refer to D22456266 (0060b5de55).

Problem:
`includeTransform` was not taken into account when calculating offset.

I added a unit test covering this specific scenario.

Reviewed By: shergin

Differential Revision: D22763011

fbshipit-source-id: e7d88fc19608ad1a4c7b5e594a9cc48122a2799b
2020-07-27 13:23:53 -07:00
Valentin Shergin 476ab7481e Fabric: Enable zIndex only for non-`static` positioned views
Summary:
The standard says that zIndex should only be defined for non-`static` positioned views. This diff implements it.
For now, it actually enables zIndex for all views in RN because there is no way to specify `position: static` but will will give that ability by changing Flow definitions in future diffs in a couple of weeks (to ensure OTA safety).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22098586

fbshipit-source-id: 77dacbee0fe887f667ba81640b8bd759e1df11fd
2020-07-26 22:05:45 -07:00
Valentin Shergin ca6700f3c3 Fabric: ViewProps::zIndex now is `optional<int>` to be able store `auto`
Summary:
In W3C standard, `zIndex` prop can have `auto` value which is the default.
In classic React Native and in Fabric before this diff, the default value was `0`. The only difference between `auto` and `0` is that nodes with `auto` do not form stacking context whereas nodes with `0` (or any other numeric value) do. This worked fine in pre-Fabric RN where every view always formed staking context but in Fabric we need to finally implement it right.

https://developer.mozilla.org/en-US/docs/Web/CSS/z-index
https://stackoverflow.com/a/57892072/496389

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22403383

fbshipit-source-id: 6532d180a00f22bde763e3ebadd6683b344a0672
2020-07-26 22:05:45 -07:00
Valentin Shergin d53fc8a3cd Fabric: Moving layout calculation off JavaScript thread
Summary:
In the current Fabric model, we compute layout during the commit phase on the caller thread synchronously. Even though, in general, it's by design the correct way to do it, there are cases where it's *not* a requirement. In such cases, it's more optimal to yield early and continue execution of the commit process on a different thread asynchronously.
One of such cases potentially is `completeRoot` call. There we don't need to return anything and can resume JavaScript execution immediately.
The performance implications of that are not clear but there is a hope that it can free up to ~100ms of JavaScript execution time which is currently spent waiting for layout calculation (and other aspects of the commit phase).

This is an implementation in the core. The plan is to test that on iOS first and then, in case if the results of the experiment are positive, to implement it on Android as well.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D22743723

fbshipit-source-id: 846a13152c5a419de0eaef0e6283ea4277c907dc
2020-07-24 23:52:48 -07:00
Ramanpreet Nara 650c0f64f1 Make __turboModuleProxy accept > 1 args
Summary: For the JS TurboModule Codegen, we'll have to have `__turboModuleProxy` accept an additional argument: information containing what methods are supported on the TurboModule object. This diff makes calling `__turboModuleProxy` with two arguments valid.

Reviewed By: shergin

Differential Revision: D22743294

fbshipit-source-id: fd0050fc0373b43dc7089695c8e341137cad21f1
2020-07-24 18:30:20 -07:00
Joshua Gross c38b506d7a LayoutAnimations: fix index consistency crash
Summary:
Unfortunately LayoutAnimations index adjustment is a bit tricky. There was one (hopefully only one!) remaining issue where a specific series of delayed removes, inserts, and removes would trip up index adjustment. Namely in this case: Preexisting delayed removes, and then a later animated commit with immediate inserts followed by higher-index removes.

This case is now resolved and I took time to test and verify other index adjustment paths.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22709915

fbshipit-source-id: 16ba5bb358608d384f44628dbb6cc691deb8164a
2020-07-23 19:50:35 -07:00
Jiayan Zhuang f7eacf0b1a Remove const from text in RawTextProps
Summary:
Changelog:
[Internal] - Remove const from text in RawTextProps

Reviewed By: shergin

Differential Revision: D22607120

fbshipit-source-id: 18f7ab716342c3e5a8e469b12c5437a617be8583
2020-07-20 09:33:02 -07:00
Valentin Shergin ec60ebe792 Introducing `YGPositionTypeStatic`
Summary:
Changelog: [Internal] Fabric-specific internal change.
This diff introduces a new value for `YGPositionType`: `YGPositionTypeStatic`.
No part of Yoga, RN, Litho or CK uses this value yet. `relative` and `static` values behave the same way for now. We also do not change any defaults. So, it should be fine.

Reviewed By: SidharthGuglani

Differential Revision: D22386732

fbshipit-source-id: 39cd9e818458ac2a91efb175f24a74c8c303ff08
2020-07-20 00:33:22 -07:00
Oleg Bogdanov 6ffb983f83 Minor fix in Hermes Inspector cli tool help message
Summary:
Chrome recently changed schema from 'chrome-devtools' to just 'devtools',
this change updates Hermes inspector cli tool usage string to reflect that change

Changelog: Minor fix in Hermes Inspector cli tool help message

Reviewed By: dulinriley

Differential Revision: D22557806

fbshipit-source-id: 95ec9cbaac445e105e7e92aec2b6c4e5a7d7924f
2020-07-16 04:19:31 -07:00
Valentin Shergin 35f2cd26ae Fabric: Introducing `TelemetryController` as part of `MountingManager`
Summary:
This diff implements TelemetryController, a small tool that can be used to instrument mounting transactions. It abstracts the logic of merging telemetry data of multiple transactions in a thread-safe manner.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22490580

fbshipit-source-id: 3f3425b88d38fddb555c1390fd8f1ff3ef1c475a
2020-07-15 23:30:33 -07:00
Valentin Shergin 242c3c8343 Fabric: Introducing `SurfaceTelemetry`
Summary:
SurfaceTelemetry data structure represents telemetry data associated with a particular running Surface. We need it to aggregate data from multiple mount transaction.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22490579

fbshipit-source-id: e087aa9bc236af4da7010d67941f9ac93ad6da97
2020-07-15 23:30:33 -07:00
Jiayan Zhuang db365b86b2 Fix the accessibilityRole crash by updating values in the enum
Summary:
Changelog:
[Internal][Fixed] - Fix the accessibilityRole crash

I only assigned three values that would be used for embedded links inside text (button, link, image). But the accessibilityRole has a lot of values that may be applied in other places. (https://reactnative.dev/docs/accessibility) To avoid this crash, need to add all possible values to the enum.

Reviewed By: JoshuaGross, shergin

Differential Revision: D22549264

fbshipit-source-id: dbaacf1965624e1d2eabe193b46168c6c8740f46
2020-07-15 16:47:31 -07:00
Jiayan Zhuang 7485e93807 Back out "Change accessibilityRole to an enum"
Summary:
Changelog:
[Internal] - Revert "Change the accessibilityRole from a string to an enum."
Original commit changeset: b46ce0bd156c

Reviewed By: PeteTheHeat

Differential Revision: D22540391

fbshipit-source-id: df4a62c7bb4525782121dea2c70a9101cf0d8e9f
2020-07-14 22:38:31 -07:00
Joshua Gross c0e7e1bd9c Back out "Introducing LayoutableShadownode::getContentOriginOffset and use it in ScrollView"
Summary:
Original commit changeset: 6fd54661305a

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D22532594

fbshipit-source-id: 5ca25328cfe11416a9721a90611eff56e14cb49f
2020-07-14 19:03:13 -07:00
Valentin Shergin d3fb036d6e Using `YGPositionTypeAbsolute` value where we compare `absolute` vs `relative`
Summary:
Now Yoga.cpp does not use the `YGPositionTypeRelative` value/constant, it uses `YGPositionTypeAbsolute` instead.
Now `YGPositionType` can only be `YGPositionTypeRelative` or `YGPositionTypeAbsolute`, so expressions `x == YGPositionTypeRelative` and `x != YGPositionTypeAbsolute` are equivalent.
The reasoning behind the change is that in all cases we actually check a node to be (or not to be) `absolute`, not `relative`. This will make a difference in the coming diffs in the stack when we will introduce a new value for the type: `static`.

We need to differentiate `static` and `relative` values t implement the `stacking context` feature in the W3C-compliant way (to fix bugs and avoid developer confusion). Read more here:
https://developer.mozilla.org/en-US/docs/Web/CSS/position

Changelog: [Internal] Internal change in Yoga.

Reviewed By: SidharthGuglani

Differential Revision: D22386733

fbshipit-source-id: 8e2c2b88b404660639f845783c8f93f0c62c0fbb
2020-07-14 15:22:33 -07:00
Ramanpreet Nara 9f3b6082da Only show deadlock warning when TM eager init is on
Summary:
During setup, TurboModules may synchronously dispatch to the main queue, if they require main queue setup. This is dangerous because it could cause the app to deadlock during TurboModule require. This is why D21654637 (e206e34175) added a warning aginst this. However, this diff had a mistake. We only want to display the warning if TurboModule eager initialization is enabled, because then, we can eagerly initialize the TurboModules before the bridge starts to avoid the problem. D21654637 (e206e34175) instead showed the warning if TurboModule eager init **wasn't** enabled. This isn't useful, because there's no way to avoid the problem with TurboModu eager initialization off.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D22529780

fbshipit-source-id: 15238483758b66b1a6addcad948203c64dca96ad
2020-07-14 14:29:59 -07:00
Jiayan Zhuang 550c66ea64 Change accessibilityRole to an enum
Summary:
Changelog:
[Internal] - Change the accessibilityRole from a string to an enum.

The change aims to save storage especially when scaling. Also, the enum makes it more difficult to input wrong because it gets checked when compiling.

Reviewed By: sammy-SC

Differential Revision: D22396351

fbshipit-source-id: b46ce0bd156c7705020ef5b061d8ac29e2cf3948
2020-07-14 09:55:32 -07:00
Jiayan Zhuang fd660fd0c5 Add `importantForAccessibility` to `AccessibilityProps` and wire with `FormsStakingContext`
Summary:
Changelog:
[iOS][Added] - Add `importantForAccessibility` to `AccessibilityProps`

Reviewed By: shergin

Differential Revision: D22490327

fbshipit-source-id: aec7ff64ea6ddfe29bad085b87d09906fa8ee029
2020-07-14 09:29:13 -07:00
Samuel Susla 0060b5de55 Introducing LayoutableShadownode::getContentOriginOffset and use it in ScrollView
Summary:
Changelog: [Internal]

When calling "measure" on ScrollView's children, origin needs to be adjusted for ScrollView's content offset.
For this scrollView uses `getTransform` to adjust frames of its children.

This is wrong because transform is applied to ScrollView as well.

Example:
ScrollView is scrolled 900 points and its origin is {0, 0}, if you call "measure" on the ScrollView, our current measure infra will report its origin being {0, 900}.

Reviewed By: shergin

Differential Revision: D22456266

fbshipit-source-id: 6fd54661305ad46def8ece93fcf61d66817b3e01
2020-07-13 06:00:00 -07:00
Samuel Susla 34ff9b7259 Add view hierarchy drawings to tests
Summary:
Changelog: [Internal]

Add view hierachy drawings to tests to make it easier to picture view hierarchy.
The sketches do not reflect sizing but relationship among the views.
I removed unnecessary reset of transform value to identity matrix.

Reviewed By: JoshuaGross, shergin

Differential Revision: D22456267

fbshipit-source-id: 480d0b938ffd0281fc94148570c412b0fcc22f42
2020-07-10 02:11:44 -07:00
Ramanpreet Nara e549f6984e Gate TurboModule eager initialization
Summary:
TurboModule eager initialization is a bit dangerous if we get it wrong, which we did (twice): T69449176.

This diff gates TurboModule eager init behind a MC, so that we can control (i.e: turn off/on, and do gradually rollout of) TurobModule eager initialization in isolation from the larger TurboModules experiment.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22460359

fbshipit-source-id: 3b8dce0529f1739bd68b8b16d6a28aa572d82c2c
2020-07-09 16:24:31 -07:00
Eloy Durán ffa3d7f638 Build macOS framework and add CocoaPods podspec (#285)
Summary:
Supersedes https://github.com/facebook/hermes/issues/239

Currently used in our macOS fork of React Native https://github.com/microsoft/react-native-macos/pull/473. (Although we’re using a build of Hermes v0.4.1, as we’re at RN 0.62.0.)

* On Apple platforms build a [dynamic] framework bundle when `HERMES_BUILD_APPLE_FRAMEWORK` is set. When set to `FALSE` it will produce a `dylib`, like previously. Defaults to `TRUE`.
* On Apple platforms create a debugging symbols bundle.
* Add `HERMES_ENABLE_FUZZING`, which is enabled by default.
* Add `HERMES_ENABLE_TEST_SUITE`, which is enabled by default.
* Add a CocoaPods podspec that can build from source or use a binary.

A standalone macOS app that pulls in Hermes as a CocoaPods pod can be found here https://github.com/alloy/TestHermesMaster.

## Framework variant (default)

```
$ ./src/utils/build/configure.py --distribute --cmake-flags='-DCMAKE_INSTALL_PREFIX:PATH=../destroot_release' build
$ cd build && ninja install && cd ..
$ tree destroot_release/
destroot_release/
├── Library
│   └── Frameworks
│       ├── hermes.framework
│       │   ├── Headers -> Versions/Current/Headers
│       │   ├── Resources -> Versions/Current/Resources
│       │   ├── Versions
│       │   │   ├── 0
│       │   │   │   ├── Headers
│       │   │   │   │   ├── CompileJS.h
│       │   │   │   │   ├── DebuggerAPI.h
│       │   │   │   │   ├── Public
│       │   │   │   │   │   ├── Buffer.h
│       │   │   │   │   │   ├── CrashManager.h
│       │   │   │   │   │   ├── CtorConfig.h
│       │   │   │   │   │   ├── DebuggerTypes.h
│       │   │   │   │   │   ├── GCConfig.h
│       │   │   │   │   │   ├── GCTripwireContext.h
│       │   │   │   │   │   └── RuntimeConfig.h
│       │   │   │   │   ├── SynthTrace.h
│       │   │   │   │   ├── SynthTraceParser.h
│       │   │   │   │   ├── TraceInterpreter.h
│       │   │   │   │   ├── TracingRuntime.h
│       │   │   │   │   ├── hermes.h
│       │   │   │   │   └── hermes_tracing.h
│       │   │   │   ├── Resources
│       │   │   │   │   └── Info.plist
│       │   │   │   └── hermes
│       │   │   └── Current -> 0
│       │   └── hermes -> Versions/Current/hermes
│       └── hermes.framework.dSYM
│           └── Contents
│               ├── Info.plist
│               └── Resources
│                   └── DWARF
│                       └── hermes
├── bin
│   ├── hbcdump
│   ├── hdb
│   ├── hermes
│   ├── hermesc
│   └── hvm
└── include
    ├── hermes
    │   ├── CompileJS.h
    │   ├── DebuggerAPI.h
    │   ├── Public
    │   │   ├── Buffer.h
    │   │   ├── CrashManager.h
    │   │   ├── CtorConfig.h
    │   │   ├── DebuggerTypes.h
    │   │   ├── GCConfig.h
    │   │   ├── GCTripwireContext.h
    │   │   └── RuntimeConfig.h
    │   ├── SynthTrace.h
    │   ├── SynthTraceParser.h
    │   ├── TraceInterpreter.h
    │   ├── TracingRuntime.h
    │   ├── hermes.h
    │   └── hermes_tracing.h
    └── jsi
        ├── JSIDynamic.h
        ├── decorator.h
        ├── instrumentation.h
        ├── jsi-inl.h
        ├── jsi.h
        ├── jsilib.h
        └── threadsafe.h
```

# dylib variant

```
$ ./src/utils/build/configure.py --distribute --cmake-flags='-DHERMES_BUILD_APPLE_FRAMEWORK:BOOLEAN=false -DCMAKE_INSTALL_PREFIX:PATH=../destroot_release' build
$ cd build && ninja install && cd ..
$ tree destroot_release/
destroot_release/
├── bin
│   ├── hbcdump
│   ├── hdb
│   ├── hermes
│   ├── hermesc
│   └── hvm
├── include
│   ├── hermes
│   │   ├── CompileJS.h
│   │   ├── DebuggerAPI.h
│   │   ├── Public
│   │   │   ├── Buffer.h
│   │   │   ├── CrashManager.h
│   │   │   ├── CtorConfig.h
│   │   │   ├── DebuggerTypes.h
│   │   │   ├── GCConfig.h
│   │   │   ├── GCTripwireContext.h
│   │   │   └── RuntimeConfig.h
│   │   ├── SynthTrace.h
│   │   ├── SynthTraceParser.h
│   │   ├── TraceInterpreter.h
│   │   ├── TracingRuntime.h
│   │   ├── hermes.h
│   │   └── hermes_tracing.h
│   └── jsi
│       ├── JSIDynamic.h
│       ├── decorator.h
│       ├── instrumentation.h
│       ├── jsi-inl.h
│       ├── jsi.h
│       ├── jsilib.h
│       └── threadsafe.h
└── lib
    ├── libhermes.dylib
    └── libhermes.dylib.dSYM
        └── Contents
            ├── Info.plist
            └── Resources
                └── DWARF
                    └── libhermes.dylib
```

Pull Request resolved: https://github.com/facebook/hermes/pull/285

Reviewed By: willholen

Differential Revision: D22398354

Pulled By: mhorowitz

fbshipit-source-id: 732524275cf273866171fc6e2ac2acb062185fbd
2020-07-08 17:15:09 -07:00
Ramanpreet Nara e206e34175 Add a warning if TurboModule init uses dispatch_sync for main queue
Summary:
When you require a TurboModule on thread that isn't the main thread, but the TurboModule requires main queue setup, we are forced to `dispatch_sync` the set up to the main queue. This is hazardous, because it can lead to deadlocks. Therefore, I'm migrating over a warning from the legacy infra that warns against this use-case.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D21654637

fbshipit-source-id: 99dc45708c533603d2111fe6163d40e807d2a513
2020-07-08 11:49:32 -07:00
Ramanpreet Nara e96f1e1d83 Refactor: Attach TurboModuleRegistry to bridge in FBReactModule
Summary:
The changes in this diff are inconsequential. Just thought it was weird that TurboModuleManager was responsible for assigning itself to the bridge. Seems like that should be done by an entity that owns both the bridge and the TurboModuleManager.

Changelog:
[Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22406172

fbshipit-source-id: cb32f097f4d377a3b85a6d165b7b06be8e6a185b
2020-07-07 16:25:11 -07:00
Ramanpreet Nara a27c295f53 Rename RCTTurboModuleLookupDelegate to RCTTurboModuleRegistry
Summary:
## Why?
1. RCTTurboModuleLookupDelegate sounds a bit nebulous.
2. In JS and Java, we use a `TurboModuleRegistry` interface to require TurboModules. So, this diff will make JS, Java, and ObjC consistent.

Changelog:
[Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22405754

fbshipit-source-id: 30c85c246b39d198c5b8c6ca4432a3196ca0ebfd
2020-07-07 16:25:11 -07:00
Ramanpreet Nara 103c863eaa Eagerly initialize TurboModules before executing JS bundle
Summary:
## Context
1. In FBReactModule jsExecutorForBridge, we asynchronously initialize a list of TurboModules on the main queue: https://fburl.com/diffusion/i56wi3px
2. After initializing the bridge, we start executing the JS bundle, here: e23e9328aa/React/CxxBridge/RCTCxxBridge.mm (L414-L417). Since bridge initialization knows nothing about TurboModule eager initialization, this happens concurrently with 1, and starts requiring NativeModules/TurboModules on the JS thread.

## The Race
1. Both the main thread and the JS thread race to create a TurboModule that requires main queue setup.
2. The JS thread wins, and starts creating the TurboModule. Meanwhile, the main thread blocks, waiting on a signal here, in RCTTurboModuleManager: e23e9328aa/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm (L430)
3. The JS thread tries to dispatch_sync to the main queue to setup the TurboModule because the TurboModule requires main queue setup, here: e23e9328aa/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm (L402)
4. We deadlock.

## The fix
Succinctly, NativeModule eager initialization finishes before execute the JS bundle, but TurboModule initialization doesn't. This diff corrects that mistake.

The changes in this diff:
1. The RN application via the TurboModuleManager delegate can now optionally provide the names of all eagerly initialized TurboModules by implementing two methods `getEagerInitModuleNames`, `getEagerInitMainQueueModuleNames`.
2. The TurboModuleManager grabs these two lists from the delegate, and exposes them to its owner via the `RCTTurboModuleRegistry` protocol.
3. The RCTCxxBridge, which already owns a `id<RCTTurboModuleRegistry>` object, uses it to eagerly initialize the TurboModules in these two lists with the correct timing requirements.

This is exactly how we implement eager initialization in Android.

**Note:** Right now, phase one and two of TurboModule eager initialization happen after phase one and two of NativeModule eager initialization. We could make the timing even more correct by initializing the TurboModules at the exact same time we initialize the NativeModules. However, that would require a bit more surgery on the bridge, and the bridge delegate. I think this is good enough for now.

Changelog:
[iOS][Fixed] - Fix TurboModule eager init race

Reviewed By: PeteTheHeat

Differential Revision: D22406171

fbshipit-source-id: 4715be0bceb478a8e4aa206180c0316eaaf287e8
2020-07-07 16:25:10 -07:00
Joshua Gross 90287ca536 Make ShadowTreeRegistry `remove` API safer
Summary:
Currently the `remove` API returns an owned unique_ptr of the removed ShadowTree but it's not used anywhere, so we can simplify the API.

Because of that change, we can make the API safe even if the SurfaceId has already been removed.

For context, on Android there is a race between RootView.unmountReactApplication and C++ teardown which removes all SurfaceIds. This currently causes a crash, but after this diff the 2nd call to `remove` for a given SurfaceId will noop.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D22416471

fbshipit-source-id: dbba44c276aab8e81097b92a89e0becdcb7b28ba
2020-07-07 13:01:47 -07:00
Valentin Shergin e23e9328aa Fabric: Geometry.h is spit to several separate files
Summary:
We are about to add several additional functions to this file, so we need to split it to keep it manageable. All changes in this diff are cosmetical.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22384429

fbshipit-source-id: d22592fba17ef04edb44388b4e1ff22112e9c020
2020-07-06 20:57:46 -07:00
Jiayan Zhuang c4c6204029 Add accessibilityRole to RCTAttributedTextUtils
Summary:
Changelog:
[Internal] - Add `accessibilityRole` to `RCTAttributedTextUtils`. AccessibilityRole was in `TextAttributes` which is a Fabric's abstraction so cannot be detected when enumerating attributedString.  Mapping accessibilityRole from `TextAttributes` to `NSAttributedString` could provide the attributeName when iterating over attributedString and then successfully find the range of the fragment whose `accessibilityRole` has value @"link".

Reviewed By: shergin

Differential Revision: D22286747

fbshipit-source-id: eb039d6a35e77d1860f86ba287391ccb56fbe7b5
2020-07-06 15:00:58 -07:00
Jiayan Zhuang 96708d58e4 Add getRectWithAttributedString() to RCTTextLayoutManager
Summary:
Changelog:
[iOS][Added] - `getRectWithAttributedString()` aims to get the rect of the fragment with embedded link, which is necessary when building the `accessibilityElement`. In this function, we first enumerate attributedString to find the range of fragments whose `accessibilityRole` is @"link". Then we calculate the rect of the fragment and send to the block and we would define what to do in the block in `RCTParagraphComponentAccessibilityProvider`.

Reviewed By: shergin

Differential Revision: D22286733

fbshipit-source-id: 4d11cb54375a4e9e72869e646fcb484de089b14b
2020-07-06 15:00:58 -07:00
David Vacca c4de0c7a0a Move ART out of OSS
Summary:
ART has been moved out of OSS, but I created the fabric implementation in github repo, this diff migrates the Fabric ART implementation to FB repository again

changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22352930

fbshipit-source-id: 1125d3f27b98be783529134de0d3fbcf1b01a6f4
2020-07-02 14:06:39 -07:00
Jiayan Zhuang 8fb1bb8da7 Add accessibilityRole to TextAttributes
Summary:
Changelog:
[Internal] - The accessibilityRole will be used to specially distinguish normal fragments and fragments with embedded link, which is helpful when building accessibilityElement.

According to this document: https://reactnative.dev/docs/accessibility, the accessibilityRole is a common accessibility props that could be inherited, and this is why I add accessibilityRole to the TextAttributes.

Reviewed By: sammy-SC

Differential Revision: D22249140

fbshipit-source-id: 408b4415bf44539d8671d3d98f1ec06f8035baf6
2020-07-02 13:01:47 -07:00
Samuel Susla 40f37b986b Temporarily disable support for transformations in findNodeAtPoint infrastructure
Summary:
Changelog: [Internal]

FindNoteAtPoint takes transformations into account. There is however a problem with how transformation in ScrollView. In ScrollViewShadowNode, getTransform is overriden. In the override we apply `Transform::Translate(-contentOffset.x, -contentOffset.y, 0)`, this means that ScrollView has moved by {-x,-y}. However this is only true for its children, not for scroll view itself. This trips off findNodeAtPoint and if you scroll more than than screen's height, point will not be evaluated as inside ScrollView.

Until we can figure out how to deal with this properly, I think it is better to disable it as usage of JS Inspector is more common in ScrollViews than it is with transformed views.

Reviewed By: shergin

Differential Revision: D22332779

fbshipit-source-id: f48c9ae67a595e6954c2b70fb287db7f8c74378b
2020-07-02 12:29:22 -07:00
Christoph Nakazawa e881b244ca Remove JSDeltaBundleClient
Summary:
This was an experiment that never shipped. In the meantime we built Fast Refresh which obviates the need to complicate how we load and store bundles on device.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D22330994

fbshipit-source-id: 5a623b2611dd2622f17dd83ed35ef05c3100e40d
2020-07-02 04:06:19 -07:00
Valentin Shergin 3c69a9eb4b Fabric: `display: none` nodes do not create views anymore
Summary:
This introduces a new shadow node trait (`Hidden`) which disables emitting ShadowVides for such nodes and all their descendants.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22134220

fbshipit-source-id: 8ea1fc3186019005ad687eacaca0ba4a4d8343dc
2020-07-01 20:54:58 -07:00
Riley Dulin 3c3f8ca270 Add a special case for assert in installConsoleFunction
Summary:
The Hermes inspector always logged the message for `console.assert`.
It instead should check the first argument, and only if that argument
is false should it log.

Also remove the polyfill code that tried to avoid this situation.

Changelog: [Internal]

Reviewed By: mhorowitz

Differential Revision: D22299186

fbshipit-source-id: cdf4f8957d4db3d171d6673a82c7fc32b7152af3
2020-06-30 21:15:52 -07:00
Valentin Shergin 753fdebcd4 Fabric: Removing `get/setHasNewLayout` from LayoutableShadowNode interface
Summary:
It's a Yoga specific feature that does not need to exposed as LayoutableShadowNode.
Removing this we save many virtual calls and add simplicity.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22304717

fbshipit-source-id: f2dda8309dd86b78cd2775971721d29e5317ffd5
2020-06-30 10:28:22 -07:00
Valentin Shergin 72a85040cd Fabric: Unit test for Overflow Inset feature
Summary:
Subject.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D22297335

fbshipit-source-id: 299998094017f3396be2531f8d6bcfb787e94eed
2020-06-30 10:28:22 -07:00
Valentin Shergin 83d7fbcf94 Fabric: Implementation of `LayoutMetrics::overflowInset`
Summary:
`Overflow inset` is a field in LayoutMetrics that describes the external bounding box that covers area formed by all descendants of the view (that might stick out of the frame of the view).

This information can be used for various optimizations across all rendering pipeline. Here is some of them:
Improving hit-testing performance.
Implementing a robust "remove invisible native views" feature.
Improving `clipToBounds` performance.
Improving View Flattening versatility.

Most importantly, we need this for improving <ScrollView> performance (and memory footprint) which we have to do to match parity with Paper's `removeClippedSubviews` feature.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22297325

fbshipit-source-id: cb238f0505d11ccabbe9db26f36a98b3172c70db
2020-06-30 10:28:22 -07:00
Valentin Shergin d3c1011c09 Fabric: `LayoutableShadowNode::layoutChildren()` was merged into `layout()`
Summary:
After years of trying to design a somehow decomposed and universal layout API, I think we chased a wrong goal. None of the solutions that I tried helped with simplicity, composability, performance, or readability. Besides that, a bunch of execution primitives we use (e.g. `setHasNewLayout`) are heavily influenced by Yoga and are far from being commonly applicable. Finally, we ended up with a situation where the current design does not allow us to implement the features we want (more about that in coming diffs).
The diff changes that. Now we have only one method that implements layout - `layout()`; all possible implementations are free to implement it in any way that makes sense for a particular approach. And, I think, even for the base case - Yoga powered layout - things are much simpler and faster now: it's easy to comprehend how a single method works and now we don't have two loops and an expensive call to `getLayoutableChildNodes`.
But most importantly, after this change will be able to implement the `Inset Overflow` feature quite easily.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D22297317

fbshipit-source-id: f8662b7e8e3b522bdd6e5b2b0ac6a06efb45be6d
2020-06-30 01:47:16 -07:00
Samuel Susla 3d4535a2bb Introduce InputAccessoryView
Summary:
Changelog: [Internal]

Introducing InputAccessoryView.

There is one big difference between Fabric's implementation and Paper's implementation.

Fabric searches for text input from InputAccessoryView, unlike Paper where it is the other way around.

Reviewed By: shergin

Differential Revision: D22160445

fbshipit-source-id: 55313fe50afeced7aead5b57137d711dd1cfd3ae
2020-06-30 01:36:04 -07:00
Joshua Gross 23fbfc1977 Remove SectionList hack that causes Fabric crash
Summary:
View elevation is an Android-only prop, and it's a float, not an int. https://www.codota.com/code/java/methods/android.view.View/setElevation

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22298431

fbshipit-source-id: 91edc3aa64e7254a5c4a4cb33f26e64ebae89b8d
2020-06-29 18:22:14 -07:00
Valentin Shergin 8ceb808937 Fabric: Removing `LayoutContext::absolutePosition`
Summary:
Here is why:
	* It was with us from the very beginning but we never use it.
	* The main purpose of this - snap-to-pixel layout - was moved to Yoga, where it should be.
	* The current implementation has a bug.
	* It's not really correct conceptually because the value becomes incorrect when an immutable subtree is being reused as part of a new tree.
	* It over-complicates a new feature I am working on.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22284645

fbshipit-source-id: c4c2df8d24e8fe924725b465e04e8154d097d226
2020-06-29 15:54:08 -07:00
Valentin Shergin 559c60cf39 Fabric: Implementation of `insetBy(Rect, EdgeInsets) -> Rect`
Summary:
A function in graphics/geometry which adjusts a rectangle by the given edge insets.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22284644

fbshipit-source-id: ad78abd7889b4457c450b2cc43fb73054aef2c79
2020-06-29 15:54:08 -07:00
Valentin Shergin 8c14d518ce Fabric: Removing `const` qualifiers from some *Props fields
Summary:
Same as D19583582 (5b2ea6ec6a).
We need this for implementing some tests.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D22284646

fbshipit-source-id: 9dd6575475c133b9426838021af4d59fb9fc3c65
2020-06-29 15:54:08 -07:00
Omer Peleg 530d11c506 Fix RN OSS build (#29221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/29221

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D22234372

fbshipit-source-id: 9b83ec3aa57254826be44ac0f73aeb34fb859337
2020-06-25 11:09:42 -07:00
Joshua Gross 6342e6e3f1 LayoutAnimations: attempt to work around potential crashes when animation is racing with setup or teardown
Summary:
Attempt to fix T68951888 where (1) ComponentHandle is zero, and/or (2) ComponentHandle is missing in the registry. Either will cause a crash and both should be trivial to work around. I was able to repro once accidentally in about 1/200 sessions, so I am not 100% sure if this fixes the root cause.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22216030

fbshipit-source-id: b6986adee6fe739ce58579a2b031a2d252e73e35
2020-06-24 16:36:28 -07:00
Joshua Gross 2e27fb6a97 LayoutAnimations: for all Transform matrices, store decomposed matrix and use that for interpolation
Summary:
Previously, we tried to take a Transform matrix, decompose it into parts, and then interpolate between those parts. This will always be risky at best, and in some cases ambiguous or unsolvable. For example, a scale of -1 is identical to a rotation of 180 degrees.

Another issue is that when decomposing a matrix, it is impossible to tell the sign of scaleX, scaleY, scaleZ. This is a problem - flipping a View over an axis via scale then becomes a non-animatable operation.

This caused a number of issues.

To resolve it, we accumulate the "operations" resulting in a particular transform. This allows us to easily interpolate between two Transform matrices without actually decomposing the matrix, since we have the "path" that resulted in each particular matrix.

This will make LayoutAnimations over transforms, including Skew transforms, look and work much better, and more reliably.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D22204559

fbshipit-source-id: 0d88ae77e4399a7ea333afbf6062beea977b854a
2020-06-24 16:36:28 -07:00
Vitaly Potlov 208e4d2dcd Fix static method in file header (#29118)
Summary:
I have looked into recent commits and found a typical mistake when static is used in .h file.
Here static is not necessary. See link: https://stackoverflow.com/questions/780730/c-c-static-function-in-header-file-what-does-it-mean

## Changelog
Changelog: [Internal] Fabric-specific internal change.
Pull Request resolved: https://github.com/facebook/react-native/pull/29118

Reviewed By: sammy-SC

Differential Revision: D22039305

Pulled By: shergin

fbshipit-source-id: 7078e716166067dd1e94cbb84200a1235283c978
2020-06-24 12:30:45 -07:00
Samuel Susla 30054645c7 Set clipped to YES when loading an image
Summary:
Changelog: [Internal]

When Paper loads images. it calls with with `clipped` being set to NO.
https://github.com/facebook/react-native/blob/master/Libraries/Image/RCTImageView.mm#L346

We should do the same in Fabric as it can result in different images being loaded.

Reviewed By: JoshuaGross, shergin

Differential Revision: D22185286

fbshipit-source-id: 04afafee67fdfac53e9d17f5edeaf9b9317c7a22
2020-06-23 15:02:19 -07:00
Samuel Susla 722a4ba561 Fix default value for shadow props
Summary:
Changelog: [Internal]

Our default values in ViewProps are incorrect for `shadowColor`, `shadowOffset` and `shadowRadius`.

The default value for shadowRadius isn't {0, 0} but {0, -3}.
Source: https://developer.apple.com/documentation/quartzcore/calayer/1410970-shadowoffset?language=objc

The default value for `shadowColor` is black opaque color.
Source: https://developer.apple.com/documentation/quartzcore/calayer/1410829-shadowcolor?language=objc

The default value for shadowRadius isn't 0 but 3.
Source: https://developer.apple.com/documentation/quartzcore/calayer/1410819-shadowradius?language=objc

Reviewed By: shergin

Differential Revision: D22091927

fbshipit-source-id: fc135fca6a487cd30f8183d88b0065e007a9eacb
2020-06-22 13:26:34 -07:00
Samuel Susla c3d4d2a3d2 Remove buck test declaration for Modal component
Summary:
Changelog: [Internal]

Remove redundant test target

Reviewed By: shergin

Differential Revision: D22115084

fbshipit-source-id: 6d7a9bade2217c7afb4f482590a35e3eb170d3d6
2020-06-22 09:02:42 -07:00
David Vacca 8cbbd93c40 Refactor Text input state
Summary:
This diff refactors the theme management for text input in order to avoid extra state updates.

changelog:[Internal]

Reviewed By: JoshuaGross

Differential Revision: D22149754

fbshipit-source-id: 8a6dbe63c8d532986dbf785c7b16323e0a980669
2020-06-19 21:50:43 -07:00
Joshua Gross a7860b64d0 LayoutAnimations: iron out some additional index-adjustment bugs
Summary:
Index adjustment is complicated since we defer REMOVE operations. This diff solves some remaining (hopefully final!) bugs found when queueing several conflicting LayoutAnimations repeatedly (this is sort of an "extreme" case since we're continuously re-queueing additional LayoutAnimations instead of allowing any to complete, while reordering and deleting, so it exercises the most extreme LayoutAnimations use-cases).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22150085

fbshipit-source-id: db1381bef3ba8bb5ec82dab791f69162d46d23f0
2020-06-19 20:28:05 -07:00
Joshua Gross 57fcf6c268 LayoutAnimations: when delaying a REMOVE operation, insert operation indices on the same level must also be adjusted
Summary:
This will prevent views from becoming out-of-order as view removals are delayed and there are inserts at the same level.

There is at least one additional issue that crops up if many animations are queued up at the same time, that will be resolved separately.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D22130185

fbshipit-source-id: d8041c6afdcd729939dd392c9e2c23fe8ec1b706
2020-06-19 11:13:35 -07:00
Joshua Gross 11ed9c2573 Fix Android diagnostic-debugging builds
Summary: Fix compiler errors when RN_DEBUG_STRING_CONVERTIBLE is defined.

Reviewed By: mdvacca

Differential Revision: D22103936

fbshipit-source-id: 7a5278b1ef70a766467a03461c7bac69848e9fa5
2020-06-19 11:13:35 -07:00
Samuel Susla 1279a4c89d Fix order of events when dispatching unique event
Summary:
Changelog: [Internal]

Order of events dispatched to JS matter. If we remove duplicate events, we shouldn't change order of types.

So If we have order of events

A -> B -> C

and inserting a new event A for the same target, we shouldn't delete the first A, as there might be logic that depends on event B being preceded by A.

What we can do though, is delete previous event of the same type and target in queue if we would be adding subsequent event.

So when we have events

A -> B -> C

and we are about to add event C to the queue which goes to the same target, we can delete the first C before inserting the new one.

Reviewed By: shergin

Differential Revision: D22135931

fbshipit-source-id: 1dadd1688516330be07c4251f446f77ca08eaa87
2020-06-19 11:09:46 -07:00
Daniel Andersson 709570acfb Add sanity checks to JSBigFileString
Summary:
When asking for the data of a JSBigFileString, check that the instance satisfies some basic invariants.

This is meant to catch any corruption issues as early as possible.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22125436

fbshipit-source-id: e0a84752c86151d56b7e7cbed3b95650d8ba1f75
2020-06-18 20:51:59 -07:00
Luna Wei 568d2206f7 Add non-fatal error handling
Summary:
## Changelog:

[Internal][Added] - Additional option to report non-fatal JS error

Reviewed By: ejanzer

Differential Revision: D22054406

fbshipit-source-id: 25e2a8d45f086173b09ee095331f94364cae4c1a
2020-06-18 16:58:21 -07:00
Kacie Bawiec 8e1b812779 Add FDSTooltipView to LegacyViewManagerInterop for Fabric
Summary:
Add tooltip to the list of components supported with the legacy view manager, so that it will work in Fabric.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D21917137

fbshipit-source-id: 1ab6c7cdd0a10a496531d2ea8fbcae7e427ec647
2020-06-17 13:22:57 -07:00
Samuel Susla 36b586ada1 Font size in Text now respects preferredContentSizeCategory
Summary:
Changelog: [Internal]

Add support for dynamic font size.

New class `ThreadStorage` is introduced, which is used to pass LayoutContext to `YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector`.

## Shortcoming
This implementation doesn't cause re-render, if user changes font size and comes to the app without restarting it, it will show old font size. I believe this is fine for now as most people set their font size before they use the app and keep the same setting for a long time.

Reviewed By: shergin

Differential Revision: D22043728

fbshipit-source-id: 7453d165c280a2f4bcb73f4ee6daf9e64b637ded
2020-06-17 10:22:32 -07:00
Samuel Susla ec9da43de5 Rename LayoutableShadowNode::measure to LayoutableShadowNode::measureContent
Summary:
Changelog: [internal]

Rename `LayoutableShadowNode::measure` to `LayoutableShadowNode::measureContent` and add LayoutContext as parameter.

Pass `LayoutConstraints` by reference rather than value.

Reviewed By: shergin

Differential Revision: D22043727

fbshipit-source-id: b668240c45b658db5b114630b73d7407d35482aa
2020-06-17 10:22:32 -07:00
Christoph Nakazawa 56689e9e28 Remove legacy bytecode handling
Summary:
Changelog: [Internal]

A long time ago we experimented with JSC bytecode. We are not experimenting with JSC bytecode any more. This code can be removed.

Reviewed By: mhorowitz

Differential Revision: D22017374

fbshipit-source-id: 6fe3fb7ad7966f92a5cd103605ac5c0bd1f17a8e
2020-06-16 02:12:09 -07:00
Joshua Gross e0294aff68 LayoutAnimations: fix crashes
Summary:
Fix crashes in LayoutAnimations:

1) It is valid to omit create, update, delete configs
2) When extracting SRT from a matrix, ignoring skew properties
3) Provide valid telemetry from LayoutAnimations transactions

Unrelated to crashes: to help debugging and until onSuccess/onError callbacks are working, log any configuration parsing errors.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22050736

fbshipit-source-id: e59418ecad0f9bfd20a2b4976557e39020c2d101
2020-06-15 17:33:07 -07:00
David Vacca 6d6268e903 Fix padding flickering visible during initial render of text input
Summary:
This diff fixes a race condition that caused a flicker during initial rendering of TextInput in Fabric

The root cause is that the TextInput's State is sometimes initialized with no information from the Theme, this causes text input to be rendered with 0 padding. Later ReactTextInput manager updates TextInput state with theme data and the TextInput is re-rendered with the correct padding information.

changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D22034849

fbshipit-source-id: a2fa91f34a8340878f2ec8d231ef6c86cee08f05
2020-06-13 22:20:04 -07:00
Samuel Susla ccf5c86bd7 Implement autoFocus in TextInput
Summary:
Changelog: [Internal]

Prop autoFocus was not implemented in Fabric's TextInput.

Reviewed By: mdvacca

Differential Revision: D22019333

fbshipit-source-id: 03f043b93e1079a5d0bff55b08ebc9d2f973c55b
2020-06-13 11:04:40 -07:00
Samuel Susla 8dce59cee8 Add incomplete support for accessibility state prop
Summary:
Changelog: [internal]

Minimal implementation of `accessibilityState` that supports `disabled` and `selected` props.

Complete implementation will need to support following props
```
export type AccessibilityState = {
  disabled?: boolean,
  selected?: boolean,
  checked?: ?boolean | 'mixed',
  busy?: boolean,
  expanded?: boolean,
  ...
};
```

Reviewed By: mdvacca

Differential Revision: D22016743

fbshipit-source-id: 1748acc4279f60ec8a92c93d5d13b136f57eb8d3
2020-06-12 11:19:49 -07:00
empyrical fb2a7765ac Update podspecs for latest Fabric changes (#28584)
Summary:
This pull request updates the Podspecs to reflect recent changes to Fabric, so they build with Fabric enabled again.

In `React-Fabric.podspec`, subspecs for the views `legacyviewmanagerinterop`, `safeareaview`, `textinput`, and `unimplementedview` are added. A minor tweak to the subspec for `rncore` was added blacklisting two codegen-generated files that have issues building, but are not actually needed yet and are empty.

In `React-graphics.podspec`, the header paths for Boost were added.

This is partially a retread of https://github.com/facebook/react-native/issues/26805, which had to be backed out due to issues with the changes to the Yoga podspec.

## Changelog

[Internal] [Fixed] - Fixed building Fabric with the Cocoapods
Pull Request resolved: https://github.com/facebook/react-native/pull/28584

Test Plan: RNTester can now compile.

Reviewed By: shergin

Differential Revision: D20966065

Pulled By: hramos

fbshipit-source-id: 73931be63b72fcb52705643f81c0f787e571eb76
2020-06-12 10:51:33 -07:00
Samuel Susla fb8411d4df Round text size to closest larger pixel size
Summary:
Changelog: [Internal]

Round calculated text size to closest larger pixel size.
In Paper we do this as well in https://fburl.com/diffusion/w2pj6ea0

Why do we need this?
For example, we calculate height of the text to be 16.707235, yoga takes this value and assigns text to have height 17 anyway.
I assume Yoga uses this extra 0.3 points of height to move other things around a little bit because Yoga doesn't deal with exact values.

Reviewed By: shergin

Differential Revision: D21999032

fbshipit-source-id: 73923dc3e27fa110adb3f76cfa635e0bfdc672d4
2020-06-11 12:36:13 -07:00
Valentin Shergin 03443d77f5 Fabic: Opening up fields of ShadowNodeFamilyFragment::Value and ShadowNodeFragment::Value
Summary:
There is no good reason why they are `const` and `private`, in the future diffs we will need to mutate them.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21992197

fbshipit-source-id: f8aee8db9ea1ff8282b38fbe3a966911678ee2c4
2020-06-11 09:48:38 -07:00
Emily Janzer 92630856c6 Move error handling with JSI into a separate helper function (#29090)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/29090

Moving the logic for calling into JS to handle errors into ErrorUtils, where it can be reused outside of the bridge.

Reviewed By: RSNara

Differential Revision: D21939254

fbshipit-source-id: 0d8f3bd2503720be7619ed8dc8b2389f544049f3
2020-06-10 10:31:46 -07:00
Valentin Shergin a28a52dd64 Fabric: Using ManagedObjectWrapper in RCTTextLayoutManager
Summary:
While I was investigated the previous issue (T59430348) I found this place where we manipulate managed pointers manually. So, to make it error-prone this diff changes it to use `wrapManagedObject`.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D21943010

fbshipit-source-id: ecaeffb419ae8d4880187027ca7ec9563e0dfd46
2020-06-09 12:40:43 -07:00
Valentin Shergin 2a80579ea1 Fabric: Checking for `nullptr` before calling `CFRelease` in `ManagedObjectWrapper`
Summary:
ManagedObjectWrapper (`wrapManagedObject`) is used to pass pointers managed by Objective-C runtime object thought C++ parts of the framework. The wrapper consists of a shared pointer to an object with a custom deleter that calls `CFRelease`.
Apparently, there is a caveat here: shared ptr implementation always calls a deleter even if the object points to `nullptr`. It's usually fine because in C++ calling `delete` on a nullptr is a no-op, not an error. But it's an error from the `CFRelease` perspective, which checks the pointer and crashes if it's nullptr.

More info:
https://stackoverflow.com/questions/1135214/why-would-cfreleasenull-crash
https://stackoverflow.com/questions/50201967/why-unique-ptr-with-custom-deleter-wont-work-for-nullptr-while-shared-ptr-does

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21943011

fbshipit-source-id: 442ad5e274a146de112e6bd8f3c2d20f0225bf77
2020-06-09 12:40:42 -07:00
Samuel Susla 485475ab3e Use CGColorRelease instead of CGRelease
Summary:
Changelog: [Internal]

`CFRelease` crashes app if `cf` is `NULL`, `CGColorRelease` doesn't.

From:
https://developer.apple.com/documentation/coregraphics/1586340-cgcolorrelease?language=objc#

Even though this hasn't happened yet, we had a similar crash in D21943011. Also `CGColorCreate` returns nullable so it could happen.
In order to prevent this in the future, let's switch to `CGColorRelease` which doesn't crash if `cf` is `NULL` and also is semantically correct.

Reviewed By: shergin

Differential Revision: D21953404

fbshipit-source-id: 8b969ee345c2507fcba2442fa20e3fdaf2235d8c
2020-06-09 12:20:58 -07:00
Samuel Susla 1fa3a8e475 Form stacking context if display style is none
Summary:
Changelog: [Internal]

View gets flattened even though it has `display: none` and therefore it and its children do not get hidden.

Reviewed By: shergin, mdvacca

Differential Revision: D21929033

fbshipit-source-id: 994a79fb64fbe66273a70218ebe8056d92cd3cd4
2020-06-09 02:31:00 -07:00
Ryan Tremblay 9c32140068 Enable array buffers in JSCRuntime.cpp (#28961)
Summary:
The JavaScriptCore implementation of JSI [does not currently support array buffers](https://github.com/facebook/react-native/blob/master/ReactCommon/jsi/JSCRuntime.cpp#L925-L943). The comments in the code suggest the JSC version used by React Native does not work with array buffers, but this seems to be out of date since the current version of JSC used by React Native does indeed support array buffers. This change just enables array buffers in JSCRuntime.cpp.

NOTE: See https://github.com/react-native-community/discussions-and-proposals/issues/91#issuecomment-632371219 for more background on this change.

## Changelog

[General] [Added] - Support for array buffers in the JavaScriptCore implementation of JSI
Pull Request resolved: https://github.com/facebook/react-native/pull/28961

Test Plan:
To test these changes, I just made some temporary changes to RNTester to use JSI to inject a test function into the JS runtime that reads from and writes to an array buffer, and call that function from the JS of the RNTester app (see 28152ce3f4).

For the JS side of this, specifically look at 28152ce3f4/RNTester/js/RNTesterApp.android.js (L13-L18)

For the native side of this, specifically look at 28152ce3f4/RNTester/android/app/src/main/cpp/JSITest.cpp (L22-L38)

Reviewed By: shergin

Differential Revision: D21717995

Pulled By: tmikov

fbshipit-source-id: 5788479bb33c24d01aa80fa7f509e0ff9dcefea6
2020-06-09 01:11:53 -07:00
Sidharth Guglani fc2b538f0d use fmod and YGDoubleEquals for double operations instead of float
Summary: Changelog: [Internal][Yoga] Use double operations during rounding

Reviewed By: mdvacca

Differential Revision: D21840018

fbshipit-source-id: c5d17fcb8984b1da9832a15ccd4d628e8d742c6a
2020-06-08 08:10:21 -07:00
Emily Janzer a50fa552a7 Fix CircleCI by adding dependency on JSI to cxxreact (#29087)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/29087

D21908523 added an implicit dependency on `jsi.h` to use functions like `asObject`, etc. For some reason this doesn't break the build with BUCK (??) but it does with cocoapods. Adding the dep to the cxxreact podspec and regenerating offline mirrors to unbreak CircleCI. Also adding the BUCK dep and include statement for good measure.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21924592

fbshipit-source-id: 295c0670c6499e1195ba3c3a3320c6aee13bc025
2020-06-07 17:55:16 -07:00
Samuel Susla 6860cb0775 Fix KERN_INVALID_ADDRESS in configureNextLayoutAnimation
Summary:
Changelog: [Internal]

The crash is caused by dereferencing invalid pointer.
This can happen because `UIManager` can outlive `RCTScheduler` and `Scheduler`.

Here we make sure when `Scheduler` is being deconstructed, UIManager's pointer is invalidated.

I don't think this is ideal solution but it should fix the crash.
Ideally we want the owner of animation delegate to invalidate the pointer.

Reviewed By: JoshuaGross

Differential Revision: D21922910

fbshipit-source-id: b2a56c1104574cecebaffad1bcbcbff82c1fa0cf
2020-06-07 13:17:52 -07:00
Emily Janzer 965635f073 Add JS error handling logic to bridge's RuntimeExecutor
Summary:
Call into our existing JS error handling logic from C++ using JSI in the RuntimeExecutor used by the bridge.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D21908523

fbshipit-source-id: ae41196443781b9f2673dcb7bbcb5b5aa8aa2528
2020-06-06 13:31:15 -07:00
Paige Sun 058eeb43b4 Prefetch images using a lower download priority
Reviewed By: fkgozali

Differential Revision: D21881729

fbshipit-source-id: 071a41aef2458df3d9a93a4ab0174af73e85b9fc
2020-06-05 20:55:36 -07:00
Samuel Susla 9ebd852334 Fix KERN_INVALID_ADDRESS in LayoutAnimation
Summary:
Changelog: [Internal]

# Problem

`MountingCoordinator` holds a pointer to instance of `MountingOverrideDelegate` which becomes invalid.

# Solution

Use `std::weak_ptr` instead of raw pointer so it is possible to tell whether the pointer is expired.

Reviewed By: JoshuaGross

Differential Revision: D21905351

fbshipit-source-id: c7bf9635742a6ec086a03ba83202e46e1f1f373f
2020-06-05 16:11:11 -07:00
David Vacca d676558a30 Add support for elevation prop in Fabric
Summary:
This diff adds support elevation prop in Fabric core, additionally it adds this prop as non collapsable on the view flattening algorithm

changelog: [Internal] internal change in fabric to support elevation prop

Reviewed By: JoshuaGross

Differential Revision: D21896465

fbshipit-source-id: e0854acc0b2ac30eaf3f82d615aab1cf378cc530
2020-06-05 02:36:26 -07:00
Emily Janzer 5c474ac24c Convert JSEngineInstance into a runtime factory, move runtime ownership to ReactInstance (#29009)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/29009

OSS changes: Update RCTTurboModuleManager to accept a RuntimeExecutor instead of a `jsi::Runtime`.

Reviewed By: RSNara

Differential Revision: D21270243

fbshipit-source-id: e954e62ffd54cd57f6644de853e92f71c5e52e78
2020-06-03 22:06:39 -07:00
Marc Horowitz 9baf6f2140 Handle stack overflow in JSError construction gracefully
Summary:
JSError creation can lead to further errors.  Make sure these cases
are handled and don't cause weird crashes or other issues.

This solution has a few parts:
 * include a ScopedNativeDepthTracker in checkStatus
 * If an exception object message or stack property is already a String, don't
   call JS String ctor on it
 * Verify that a jsi::Value is a String before calling getString on it.
 * Add more tests for JSError construction

Changelog: [Internal]

Reviewed By: dulinriley

Differential Revision: D21851645

fbshipit-source-id: 2d10da0e741ad4ede93cd806320f68ad512e5138
2020-06-03 18:14:18 -07:00
Ramanpreet Nara 976f51abd9 Execute sync methods on JS thread
Summary:
There are two ways to make a NativeModule method execute synchronously:
- Declare the NativeModule method to be synchronous (i.e: use `RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD`).
- Make the NativeModule synchronous (i.e: make its method queue `RCTJSThread`). This way, all its methods are synchronous.

`RCTNativeModule` executes all synchronous methods on the JS thread:
- Executing an async methods on a sync module: https://git.io/JfRPj
- Executing a sync method: https://git.io/JfRXe

However, in TurboModules we block the JS thread, execute the method on the NativeModule's method queue, and then unblock the JS thread. While this approach is thread-safe, and arguably the correct way to dispatch sync methods, it's also much slower than the alternative. Therefore, this diff migrates the legacy behaviour to the TurboModule system.

## Special Case: getConstants()
When an ObjC NativeModule requires main queue setup, and it exports constants, we execute its `constantsToExport` method on the main queue (see: [RCTModuleData gatherConstants](c8d678abcf/React/Base/RCTModuleData.mm (L392-L402))). I replicated this behaviour with TurboModules.

Changelog:
[iOS][Fixed] - Execute ObjC TurboModule async method calls on JS thread for sync modules

Reviewed By: fkgozali

Differential Revision: D21602096

fbshipit-source-id: 42d07b7ad000abeac27091dc3ec440e3836d2eae
2020-06-02 23:01:35 -07:00
Ramanpreet Nara 39d67737c0 Run getConstants method statements on main queue
Summary:
If a NativeModule requires main queue setup, its `getConstants()` method must be executed on the main thead. The legacy NativeModule infra takes care of this for us. With TurboModules, however, all synchronous methods, including `getConstants()`, execute on the JS thread. Therefore, if a TurboModule requires main queue setup, and exports constants, we must execute its `getConstants()` method body on the main queue explicitly.

**Notes:**
- The changes in this diff should be a noop when TurboModules is off, because `RCTUnsafeExecuteOnMainQueueSync` synchronously execute its block on the current thread if the current thread is the main thread.
- If a NativeModule doens't have the `requiresMainQueueSetup` method, but has the `constantsToExport` method, both NativeModules and TurboModules assume that it requires main queue setup.

## Script
```
const exec = require("../lib/exec");
const abspath = require("../lib/abspath");
const relpath = require("../lib/relpath");
const readFile = (filename) => require("fs").readFileSync(filename, "utf8");
const writeFile = (filename, content) =>
  require("fs").writeFileSync(filename, content);

function main() {
  const tmFiles = exec("cd ~/fbsource && xbgs -n 10000 -l constantsToExport")
    .split("\n")
    .filter(Boolean);

  const filesWithoutConstantsToExport = [];
  const filesWithConstantsToExportButNotGetConstants = [];
  const filesExplicitlyNotRequiringMainQueueSetup = [];

  tmFiles
    .filter((filename) => {
      if (filename.includes("microsoft-fork-of-react-native")) {
        return false;
      }

      return /\.mm?$/.test(filename);
    })
    .map(abspath)
    .forEach((filename) => {
      const code = readFile(filename);
      const relFilename = relpath(filename);

      if (!/constantsToExport\s*{/.test(code)) {
        filesWithoutConstantsToExport.push(relFilename);
        return;
      }

      if (!/getConstants\s*{/.test(code)) {
        filesWithConstantsToExportButNotGetConstants.push(relFilename);
        return;
      }

      if (/requiresMainQueueSetup\s*{/.test(code)) {
        const requiresMainQueueSetupRegex = /requiresMainQueueSetup\s*{\s*return\s+(?<requiresMainQueueSetup>YES|NO)/;
        const requiresMainQueueSetupRegexMatch = requiresMainQueueSetupRegex.exec(
          code
        );

        if (!requiresMainQueueSetupRegexMatch) {
          throw new Error(
            "Detected requiresMainQueueSetup method in file " +
              relFilename +
              " but was unable to parse the method return value"
          );
        }

        const {
          requiresMainQueueSetup,
        } = requiresMainQueueSetupRegexMatch.groups;

        if (requiresMainQueueSetup == "NO") {
          filesExplicitlyNotRequiringMainQueueSetup.push(relFilename);
          return;
        }
      }

      const getConstantsTypeRegex = () => /-\s*\((?<type>.*)\)getConstants\s*{/;
      const getConstantsTypeRegexMatch = getConstantsTypeRegex().exec(code);

      if (!getConstantsTypeRegexMatch) {
        throw new Error(
          `Failed to parse return type of getConstants method in file ${relFilename}`
        );
      }

      const getConstantsType = getConstantsTypeRegexMatch.groups.type;

      const getConstantsBody = code
        .split(getConstantsTypeRegex())[2]
        .split("\n}")[0];

      const newGetConstantsBody = `
  __block ${getConstantsType} constants;
  RCTUnsafeExecuteOnMainQueueSync(^{${getConstantsBody
    .replace(/\n/g, "\n  ")
    .replace(/_bridge/g, "self->_bridge")
    .replace(/return /g, "constants = ")}
  });

  return constants;
`;

      writeFile(
        filename,
        code
          .replace(getConstantsBody, newGetConstantsBody)
          .replace("#import", "#import <React/RCTUtils.h>\n#import")
      );
    });

  console.log("Files without constantsToExport: ");
  filesWithoutConstantsToExport.forEach((file) => console.log(file));
  console.log();

  console.log("Files with constantsToExport but no getConstants: ");
  filesWithConstantsToExportButNotGetConstants.forEach((file) =>
    console.log(file)
  );
  console.log();

  console.log("Files with requiresMainQueueSetup = NO: ");
  filesExplicitlyNotRequiringMainQueueSetup.forEach((file) =>
    console.log(file)
  );
}

if (!module.parent) {
  main();
}

```

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D21797048

fbshipit-source-id: a822a858fecdbe976e6197f8339e509dc7cd917f
2020-06-02 23:01:35 -07:00
Valentin Shergin 9d6d39de86 A corner case check in `Instance::handleMemoryPressure`
Summary:
At some early stages of Instance initialization, it does not have a `nativeToJsBridge_`. At the same time, `handleMemoryPressure` can be called at any point in time, so we should check the pointer for not being null before calling on it.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D21798522

fbshipit-source-id: 6384da88784cceb493cf9810408cbb47777d3f4b
2020-05-29 20:38:25 -07:00
David Vacca 4b596fd5b3 Extend Text to support measurement of empty Texts
Summary:
This diff extends the measurement of Text components in order to support empty strings.
This is required for parity with Paper.
I created a follow up task to analyze support of empty string as part of the Text infrastructure of Fabric in the future.

changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D21761171

fbshipit-source-id: d2aa074052b09732af5d35723f19014090fcabbf
2020-05-28 15:10:47 -07:00
Riley Dulin 9bb7e06747 Remove calls to AllocationLocationTracker for native memory
Summary:
`getStackTracesTreeNodeForAlloc` only works for memory that was tracked with `newAlloc`.
For now, that is only memory that goes through GC APIs.

Various places were calling this function on native memory which was allocated
with `malloc`, not GC memory. This led to SIGSEGV on nullptr when trying to take heap profiles
of these objects.

`newAlloc` could, in theory, work with native memory as well. But building out support for that
is outside the scope of this fix.

Changelog: [Internal]

Reviewed By: jbower-fb

Differential Revision: D21667842

fbshipit-source-id: 8403a6668e5ec607972ce6819f78fedb89da3f37
2020-05-28 12:15:48 -07:00
Joshua Gross 8b2eb3766b C++ LayoutAnimations: solve crash when "animating" virtual views
Summary:
Index adjustment doesn't work if virtual views are inserted, because those don't actually result in the view hierarchy being mutated, as such.

Add an Android-specific check to solve the crash.

I don't love adding platform-specific checks here, so I'm considering wrapping this logic in a platform-specific class, so that logic lives outside of the core of LayoutAnimations and entirely in platform code.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21727805

fbshipit-source-id: 5af2cf479beaa4d0e9d94ea16ac989c4268920f8
2020-05-26 16:12:03 -07:00
Joshua Gross ae7df2df22 LayoutAnimations: fail silently instead of redboxing if there's a misconfigured LayoutAnimation
Summary:
property and type are optional params according to Flow, so we should treat as such.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21725746

fbshipit-source-id: 3c48a8cef8fa5911c195f582556de6dad871c4f1
2020-05-26 13:15:50 -07:00
Christoph Purrer 8d6cc50d77 Change jsi::Runtime::lockWeakObject to take a mutable ref
Summary:
A key difference in WeakRefs with the Hades GC is that they are mutable,
in the sense that reading the value of a WeakRef while a GC is active might
clear the WeakRef.
For this reason, attempting to lock the WeakObject might mutate the backing
reference.

I preferred to communicate this change in behavior via the API rather than
`const_cast` it away inside the implementation.

Changelog: [Internal] Change jsi::WeakObject to be mutable in lockWeakObject

Reviewed By: mhorowitz

Differential Revision: D21485758

fbshipit-source-id: 3618928be8f8791aed56cb20673896ff5b786ded
2020-05-26 11:10:06 -07:00
Samuel Susla 1b1ebaf2bd Delete copy constructor and copy assignment operator in ShadowNode
Summary:
Changelog: [Internal]

ShadowNode shouldn't be copyable.

Reviewed By: shergin

Differential Revision: D21692756

fbshipit-source-id: e70dcf82f4d4c7609283936a42c741467f8f13ca
2020-05-23 06:57:51 -07:00
David Vacca 95546d932f Add ART components into Catalyst app Android
Summary:
Simple diff to add ART components into Catalyst app Android

changelog: [Internal] Internal changes to add support of ART for Fabric

Reviewed By: JoshuaGross

Differential Revision: D21621479

fbshipit-source-id: d957c25f447d19d8f349c69aa20f5f19237d867a
2020-05-22 01:23:38 -07:00
David Vacca 19e0b133f8 Delete unused class
Summary:
ez diff to delete unused class

changelog: [internal]

Reviewed By: fkgozali

Differential Revision: D21699666

fbshipit-source-id: d0e725c7096906e2effd16f8fa2a57683192420f
2020-05-22 01:23:38 -07:00
David Vacca 58a7ddd55d Implement equality of ARTElements and use it in ARTState
Summary:
Here I'm implementing equality methods for ARTGroup, ARTShape and ARTText and I'm using these methods to update the state only when it is necessary.
This will improve perf in rendering of ART

changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D21695127

fbshipit-source-id: b438ddea4c34bd7a0bdf26a6aac4fd62a9f78b49
2020-05-22 01:23:37 -07:00
David Vacca 55c36661d9 Rename Element -> ARTElement
Summary:
Element, Shape, Group, Text are too generic, we are renaming these classes to ARTElement, ARTBGroup, ARTShape...

changelog: [Internal] internal changes to support ART in android

Reviewed By: JoshuaGross

Differential Revision: D21681878

fbshipit-source-id: f6b35443486a3db210f61dcaf91bd32df47fbc66
2020-05-22 01:23:37 -07:00
David Vacca cfd2e7d88d Add support for Text in ART Fabric Android
Summary:
This diff adds support for Text in ART Fabric Android

changelog: [Internal] internal changes to fully support ART in Fabric

Reviewed By: JoshuaGross

Differential Revision: D21681877

fbshipit-source-id: c92e642cff56b71f8ee8f4eb9af6eea6c490f6c7
2020-05-22 01:23:36 -07:00
David Vacca b8b683dc46 Serialize ART text components and send data to Android
Summary:
This diff implements the serialization of Text components to send data from C++ to java

changelog: [Internal] internal changes to support ART in fabric

Reviewed By: JoshuaGross

Differential Revision: D21681875

fbshipit-source-id: eba31f35c95e0a2d3226ec70421832719083d7fa
2020-05-22 01:23:36 -07:00
David Vacca 888866461b Refactor types of ART Text class
Summary:
This diff refactors the types of ART Text classes, this is necessary on the next diffs of the stack

closeoncommit

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D21681876

fbshipit-source-id: ea438e89df6d860b3ff8bbdae657ca123b417a1b
2020-05-22 01:23:36 -07:00
Kevin Gozali e85118cc43 update internal code attribution
Summary:
Internal code attribution labeling update.

Changelog: [Internal]

Reviewed By: zlern2k

Differential Revision: D21696075

fbshipit-source-id: ef689a6367e1dddfffbbefb52a6aead2c91bfefe
2020-05-21 19:59:29 -07:00
Samuel Susla b31149cf90 Introduce BatchedEventQueue::enqueueUniqueEvent
Summary:
Changelog: [Internal]

`BatchedEventQueue::enqueueUniqueEvent` goes over event queue and deletes previous event of the same type and same target.

This is useful for ScrollView for example where only the latest event is relevant.
This only affects ScrollView scroll event, other events take the original code path.

Reviewed By: mdvacca

Differential Revision: D21648906

fbshipit-source-id: a80ad652058fd50ebb55e24a87229cdc1764b591
2020-05-21 11:56:22 -07:00
Samuel Susla 43d65ed66c Separate event dispatchers to ivars instead of array
Summary:
Changelog: [Internal]

Separates EventQueues from an array into 4 ivars.
EventQueues are of different type, in the future we will want to call different methods on different kind of EventQueue.

Reviewed By: shergin

Differential Revision: D21648905

fbshipit-source-id: 90ae65edb8a9276eecfea9770f554d8c56804797
2020-05-21 11:56:22 -07:00
generatedunixname89002005287564 7e343c8d3a Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D21683227

fbshipit-source-id: a29bc66af62fe99d803ac386261269b5cd16c18f
2020-05-21 10:13:22 -07:00
Samuel Susla 745ff1086a Prevent ABA problem during YogaLayoutableShadowNode cloning
Summary:
Changelog: [Internal]

# Problem
Yoga internally uses address of owner to determine whether a node should be cloned or it shouldn't.
During layout, it traverses the tree and looks whether current parent is equal to child's owner. If it isn't it means the yoga node is shared between 2+ trees and need to be cloned before mutated. Parent in yoga is stored as reference to the parent.

We can run into an issue where yoga node is shared between 2+ trees, but its current parent is equal to child's owner. This is because we reallocate new parent at address where its previous parent lived. This happens over few iterations, the old parent is first deallocated.

This is known as ABA problem.

# Solution

When we are cloning node, we loop over all children to see whether any of the is not using address of new `yogaNode_` as its owner. At this point we know this is accidental and set its owner to `0xBADC0FFEE0DDF00D`.

We chose `0xBADC0FFEE0DDF00D` because when someone is debugging this in LLDB and prints this address, it will hint them that it was artificially set and can string search for it in the codebase.

Reviewed By: shergin

Differential Revision: D21641096

fbshipit-source-id: c8b1b4487ea02b367f5831c1cdac055bce79c856
2020-05-21 07:20:20 -07:00
David Vacca 21afa62517 Serialize ART state into folly::dynamic
Summary:
This diff serializes ART state into folly::dynamic. this is necessary to send this data to Android

changelog: [Internal]

Reviewed By: shergin

Differential Revision: D21657608

fbshipit-source-id: 6c1b69af7d1dbe7de15e509f83c508a38294d89e
2020-05-21 00:11:51 -07:00
David Vacca 0305ff8ee0 Integrate ElementType Enum into state
Summary:
This diff replaces the usage of int to represent the type of elements for an Enum
changelog: [Internal] Internal change to support ART in fabric

Reviewed By: shergin

Differential Revision: D21657706

fbshipit-source-id: 7bda0210d50136477f0524695d5406e35074f09c
2020-05-21 00:11:51 -07:00
David Vacca b7ab3aaf61 Integrate State into ARTSurfaceViewShadowNode
Summary:
This diff integrates ART state into ARTSurfaceViewShadowNode

changelog: [Internal]

Reviewed By: shergin

Differential Revision: D21657611

fbshipit-source-id: 06bd4d610e2c52e0ef3bca423b93c9ad2318e8df
2020-05-21 00:11:51 -07:00
David Vacca 493d616521 Create internal State of ART based on Shadow Nodes
Summary:
This diff creates the internal state of ART based on its shadow nodes

changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D21657607

fbshipit-source-id: 0a15e90ee7465bf3a2b1001ff9d3198eb22fd708
2020-05-21 00:11:50 -07:00
David Vacca 192bea1613 Create classes to represent C++ state of ART
Summary:
This diff introduces a set of classes that are going to be used to represent the internal State of ART nodes

changeLog: [Internal][Android] Internal change to support ART in Fabric

Reviewed By: JoshuaGross, shergin

Differential Revision: D21657612

fbshipit-source-id: ea6d94b06807ff02d222dfa129a1cae384dceeaa
2020-05-21 00:11:50 -07:00
Ramanpreet Nara 4830085f40 Guard all NativeModulePerfLogger calls with a null check
Summary:
## Motivation
We got this crash T67304907, which shows a `EXC_BAD_ACCESS / KERN_INVALID_ADDRESS` when calling this line:
```
  NativeModulePerfLogger::getInstance().asyncMethodCallBatchPreprocessStart();
```
There are no arguments in that call, so I figured the only error could be when we try to invoke `getInstance()` or `asyncMethodCallBatchPreprocessStart()`.

This diff:
1. Removes the `NativeModulePerfLogger::getInstance()` bit. Now NativeModulePerfLogger is used via regular static C functions. So, there's no way that simply invoking one of the logging functions crashes the application: there's no vtable lookup.
2. Inside each logging function, when perf-logging is disabled, the global perflogger should be `nullptr`. This diff makes it so that in that case, we won't execute any code in the control group of the perf-logging experiment.

## Changes
**How do we enable NativeModule perf-logging?**
- Previously:
   - `NativeModulePerfLogger::setInstance(std::make_shared<FBReactNativeModulePerfLogger>(...))`
   - `TurboModulePerfLogger::setInstance(std::make_shared<FBReactNativeModulePerfLogger>(...))`.
- Now:
   - `BridgeNativeModulePerfLogger::enableLogging(std::make_unique<FBReactNativeModulePerfLogger>(...))`
   - `TurboModulePerfLogger::enableLogging(std::make_unique<FBReactNativeModulePerfLogger>(...))`

**How do we do NativeModule perf-logging now?**
- Previously:
   -  `NativeModulePerfLogger::getInstance().command(...args)`
   -  `TurboModulePerfLogger::getInstance().command(...args)`.
- Now:
   - `BridgeNativeModulePerfLogger::command(...args)`
   - `TurboModulePerfLogger::command(...args)`.

The benefit of this approach is that each method in `BridgeNativeModulePerfLogger` is guarded with an if check. Example:

```
void moduleCreateConstructStart(const char *moduleName, int32_t id) {
  NativeModulePerfLogger *logger = g_perfLogger.get();
  if (logger != nullptr) {
    logger->moduleCreateConstructStart(moduleName, id);
  }
}
```

Therefore, we don't actually execute any code when perf-logging is disabled.

Changelog:
[Internal]

Reviewed By: fkgozali

Differential Revision: D21669888

fbshipit-source-id: 80c73754c430ce787404b563878bad146295e01f
2020-05-20 20:19:30 -07:00
Joshua Gross c75e8ae4ff LayoutAnimations: allow Paragraph props to be interpolated
Summary:
1. Split out the prop interpolation function out of the View ComponentDescriptor, into an inline'd function that can be used elsewhere.
2. Call it from View and from Paragraph component descriptors.

This causes animations including Text to look normal on iOS.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21675804

fbshipit-source-id: c34a317749fd6c108aef072d47f3dcb14ce8aa5c
2020-05-20 19:45:51 -07:00
Joshua Gross 3f9fad1052 LayoutAnimations: Use Quaternions to interpolate rotation transforms
Summary:
Implement a real Transform interpolation. It uses quaternions/Slerp to interpolate rotations. This allows us to interpolate scale, rotation, and translation simultaneously.

See caveats in code. Because of the way transform matrices work, there isn't much (anything?) we can do about skew, and certain values will look nonsensical. This seems to be true for any variant of this algorithm.

This is a big step up from Classic RN which didn't support this in LayoutAnimations at all.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21675805

fbshipit-source-id: a33494cc02c73102ca67c1d562efc4b2a7308a4a
2020-05-20 19:45:50 -07:00
Joshua Gross eb9b2cedb8 LayoutAnimations: implement LayoutAnimationStatusDelegate for platform-specific integrations
Summary:
The LayoutAnimationStatusDelegate exists so that platforms can get a signal when animations are starting or have all completed.

This signal is meant to be used ONLY for driving animations at 60fps, or stopping that process, on the platform side.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21675807

fbshipit-source-id: e89ba524ea43c266556199c8854e8228869755e3
2020-05-20 19:45:49 -07:00
Joshua Gross 8d2c1f6e7e LayoutImplementations: implement all existing animation curves besides Keyboard
Summary:
Implement EaseIn, EaseOut, EaseInOut, and Spring with SpringDamping.

Note this does not yet implement Keyboard-type animation for iOS (coming soon), and the spring interpolator is VERY naive. We likely want to replace it with a "real" spring animation ASAP. The spring animation is identical to what Android does today, but would likely be a downgrade for iOS. I will do both in a followup.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21675810

fbshipit-source-id: ac98554ebc81f0b81fdacefd6d848e3566e424c0
2020-05-20 19:45:49 -07:00
Joshua Gross 3331962279 C++ Fabric Core LayoutAnimations
Summary:
This is the V1 implementation of Fabric Core LayoutAnimations.

The intention is to structure this in such a way that it's easy for each platform to customize the "AnimationDriver" class (to do platform-specific optimizations) without changing the KeyFrameManager at all.

In the future, this structure and architecture should allow us to iterate faster on new animation APIs.

Changelog: [Internal] Support for LayoutAnimations in Fabric

Reviewed By: mdvacca

Differential Revision: D21675808

fbshipit-source-id: b3ef44729bb8b6217f90760aec9737276c9601d1
2020-05-20 19:45:49 -07:00
Ishan Khot eb504e613e Revert D17486030: C++ Fabric Core LayoutAnimations
Differential Revision:
D17486030

Original commit changeset: 95c72cf9fc2b

fbshipit-source-id: fa7ef058f5d0dea0154c62718a8a11d9330698d9
2020-05-20 16:34:29 -07:00
Ishan Khot 6a15d7487f Revert D21587648: LayoutImplementations: implement all existing animation curves besides Keyboard
Differential Revision:
D21587648

Original commit changeset: 246ab7fd4039

fbshipit-source-id: 427e13ff821776feb4952c3438c15ea815fce5f0
2020-05-20 16:34:29 -07:00
Ishan Khot 5ae7e4fee2 Revert D21583109: LayoutAnimations: implement LayoutAnimationStatusDelegate for platform-specific integrations
Differential Revision:
D21583109

Original commit changeset: 234496841bde

fbshipit-source-id: 2f74dcce23f4eebf987e2114ad1f23cf01e11a9d
2020-05-20 16:34:29 -07:00
Ishan Khot 953c39293e Revert D21615829: LayoutAnimations: Use Quaternions to interpolate rotation transforms
Differential Revision:
D21615829

Original commit changeset: da6cb931ce85

fbshipit-source-id: 4b5bc392a35aac627b89ccccb73e10a2b1c4aaa6
2020-05-20 16:34:27 -07:00
Ishan Khot adccef7f48 Revert D21635473: LayoutAnimations: allow Paragraph props to be interpolated
Differential Revision:
D21635473

Original commit changeset: 470f43fd24a6

fbshipit-source-id: 8507b0aaead2c0ebbdd09077db99e5e44da175ab
2020-05-20 16:34:27 -07:00
Joshua Gross a799367baf LayoutAnimations: allow Paragraph props to be interpolated
Summary:
1. Split out the prop interpolation function out of the View ComponentDescriptor, into an inline'd function that can be used elsewhere.
2. Call it from View and from Paragraph component descriptors.

This causes animations including Text to look normal on iOS.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D21635473

fbshipit-source-id: 470f43fd24a6e80d8696ee2f2a09d9e693b7f280
2020-05-20 14:16:48 -07:00
Joshua Gross 3cbafcccba LayoutAnimations: Use Quaternions to interpolate rotation transforms
Summary:
Implement a real Transform interpolation. It uses quaternions/Slerp to interpolate rotations. This allows us to interpolate scale, rotation, and translation simultaneously.

See caveats in code. Because of the way transform matrices work, there isn't much (anything?) we can do about skew, and certain values will look nonsensical. This seems to be true for any variant of this algorithm.

This is a big step up from Classic RN which didn't support this in LayoutAnimations at all.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21615829

fbshipit-source-id: da6cb931ce857107d4b3d20108fb9bbecbf4f898
2020-05-20 14:16:47 -07:00
Joshua Gross f0c595b57c LayoutAnimations: implement LayoutAnimationStatusDelegate for platform-specific integrations
Summary:
The LayoutAnimationStatusDelegate exists so that platforms can get a signal when animations are starting or have all completed.

This signal is meant to be used ONLY for driving animations at 60fps, or stopping that process, on the platform side.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21583109

fbshipit-source-id: 234496841bde226fcd6623c74c1a500e5cd00d99
2020-05-20 14:16:46 -07:00
Joshua Gross 46310c1976 LayoutImplementations: implement all existing animation curves besides Keyboard
Summary:
Implement EaseIn, EaseOut, EaseInOut, and Spring with SpringDamping.

Note this does not yet implement Keyboard-type animation for iOS (coming soon), and the spring interpolator is VERY naive. We likely want to replace it with a "real" spring animation ASAP. The spring animation is identical to what Android does today, but would likely be a downgrade for iOS. I will do both in a followup.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21587648

fbshipit-source-id: 246ab7fd40397a4231bb6b18d2f29602788a1bd2
2020-05-20 14:16:46 -07:00
Joshua Gross e9d6fb2ec6 C++ Fabric Core LayoutAnimations
Summary:
This is the V1 implementation of Fabric Core LayoutAnimations.

The intention is to structure this in such a way that it's easy for each platform to customize the "AnimationDriver" class (to do platform-specific optimizations) without changing the KeyFrameManager at all.

In the future, this structure and architecture should allow us to iterate faster on new animation APIs.

TODOs:

- Use std::chrono for timekeeping

Changelog: [Internal] Support for LayoutAnimations in Fabric

Reviewed By: shergin

Differential Revision: D17486030

fbshipit-source-id: 95c72cf9fc2b4bf3fe652fbd249cf2ad113033c7
2020-05-20 14:16:45 -07:00
Jimmy Zhang 6acccae980 Add FBRotatablePhotoPlayerView to LegacyInterop whitelist
Summary: Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D21661427

fbshipit-source-id: de692015f3c6f029d2ea3f927e30d6758c0b1102
2020-05-20 09:28:08 -07:00
Samuel Susla 351a9f1047 Copy alreadyAppliedPadding when cloning SafeAreaViewShadowNode
Summary:
Changelog: [Internal]

`SafeAreaViewShadowNode.alreadyAppliedPadding` was always {0, 0, 0, 0} because value of previous shadow node was never copied over to new shadow node during clone.

Reviewed By: shergin

Differential Revision: D21617361

fbshipit-source-id: 6d6c91b19ff60271bf7c48145d85faaee0321680
2020-05-19 03:20:42 -07:00
David Vacca 7929f674cc Basic implementation of ARTText
Summary:
Basic implementation of ARTText (shadow node, props and component descriptor)
changelog: [Internal] Internal changes to support art in Fabric

Reviewed By: shergin

Differential Revision: D21621483

fbshipit-source-id: d0886dc149520af13faa1bb936dfcccab1798c37
2020-05-18 16:36:38 -07:00
David Vacca 54adda64ec Basic implementation of ARTGroupProps
Summary:
Basic implementation of ARTGroupProps (shadow node, props and component descriptor)
changelog: [Internal] Internal changes to support art in Fabric

Reviewed By: shergin

Differential Revision: D21621480

fbshipit-source-id: 367a479568b8c1a290f3e0f633cc4052a9c95b87
2020-05-18 16:36:38 -07:00
David Vacca 12fee9af62 Create basic implementation of Shape
Summary:
Create basic implementation of Shape (shadow node, props and component descriptor)
changelog: [Internal] Internal changes to support art in Fabric

Reviewed By: shergin

Differential Revision: D21621482

fbshipit-source-id: e5b9bb2812ee92bce625301b7521f0578eaca0ff
2020-05-18 16:36:37 -07:00
David Vacca a011eaf7e5 Basic implementation of ARTSurfaceView
Summary:
Basic implementation of ARTSurfaceView (shadow nodes, props and component descriptor)
changelog: [Internal]

Reviewed By: shergin

Differential Revision: D21621484

fbshipit-source-id: 5577989e966a8a97a043454bf9ae1e5602abc3b1
2020-05-18 16:36:37 -07:00
Valentin Shergin dafa975352 Fabric: Simplification of `UIManager::getRelativeLayoutMetrics`
Summary:
Using of the new API makes clear that we don't need to calculate the newest descendant node.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21480202

fbshipit-source-id: c54998573baffe4a05726e3402da027f052b049a
2020-05-18 14:08:27 -07:00
Valentin Shergin caab26e0c3 Fabric: Refinement of `LayoutableShadowNode::getRelativeLayoutMetrics`
Summary:
This diff simplifies the implementation of `LayoutableShadowNode::getRelativeLayoutMetrics`.

It fixes a small bug but the most important change is the new interface.

Now the function that does measurements accepts a node and a family instead of two nodes. It prevents misuse and misinterpretation of what the function does. The function needs two things to perform measurement:
 * an ancestor node that defines the tree is being measured and the base node of measurement;
* a family of some descendant node being measured relative to the ancestor node.

An API that accepts two nodes is misleading because it implies that the given descendant node will be measured (which is not true).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21480200

fbshipit-source-id: 9fddc361417fee47bbf66cc7ac2954eb088a3179
2020-05-18 14:08:27 -07:00
Valentin Shergin 656db7823c Fabric: Changes in LayoutableShadowNodeTest
Summary:
One small test was added.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21480201

fbshipit-source-id: fd6c050143fcdf27d345ee62e74c4368266e6ce0
2020-05-18 14:08:26 -07:00
Daniel Weaver b4f4f2d33e Update Hermes attribution labels
Summary:
Internal target attribution update.

Changelog: [Internal]

Reviewed By: janettec

Differential Revision: D21519089

fbshipit-source-id: 1aa1b57f5e1a1405db32f5cfb9973f27a13bcfdf
2020-05-18 13:36:01 -07:00
David Vacca a2e46e43fb Extends view flattening algorithm to support flattening of absolute positioned views
Summary:
This diff extends view flattening algorithm to support flattening of absolute positioned views.

changeLog:[Internal] internal change in fabric

Reviewed By: shergin

Differential Revision: D21614519

fbshipit-source-id: e33a41677a332bb58d5e5dcedbffd614a8416a45
2020-05-18 12:58:07 -07:00
Valentin Shergin b72d6768e0 Fabric: Automatic removing outstanding Surface on Scheduler destruction; gated.
Summary:
This is an addition to an automatic emergency clean-up algorithm that we have in Scheduler. In addition to committing empty surfaces, we also remove those surfaces from the registry making calling stuff on them impossible. Removing surfaces waits for all commits in flight to be finished, so it theoretically can deadlock (so we gated that).

If we won't face deadlocks in a coming couple of weeks, I would remove gating.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21610683

fbshipit-source-id: 71feeaa0ee4521a0180cdfba6e3a271e7f7d9401
2020-05-17 15:01:20 -07:00
Kevin Gozali f24b815fe6 use xplat BUCK attribution
Summary:
Internal code attribution update.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21603406

fbshipit-source-id: c3da1823e26beb0092d97e66d731618c0433a2f7
2020-05-15 21:55:52 -07:00
Ramanpreet Nara eb2a561ecb Rename <ReactCommon/NativeModulePerfLogger.h> to <reactperflogger/NativeModulePerfLogger.h>
Summary:
## Motivation
This rename will fix the following CircleCI build failures:
- [test_ios_unit_frameworks](https://circleci.com/gh/facebook/react-native/150473?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)
- [test_ios_detox_frameworks](https://circleci.com/gh/facebook/react-native/150474?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)

## Investigation
We have 4 podspec targets that map to the same header namespace (i.e: `header_dir`) `ReactCommon`:
- **New:** `React-perflogger`: Directory is `ReactCommon/preflogger`, and contains `NativeModulePerfLogger.{h,cpp}`.
- `React-runtimeexecutor`: Directory is `ReactCommon/runtimeexecutor`, and contains only `RuntimeExecutor.h`
- `React-callinvoker`: Directory is `ReactCommon/callinvoker`, and contains only `CallInvoker.h`
- `ReactCommon/turbomodule/core`: Directory is `ReactCommon/turbomodule`, and contains C++ files, as well has header files.

**The problem:**
We couldn't import headers from `React-perflogger` in `ReactCommon/turbomodule/core` files.

**The cause:**
I'm not entirely sure why, but I was able to discern the following two rules by playing around with the podspecs:
1. If your podspec target has a cpp file, it'll generate a framework when `USE_FRAMEWORKS=1`.
2. Two different frameworks cannot map to the same `module_name` or `header_dir`. (Why? No clue. But something breaks silently when this is the case).

So, this is what happened when I landed `React-perflogger` (D21443610):
1. The TurboModules code generates the `ReactCommon` framework that uses the `ReactCommon` header namespace.
2. `React-runtimeexecutor` and `React-callinvoker` also used the `ReactCommon` header namespace. However, neither generate a framework because of Rule 1.
3. When I comitted `React-perflogger`, I introduced a second framework that competed with the `ReactCommon` framework (i.e: TurboModules code) for the `ReactCommon` header namespace. Rule 2 violation.

## Thoughts on renaming
- `<perflogger/NativeModulePerfLogger.h>` is too generic, and the `perflogger` namepsace is used internally within FB.
- `<react/perflogger/NativeModulePerfLogger.h>` matches our fabric header format, but I'm pretty sure that slashes aren't allowed in `header_dir`: I tested this and it didn't work. IIRC, only alphanumeric and underscore are valid characters for `header_dir` or `module_name`. So, I opted to just use `reactperflogger`.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D21598852

fbshipit-source-id: 60da5d0f7758eaf13907a080b7d8756688f40723
2020-05-15 15:25:23 -07:00
Will Holen 452cb9a78a Add support for Debugger.runIfWaitingForDebugger
Summary:
This call is used to continue execution when the app has just been
started in a "wait for debugger" mode. This is the only case
in which it has an effect.

Notably, it should do nothing in the following cases, which a layperson
may be tempted to classify as "WaitingForDebugger":

* The app was running detached and hit a 'debugger;' statement
* The app is paused because of a breakpoint or hitting the Pause button
* The app stopped on an instrumentation breakpoint, and expects
  the debugger to collect data and potentially auto-resume.

Changelog: [Internal] Add Hermes support for Debugger.runIfWaitingForDebugger

Reviewed By: mhorowitz

Differential Revision: D21557446

fbshipit-source-id: 790cec7444ddc61908d2ef9d92e4649b535d678f
2020-05-15 12:42:38 -07:00
Keegan Mendonca 2b0208b399 Revert D21585006: Rename <ReactCommon/NativeModulePerfLogger.h> to <reactperflogger/NativeModulePerfLogger.h>
Differential Revision:
D21585006

Original commit changeset: e3339273af5d

fbshipit-source-id: cb4ff227edcc16842c7539bf71c912cd4ec478e0
2020-05-14 21:48:44 -07:00
David Vacca 84bca09f87 Fix position of TextInlineViews when nesting multiple Text components
Summary:
This diff fixes the position of TextInlineViews when nesting multiple Text.
The root is that we were not taking into consideration LayoutOffset of nested TextViews during the calculation of the nested views.

changelog: [Internal] Internal fix in Fabric

Reviewed By: JoshuaGross

Differential Revision: D21586893

fbshipit-source-id: 55e6ad0cf95222588ffe9185f5e22baea1059448
2020-05-14 21:42:37 -07:00
Ramanpreet Nara 9f3c7af400 Rename <ReactCommon/NativeModulePerfLogger.h> to <reactperflogger/NativeModulePerfLogger.h>
Summary:
## Motivation
This rename will fix the following CircleCI build failures:
- [test_ios_unit_frameworks](https://circleci.com/gh/facebook/react-native/150473?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)
- [test_ios_detox_frameworks](https://circleci.com/gh/facebook/react-native/150474?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)

## Investigation
We have 4 podspec targets that map to the same header namespace (i.e: `header_dir`) `ReactCommon`:
- **New:** `React-perflogger`: Directory is `ReactCommon/preflogger`, and contains `NativeModulePerfLogger.{h,cpp}`.
- `React-runtimeexecutor`: Directory is `ReactCommon/runtimeexecutor`, and contains only `RuntimeExecutor.h`
- `React-callinvoker`: Directory is `ReactCommon/callinvoker`, and contains only `CallInvoker.h`
- `ReactCommon/turbomodule/core`: Directory is `ReactCommon/turbomodule`, and contains C++ files, as well has header files.

**The problem:**
We couldn't import headers from `React-perflogger` in `ReactCommon/turbomodule/core` files.

**The cause:**
I'm not entirely sure why, but I was able to discern the following two rules by playing around with the podspecs:
1. If your podspec target has a cpp file, it'll generate a framework when `USE_FRAMEWORKS=1`.
2. Two different frameworks cannot map to the same `module_name` or `header_dir`. (Why? No clue. But something breaks silently when this is the case).

So, this is what happened when I landed `React-perflogger` (D21443610):
1. The TurboModules code generates the `ReactCommon` framework that uses the `ReactCommon` header namespace.
2. `React-runtimeexecutor` and `React-callinvoker` also used the `ReactCommon` header namespace. However, neither generate a framework because of Rule 1.
3. When I comitted `React-perflogger`, I introduced a second framework that competed with the `ReactCommon` framework (i.e: TurboModules code) for the `ReactCommon` header namespace. Rule 2 violation.

## Thoughts on renaming
- `<perflogger/NativeModulePerfLogger.h>` is too generic, and the `perflogger` namepsace is used internally within FB.
- `<react/perflogger/NativeModulePerfLogger.h>` matches our fabric header format, but I'm pretty sure that slashes aren't allowed in `header_dir`: I tested this and it didn't work. IIRC, only alphanumeric and underscore are valid characters for `header_dir` or `module_name`. So, I opted to just use `reactperflogger`.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D21585006

fbshipit-source-id: e3339273af5dfd65a1454d87213d1221de6a4651
2020-05-14 20:54:57 -07:00
Joshua Gross eb12cb5bbc Support interpolating `transform` View property
Summary:
For Fabric LayoutAnimations, we need to support interpolating the Transform property (which really ends up just being interpolation of ScaleX, ScaleY, or ScaleXY transforms - not arbitrary matrices).

To support that, we need to be able to convert Transform back to folly::dynamic, and on the Java side we need to support accepting arbitrary matrices instead of transform maps of properties.

Changelog: [Internal] Fabric-only changes

Reviewed By: sammy-SC

Differential Revision: D21564590

fbshipit-source-id: b137f659b27e4b8fae83921a28ccf46035e18651
2020-05-14 12:38:00 -07:00
Samuel Susla a7bbc858c5 Use vector.empty() to check for emptyness
Summary:
Changelog: [Internal]

Using `empty()` vs `size() == 0` or `size() > 0`.
It is a more semantic way to check whether container is empty or not.

Reviewed By: JoshuaGross

Differential Revision: D21573183

fbshipit-source-id: b83283f687432a037941852114717a0f014e28db
2020-05-14 11:58:58 -07:00
Samuel Susla 5c60247981 Use east const in ScrollViewProps
Summary:
Changelog: [Internal]

For consistency, switching west const to east const.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D21574239

fbshipit-source-id: eb3459c63f731f51b24f40f9f80b574661ffd935
2020-05-14 11:52:05 -07:00
Samuel Susla 060250dcb0 Add support for ScrollView.contentOffset
Summary:
Changelog: [Internal]

Fabric's scrollview didn't have `contentOffset` implemented.

Reviewed By: JoshuaGross

Differential Revision: D21573179

fbshipit-source-id: 258c1cfa3398336f74d7ab033d90edcec7095292
2020-05-14 11:52:05 -07:00
Sidharth Guglani 5c0a3a61d5 throw std::logic_error instead of aborting the process and convert to java exception
Summary: Changelog: [Internal][Yoga] throw std::logic_error instead of aborting the process and convert to java exception for jni layer

Reviewed By: pasqualeanatriello

Differential Revision: D21301235

fbshipit-source-id: 148b27920e62990a271e1d0df8c85a2cc42f4fd4
2020-05-14 06:34:25 -07:00
Samuel Susla 16d15209e5 Remove branching for optimized differ QE
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D21556312

fbshipit-source-id: 0d6d275de2d691cb42e5e70e5bf19bcc983cae12
2020-05-14 05:30:48 -07:00
Ramanpreet Nara 0b8a82a6ee Instrument sync and async method calls (#28893)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/28893

`JSIExecutor::callSerializableNativeHook` converts the arguments from `JSI::Value` to `folly::dynamic`. Then, `RCTNativeModule` converts the arguments from `folly::dynamic` to ObjC data structures in its `static invokeInner` function.

Therefore, I decided to start the sync markers inside `JSIExecutor::callSerializableNativeHook`, which required me to expose these two methode `ModuleRegistry::getModuleName` and `ModuleRegistry::getModuleSyncMethodName`. This shouldn't modify performance because we eagerly generate a NativeModule's methods when it's first required. So, at worst, this is doing a cache lookup.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D21443610

fbshipit-source-id: 67cf563b0b06153e56e63ba7e186eea31eafc853
2020-05-13 20:28:18 -07:00
Ramanpreet Nara bf0e516086 Instrument async method call batch preprocessing
Summary:
NativeModule async method calls are queued up on the JS side, and flushed to C++ on every Native -> JS call. Before we execute the batch of async NativeModule method calls, we convert it (a JS object) from a `jsi::Value` to a `folly::dynamic` object in `JSIExecutor::callNativeModules`. Then, in `JsToNativeBridge::callNativeModules`, we convert this `folly::dynamic` object into an `std::vector<MethodCall>`, before finally looping over these `MethodCall`s and invoking each NativeModule async method call.

The markers I'm adding in this diff measure this `jsi::Value -> folly::dynamic -> std::vector<MethodCall>` pre-processing.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D21435455

fbshipit-source-id: 4c5a9e2b73c1a2a49d7a8f224a0d30afe3a0c79c
2020-05-13 20:28:17 -07:00
Ramanpreet Nara 9f310a2b15 Instrument JS requires
Summary:
This diff instruments two markers:
- JSRequireBeginning: From the start of the JS require to when we start creating the platform NativeModule
- JSRequireEnding: From the end of platform NativeModule create to the end of the JS require

In order to accomplish this, I had modify `ModuleRegistry::ModuleRegistry()` to accept a `std::shared_ptr<NativeModulePerfLogger>`. I also had to implement the public method `ModuleRegistry::getNativeModulePerfLogger()` so that `JSINativeModules` could start logging the JS require beginning and ending.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D21418803

fbshipit-source-id: 53828817ae41f23f3f04a95b1d3ac0012735da48
2020-05-13 20:28:17 -07:00
Ramanpreet Nara c98f36c676 Switch TurboModules over to NativeModulePerfLogger
Reviewed By: PeteTheHeat

Differential Revision: D21363243

fbshipit-source-id: 9836b6651107c924ab9ab8e1ed73b156aed58d9f
2020-05-13 20:28:16 -07:00
Ramanpreet Nara 0486640571 Introduce NativeModulePerfLogger
Summary:
## Description
This diff introduces `NativeModulePerfLogger`, its BUCK, Cocoapod, android-ndk targets. This diff also wires up those targets into the React Native bridge and TurboModules targets, so that we get signal on if the code compiles.

This diff also introduces `TurboModulePerfLogger`, which is a namespace that holds the `NativeModulePerfLogger` that'll do perf-logging for TurboModules.

## How will perflogging work on iOS?
1. Each application will, during React Native initialization, create a NativeModule perf logger.
2. If TurboModules are enabled, we'll call `TurboModulePerfLogger::setInstance(perfLogger)`. If TurboModules are disabled, we'll call `NativeModulePerfLogger::setInstance(perfLogger)`.
3. TurboModules, when they're created and used, will log events via `TurboModulePerfLogger::getInstance()`. NativeModules (i.e: bridge modules), when they're created and used, will log events via the `NativeModulePerfLogger::getInstance()`.

> **Note:** The NativeModule system will log events for non-TurboModules as well. Maybe we should log events for only NativeModules that conform to the `TurboModule` interface, when TurboModules are disabled. This'll ensure a fair comparison between the two systems.

## How will perflogging work on Android?
Please see the subsequent diff.

allow-large-files

Changelog:
[Both][Added] - Introduce `NativeModulePerfLogger`

Reviewed By: PeteTheHeat

Differential Revision: D21318053

fbshipit-source-id: 6ddf5b5a80bdc4076d2dd6588067e2b0ec8c2c6b
2020-05-13 20:28:15 -07:00
Valentin Shergin 0aac4c39d9 Fabric: Unifying interface of stub TextLayoutManager with actual ones
Summary:
The interface of css/TextLayoutManager now matches acual platform-specific implementations, so now CXX tests compiles and usable.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21518656

fbshipit-source-id: cece3bea14c70410eea22abafb424f7a2cb201c0
2020-05-13 16:42:18 -07:00
Joshua Gross d269844cc1 LayoutAnimations: have each Props struct do its own interpolation
Summary:
Each ComponentDescriptor becomes capable of doing its own interpolation over props for animation purposes.

This new custom interpolator is called by default by the ConcreteComponentDescriptor, but `ComponentDescriptor::interpolateProps` is a virtual function and each ComponentDescriptor can provide custom interpolation if necessary.

For now, only View does any actual interpolation, to support LayoutAnimations.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20965310

fbshipit-source-id: e1c1588107848e94c155efecb0da1cc1619ae544
2020-05-13 15:40:34 -07:00
Martin Sherburn 77ef8f881f When debugger is attached continue to receive console messages
Summary:
I noticed an issue when the hermes debugger was attached. Console messages would no longer appear in the terminal. This is because the hermes inspector overrides the console object with its own to intercept messages and send them to the debug client.
With this change I made it so that messages are sent to the original console as well instead of completely replacing it.

Changelog:
[General][Fixed] - When Hermes debugger is enabled continue to send log messages to the console

Reviewed By: mhorowitz

Differential Revision: D21509895

fbshipit-source-id: 6d91c4b82682e404679533be14b3e5f12e687e79
2020-05-13 07:20:20 -07:00
David Vacca e3f4a7ba09 Fix precision of TextInlineViews in Android
Summary:
TextInlineViews in Android was incorrectly converting values to from float to int, this produced to loose precision and to render incomplete texts in some components.
This diff changed the types from int to float, avoiding loose precision.

The impact of this bug is not that high because in the conversion to int we were using Math.ceil(), which was already rounding the result to the next pixel.

changeLog: [Android][Fixed] Fix precision of TextInlineViews in Fabric Android

Reviewed By: JoshuaGross, shergin

Differential Revision: D21541159

fbshipit-source-id: 4741ab96964c35af1c1b7d3e821e505ecef2efce
2020-05-13 00:42:36 -07:00
Vitaly Potlov 649e1b787f Fixing typo in comment (#28882)
Summary:
I was reading the code and noticed the typo.

## Changelog

Doesn't affect the code.

[General] [Fixed] - Message
Pull Request resolved: https://github.com/facebook/react-native/pull/28882

Differential Revision: D21529436

Pulled By: shergin

fbshipit-source-id: 82929a6f1fe7b5510ee17fff547aae9d5125891c
2020-05-12 13:22:58 -07:00
Valentin Shergin f78bd0e72a Fabric: Fixed incorrect memory management in Scheduler
Summary:
The previous implementation was incorrect causing a memory leak. In the new approach, we use a shared pointer to optional to be able to construct that ahead of time and then fill with actual value.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21516794

fbshipit-source-id: ddcbf8a1ad2b1f629ae4ff2842edeb7bb2a275a6
2020-05-12 11:28:34 -07:00
Samuel Susla 91468b76c6 Download image of size based on image view size, not image size
Summary:
Changelog: [internal]

Fabric asks server for images of their real size and scale, not images of size that they would take up on the screen once rendered. Also scale of the screen is incorrect. This causes images to be twice as large as they have to be.

Look at the size of the first image size here in Paper, it is `{310.5, 207}`.
{F235394066}

If you compare it with Fabric, there it is `{800, 381}`
{F235394115}

It isn't just the size, but scale of request image as well. Fabric always asks for image of scale 1, unlike Paper which takes screen scale into account.

Reviewed By: shergin

Differential Revision: D21255794

fbshipit-source-id: 9db3ccafec1c09cedc5db5ac0a435a28a4c30c85
2020-05-12 11:10:21 -07:00
Samuel Susla 43de8ea2ba Fix opacity not being animated on Text component
Reviewed By: shergin

Differential Revision: D21523725

fbshipit-source-id: 80be40fd1314b7e1cbaa827ca52f917ba5bc916e
2020-05-12 10:32:22 -07:00
Samuel Susla 8f90ce26a5 Break retain cycle in RCTLegacyViewManagerInteropCoordinator
Summary: Breaks retain cycle by having weak reference to bridge.

Reviewed By: shergin

Differential Revision: D21501419

fbshipit-source-id: 7526ceefceb59e296c6f4944cac5069cb62b33a5
2020-05-12 03:48:30 -07:00
Kevin Gozali 3c9013402e xplat code ownership
Summary:
For internal code attribution.

Changelog: [Internal]

Reviewed By: zlern2k

Differential Revision: D21496969

fbshipit-source-id: 9fa27a758df19c16fd2087ce964132eaa70dc91f
2020-05-11 10:24:35 -07:00
Samuel Susla cde82b55fc Add comments to a test case in LayoutableShadowNodeTest
Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D21500371

fbshipit-source-id: daec07f82f43aae9cdc31f67599e30873ca108b9
2020-05-11 09:27:40 -07:00
Valentin Shergin 51740f8bb3 Fabric: Support for sync `RuntimeExecutor` in `executeSynchronouslyOnSameThread_CAN_DEADLOCK`
Summary:
The approach is quite simple: we check the thread id, and if it matches the caller thread id, we unlock mutexes which lead to the normal uninterrupted execution flow.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: RSNara

Differential Revision: D21328313

fbshipit-source-id: 4290b8a0357dbad3563d7da9464c03ecce5ded7c
2020-05-11 09:01:34 -07:00
Manvir Singh d54113d8c4 implemented showSoftInputOnFocus for iOS (#28834)
Summary:
`showSoftInputOnFocus` was added in https://github.com/facebook/react-native/issues/25028, but it was only added for Android. There was a lot of discussion on the original issue being addressed (https://github.com/facebook/react-native/issues/14045), that there is a need for this on iOS as well. The issue with iOS was brought up again on https://github.com/facebook/react-native/issues/27243.

On a related note, when searching this repo's issues for `showSoftInputOnFocus`, it appears that there are several closed issues that claim that the Android implementation doesn't work (https://github.com/facebook/react-native/issues/25685, https://github.com/facebook/react-native/issues/25687, https://github.com/facebook/react-native/issues/26643). So perhaps the Android implementation needs to be looked at as well (I myself have not gotten around to confirming whether it works or not)

## Changelog

[iOS] [Added] - Add showSoftInputOnFocus to TextInput
Pull Request resolved: https://github.com/facebook/react-native/pull/28834

Test Plan:
You'd use this just like you would in the Android implementation:
```jsx
<TextInput showSoftInputOnFocus={false} />
```

## GIFs
### Before change
![May-04-2020 20-52-49](https://user-images.githubusercontent.com/4932784/81034028-9d89cf80-8e4a-11ea-906c-64f62504f80c.gif)

### After change
![May-04-2020 20-54-27](https://user-images.githubusercontent.com/4932784/81034035-a11d5680-8e4a-11ea-918e-119a1c9e2a19.gif)

Differential Revision: D21418763

Pulled By: shergin

fbshipit-source-id: 561e72fc2cf16b30446132f6b96b8aa2b4a92daf
2020-05-11 09:01:33 -07:00
Valentin Shergin f05fff6a68 Fabric: Using `PlatformRunLoopObserver` instead of `MainRunLoopEventBeat` and `RuntimeEventBeat` on iOS (gated)
Summary:
This diff implements iOS-specific `PlatformRunLoopObserver` (and `MainRunLoopObserver`) that then being glued together with `SynchronousEventBeat` replaces `MainRunLoopEventBeat`, and then same thing glued with `AsynchronousEventBeat` replaces `RuntimeEventBeat`.

So, instead of two platform-specific classes we had on iOS (for that needs), now we have only one (that can be reused for a more broad variety of applications).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21341998

fbshipit-source-id: fafde4e678770f7fcf9c1ff87acc02812a37e708
2020-05-11 09:01:33 -07:00
Valentin Shergin ebdd59aff8 Fabric: Initializing EventBeat::OwnerBox with non-null value ahead of time
Summary:
We use `EventBeat::OwnerBox` in the `EventBeat` infra to represent weak ownership of classes that contain that, so those classes can ensure own life-time at some critical points.
Before this diff, we stored a pointer to EventDispatcher right after we create it. However, some components that we build require to have a valid pointer from the beginning (even before the EventDispatcher is created). To satisfy this requirement, we create a dummy pointer first and use it as an owner, then we merge (share control block) the pointer to an EventDispatcher into that. It works because the owner pointer never gets dereferenced (it's `void *`), so it does not matter which object it represents while it represents correct ownership.

In the future, this approach will allow us to remove the concept of `OwnerBox` completely and use just `std::weak_ptr<void>` instead.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21441109

fbshipit-source-id: 7457c77bd31cd577f38a26e28e27eb7e33b6ad24
2020-05-11 09:01:32 -07:00
Valentin Shergin b65b00ab6b Fabric: Fixed incorrect name of the prop value `justifyContent=space-between`
Summary:
The name of the value was incorrect.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21496651

fbshipit-source-id: 464c98436bb8d5f2b6275b7eab1c32d187e2b23c
2020-05-10 18:27:41 -07:00
Valentin Shergin 497191601b Fabric: Checks for corner cases in UIManager::getNewestCloneOfShadowNode
Summary:
We should check for corner cases.
Another interesting detail is behavior. Now (and previously) we return nullptr if case we could not find the most recent node. But maybe we should return the given node instead?

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21480874

fbshipit-source-id: bb943c4508ec025316a3665d652e4b5e06dd795c
2020-05-10 13:28:46 -07:00
Valentin Shergin 0d2fcb1ed7 Fabric: Making `UIManager::getNewestCloneOfShadowNode` even more safer
Summary:
We cannot use a raw pointer here because the tree might progress right after we call to `shadowTree.tryCommit` and we will get a dangling pointer as a result.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21464832

fbshipit-source-id: 3998b39d29db672da54d4adcb6be55cd3d44d862
2020-05-10 13:28:46 -07:00
Valentin Shergin 604402678b Fabric: Making `UIManager::getRelativeLayoutMetrics` safer
Summary:
In this method we have to maintain a retaining pointer to the node in order to access it as a raw pointer.
See also a comment in the codee.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D21464834

fbshipit-source-id: 69f6894009509e5feca291fab12c019208933816
2020-05-10 13:28:46 -07:00
Valentin Shergin af1fe62ae0 Fabric: Changes in UIManager::getNewestCloneOfShadowNode to make it safer
Summary:
There is no need to use a raw pointer to a shared pointer as a return value of `UIManager::getNewestCloneOfShadowNode`. If it would be a very hot path, we could you a raw pointer to the node instead but it's not a hot path.
Prooving that using a raw pointer here is safe is quite complex (and I don't know if it's safe or not). So, I changed it to just a shared pointer.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D21464833

fbshipit-source-id: 813a3c9fca0147afb322db6855a0ce8fd2d47909
2020-05-10 13:28:45 -07:00
Emily Janzer a4a47b9a1e Expose RuntimeExecutor on CatalystInstance (#28851)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/28851

This diff creates a RuntimeExecutor that uses the bridge and exposes it on CatalystInstanceImpl.

Changelog: [Internal]

Reviewed By: mdvacca, RSNara

Differential Revision: D21051949

fbshipit-source-id: b3977fc14fa19089f33e297d29cedba0d067526d
2020-05-08 16:13:42 -07:00
Kevin Gozali 164d47f30a label react-native-github targets
Summary:
For internal code attribution.

Changelog: [Internal]

Reviewed By: zlern2k

Differential Revision: D21468924

fbshipit-source-id: 59cd2a52e0ae46bedbf54816820a5f40b684da8b
2020-05-08 00:36:17 -07:00
Will Holen bf837d6373 Add support for Debugger.setInstrumentationBreakpoint
Summary:
This diff adds support for the "beforeScriptWithSourceMapExecution" instrumentation
breakpoint via "Debugger.setInstrumentationBreakpoint".

CDP describes it as a breakpoint, but we just set a flag in the inspector. A
fake breakpoint ID is synthesized for optional removal later.

Changelog: [Internal] Add Debugger.setInstrumentationBreakpoint to Hermes Inspector

Reviewed By: mhorowitz

Differential Revision: D21418218

fbshipit-source-id: 90fa49c0954980993815322d3a7effee416ed5db
2020-05-07 21:05:30 -07:00
Will Holen 938aa86013 Remove Hermes.setPauseOnLoad message
Summary:
This removes the Hermes.setPauseOnLoad. It will be replaced by the more standard
Debugger.setInstrumentationBreakpoint's "beforeScriptExecution" event.

ChangeLog: [Internal] Remove Hermes.setPauseOnLoad message (to be replaced)

Reviewed By: mhorowitz

Differential Revision: D21418219

fbshipit-source-id: 93c53801c23487f9336b322c2bd737663ec21b97
2020-05-07 21:05:30 -07:00
David Vacca 561a97f699 Extend Text measurement to support includeFontPadding prop
Summary:
This diff exposes the Text.includeFontPadding prop to java, then it uses the prop to calculate the height of Text components correctly.

changelog: [Internal][Fabric] Internal change in Fabric to support Text.includeFontPadding prop in fabric

Reviewed By: shergin

Differential Revision: D21446737

fbshipit-source-id: efe73fb6b0d402c3275ac8c012fa8fa06b743bdd
2020-05-07 17:11:48 -07:00
David Vacca 4e59508a8e Extend ParagraphAttribute to store the includeFontPadding prop
Summary:
This diff extends the ParagraphAttribute class to store the value of the includeFontPadding prop.
Note that this is an Android only prop, I'm not creating android blocks to improve "cleanliness" of the code.

changelog: [Internal][Fabric] Internal change in Fabric to support Text.includeFontPadding prop in fabric

Reviewed By: shergin

Differential Revision: D21446738

fbshipit-source-id: 0543e86aa18ce10f7a56bbaafe111cce0179ea86
2020-05-07 17:11:48 -07:00
Pieter De Baets e566c7ec7b Add virtual destructor to JSError
Summary:
We consume Hermes through multiple .so's, which means we have multiple (weak) typeinfo definitions of facebook::jsi::JSError. Previously we were using gnustl, which would strcmp typeinfo to decide whether a certain exception handler applies, which meant this didn't cause any major issues. However since this is deprecated, we recently switched to libc++, which does not have this by behaviour (or it does, but behind a flag I'm not sure how to enable). This causes any JS exceptions to fall through from our exception handlers and fatal the app.

This problem is actually documented in the common Android NDK problems page: https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md#rtti_exceptions-not-working-across-library-boundaries

The suggested solution is to ensure that any exception types have a key function defined (a non-pure, out-of-line virtual function). The simplest one to add is a virtual destructor. This makes the object file that holds the implementation of the destructor export a non-weak typeinfo definition which will at load time override the other weak versions.

I'm not sure why we're the first to hit this. RN's JSIExecutor doesn't explicitly reference JSError which probably helps (https://github.com/facebook/react-native/blob/master/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp#L256-L258) and they also don't use unguarded callbacks like we do.

Changelog: [Internal]

Reviewed By: mhorowitz

Differential Revision: D21426524

fbshipit-source-id: 474284ada1ca2810045dc4402c420879447f9308
2020-05-07 04:15:14 -07:00
Nikita Lutsenko f4815fbad3 third-party | Move glog from xplat/third-party to third-party and create temporary redirect.
Summary:
Move and create an empty rule that redirects as well, to handle //arvr rules
Need to do this way, since ovrsource sync rules are in different repo.

allow_many_files
allow-large-files

Steps:
- [X] Move glog from xplat/third-party to /third-party
- [ ] Update references in ovrsource to translate to //third-party instead of //xplat/third-party
- [ ] Get rid of temporary rule
- [ ] Update fbsource/third-party/glog to 0.3.5 (what we have in ovrsource)

Changelog: [Internal] Update reference for glog from xplat/third-party to /third-party.

Reviewed By: yfeldblum

Differential Revision: D21363584

fbshipit-source-id: c1ffe2dd615077170b03d98dcfb77121537793c9
2020-05-06 19:04:33 -07:00
Valentin Shergin 025b6a74c8 Fabric: Cross-platform implementation of `SynchronousEventBeat` and `AsynchronousEventBeat`
Summary:
`SynchronousEventBeat` and `AsynchronousEventBeat` are a cross-platform re-implementation of run loop related parts of `MainRunLoopEventBeat` and `RuntimeEventBeat` (iOS specific classes for now). In the future, they will replace iOS- and Android-specifc event beat classes.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21341996

fbshipit-source-id: 8eda9a5df537cd666b7728e32212a8bb5ddb3ab7
2020-05-06 18:28:52 -07:00
Valentin Shergin d76e03f85a Fabric: Introducing `RunLoopObserver`
Summary:
`RunLoopObserver` is one of the core interfaces that bridge intrinsically platform-specific functionality to cross-platform React Native core. `RunLoopObserver` allows subscribing for notifications about changes in a run loop life cycle. Primarily it supposed to be used for observing UI (aka main) and JavaScript execution thread/run-loop.
Having a `RunLoopObserver` implemented in a platform-specific manner allows building these components in a cross-platform manner:
* Sync and async UI event delivery pipeline;
* Timing for some animation engine;
* Timers (probably additional features are required).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21341997

fbshipit-source-id: 7ef61fb51f550dd0f2e89c64af657e0f0de029aa
2020-05-06 18:28:52 -07:00
Valentin Shergin fa5b4c9e0c Fabric: Backward-compatible behaviour of `measureInWindow` and `measure`
Summary:
Before this change, in case of incorrect measurements, Fabric's implementation of `measure` and `measureInWindow` incorrectly returned negative height and width. Now it returns zeros (as classic React Native does).

Fabric:
This does not fix `measureLayout` called for virtual nodes. This is not so trivially to fix and it will be done separately.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, yungsters, mdvacca

Differential Revision: D21433239

fbshipit-source-id: fbaf5ee35c690506822c634daac4426542c2cdcf
2020-05-06 15:16:04 -07:00
Will Holen 4459c08219 Make column match fuzzy
Summary:
We are currently very strict about breakpoint location matching. This
diff allows some fuzz in the column, but not in the line.

Changelog: [Internal] Setting Hermes breakpoints no longer requires exact column match

Reviewed By: avp

Differential Revision: D21343198

fbshipit-source-id: a59786a9d63f9fe1ed576835ed660ba3343affe1
2020-05-05 12:04:10 -07:00
Joshua Gross bb5d04366a Differ: fix TinyMap to prevent possible crashes in `find()` and `begin()`, and prevent erased elements from being iterated over
Summary:
The core issue solved in D21389371 was that erased elements of a TinyMap were being iterated over, because TinyMap has somewhat-complicated logic around cleaning out the underlying vector. In some very marginal cases, vectors were not being cleaned and an iterator pointing at erased elements was being returned.

The diff prevents some possible crashes in `begin()` and `find()` while making it much less likely to iterate over erased elements.

We also add a unit test to catch the case fixed in D21389371, in particular.

We also are keeping the code added in D21389371 (for now) since it's a cheap check, and will be a safeguard until we have rigorous testing around TinyMap. To be clear that logic should noop currently, but will prevent crashes in case guarantees around TinyMap change in the future.

Currently there is only one line of code that actually uses the TinyMap iterator, so this should be safe.

Reviewed By: shergin

Differential Revision: D21392762

fbshipit-source-id: 36dc998958c230fad01af93338974f8889cbcf55
2020-05-04 21:28:35 -07:00