Commit Graph

2442 Commits

Author SHA1 Message Date
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 (https://github.com/facebook/react-native/commit/0060b5de559cd9c785a2a2a6c66f58088fea4dd2) and fixes the reason why it was reverted. Reverted in D22532594 (https://github.com/facebook/react-native/commit/c0e7e1bd9cf050b4a77a20212603d3468826979c).

For reason why it was introduced in the first place, please refer to D22456266 (https://github.com/facebook/react-native/commit/0060b5de559cd9c785a2a2a6c66f58088fea4dd2).

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 (https://github.com/facebook/react-native/commit/e206e34175c091a753c0e733abeda41b662241d4) 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 (https://github.com/facebook/react-native/commit/e206e34175c091a753c0e733abeda41b662241d4) 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: https://github.com/facebook/react-native/blob/e23e9328aa164d0a70fe4f16042c982e7801d924/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: https://github.com/facebook/react-native/blob/e23e9328aa164d0a70fe4f16042c982e7801d924/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: https://github.com/facebook/react-native/blob/e23e9328aa164d0a70fe4f16042c982e7801d924/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 (https://github.com/facebook/react-native/commit/5b2ea6ec6ab8cecad35d6309ceec3853aa37b0a3).
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