Commit Graph

372 Commits

Author SHA1 Message Date
Samuel Susla 34d189ae09 Introducing Leak Checker
Summary:
Changelog: [internal]

Introducing LeakChecker. A tool that checks if all native components have been cleaned up when surface is stopped.

**Known shortcomings**:
- LeakChecker is only enabled in debug builds and the existence of leaks is logged to console.
- For now, Leak Checker looks at N-1 screen. This is intentional as there is a known limitation of React that doesn't free up all shadow nodes when surface is stopped. Because of this, the use of LeakChecker is not intuitive and I'll work with React team to try to work around this.
- It doesn't help locating the leak, it only informs that leak is present. I'll be looking into ways to help locate the leak.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D26727461

fbshipit-source-id: 8350190b99f24642f8e15a3c2e1d79cfaa810d3d
2021-03-17 02:57:37 -07:00
Joshua Gross 9c1926051e Pass blockNativeResponder param to setIsJSResponder
Summary:
The non-Fabric API has a `blockNativeResponder` param in setJSResponder. Make sure to pass that along in Fabric.

On Android this allows us to respect the flag and do the same thing non-Fabric was doing if `blockNativeResponder` is false. It's not clear yet what the impact is on iOS.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D27058806

fbshipit-source-id: aa5074fa46191d78f5292a93d9040ab4bb58ca66
2021-03-15 18:37:36 -07:00
Joshua Gross 7ac5d48341 Generalize "isVirtualView" logic to make debug asserts consistent with platform
Summary:
On Android we have the notion of "virtual views", which are defined consistently but the logic is scattered and duplicated throughout the codebase.

The logic exists to mark nodes that exist in the ShadowTree, but not the View tree. We want to CREATE, UPDATE, and DELETE them on the platform, but not INSERT or REMOVE
them. They basically exist as EventEmitter objects.

The only issue with this is (1) duplicated code, which opened the possibility for inconsistent definition (2) StubViewTree did not account for virtualized views, which caused
assert crashes in debug mode for certain LayoutAnimations on Android.

By moving the definition to ShadowViewMutation and accounting for it in StubViewTree, asserts are correct and consistent on all platforms.

This was not caught until recently, because, until recently, no asserts actually ran on Android.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27001199

fbshipit-source-id: eb29085317037ba8a286d7813bdd57095ad4746f
2021-03-15 13:50:56 -07:00
Samuel Susla 23cf99544c Introduce RCTInstallNativeComponentRegistryBinding
Summary:
Changelog: [internal]

Creates new function `RCTInstallNativeComponentRegistryBinding` which can be called during JS setup to register JS function `__nativeComponentRegistry__hasComponent`.

Note: This diff doesn't call `RCTInstallNativeComponentRegistryBinding`.

Reviewed By: shergin

Differential Revision: D26946176

fbshipit-source-id: 0625b8dd6090bc9e08baa38ba60b9cbe48268184
2021-03-15 03:39:13 -07:00
Lulu Wu ea1f9531f0 Add additional checks to prevent throwing native java errors in UIManagerBinding.cpp
Summary:
Right now there are places in UIManagerBinding.cpp where native java exceptions will be thrown if calling JSI functions results in errors, such as:

```Trying to report error getPropertyAsObject: property '__fbBatchedBridge' is undefined, expected an Object
Error: getPropertyAsObject: property '__fbBatchedBridge' is undefined, expected an Object
```

https://www.internalfb.com/intern/logview/details/facebook_android_javascripterrors/358181062b47b9561e60427bbb3816a9

In this diff I added LOG(ERROR) and checks because:
1, Throwing errors neither prevents the JSI errors nor handles them properly, checks prevent JSI errors from happening.
2, Errors are aggregated in Logview with other JSI errors as "Error: android_crash:com.facebook.react.devsupport.JSException:facebook::jni::throwNewJavaException" which keeps the SLA task open forever, checks can prevent JSI errors so they won't lead to exceptions, and  LOG(ERROR) will make sure we have enough info for debugging.

Changelog:
[General][Changed] -  Add checks and logs to for better error handling

Reviewed By: JoshuaGross

Differential Revision: D26885562

fbshipit-source-id: c0c1c057342e9efc0ff708188703f4332036e7a9
2021-03-15 03:09:30 -07:00
Joshua Gross b88ec8b144 Format StubViewTree logs to be closer to other logs
Summary:
Debug logs should wrap React Tags in square brackets.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27001202

fbshipit-source-id: 32fca9d0e1467a515ca3d9d1a3e24a35c23120db
2021-03-12 09:33:24 -08:00
Valentin Shergin fa64427236 Fabric: Fixed deadlock in Surface Handler
Summary:
As part of stoping a Surface, we have to commit an empty shadow node tree. And to avoid a deadlock we have to do it not under a `linkMutex_`. To do so, we need to move the part that commits an empty tree from UIManager to SurfaceHandler. And this diff does exactly this.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D27010535

fbshipit-source-id: 60cc79b1c81d7340b550e78653737d2cc5bec24d
2021-03-12 08:57:57 -08:00
Joshua Gross 3b0800a49a EventTarget (native)/InstanceHandle (JS) is not optional, assert that it's non-null
Summary:
When EventTarget is created in createNode, it's currently treated as optional in native, but it's not optional in JS. We should assert that it's non-null to make the contract more clear.

For now, we keep it as an assert so we catch issues in debug/dev, but it won't impact prod.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D27002506

fbshipit-source-id: c541dc02d3de22df19292deaef1a3b68fe57ba1f
2021-03-11 20:49:53 -08:00
Valentin Shergin e19401843e Fabric: Incorporating text measure time into SurfaceTelemetry
Summary:
Now cumulative time spent on text measuring is available as as part of SurfaceTelemetry.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D26827445

fbshipit-source-id: 8ad3178557ea71170557fcf19b6f62f7072d6da2
2021-03-11 14:34:22 -08:00
Valentin Shergin 60f15d6b5d Tracking time spent on measuring text in TransactionTelemetry
Summary:
Now we not only measure how many times we measured text but also measure how much time it takes. This way we can see which portion of the layout process is spent by layout itself (and measuring embedded components).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D26827447

fbshipit-source-id: e0b09fcacc86aed50dd94b48458215adbb0a60ef
2021-03-11 14:34:22 -08:00
Samuel Susla fdb2bb76ec Refactor componentNameByReactViewName into separate file
Summary:
Changelog: [internal]

Extract componentNameByReactViewName to separate file so it can be used elsewhere.

Reviewed By: shergin, mdvacca

Differential Revision: D26946159

fbshipit-source-id: cf69df1f80f1c1938fc667f4666a5d3fec5a9658
2021-03-11 11:53:14 -08:00
Andrew Coates 81c895fb3f Fix various C++ warnings (#31002)
Summary:
Fix warnings about implicit type truncation.

## Changelog

[Internal] [Fixed] - Fix various C++ warnings

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

Test Plan:
Almost all the changes here are simply making explicit conversions which are already occurring.  With the exception of a couple of constants being changed from doubles to floats.

With these changes I am able to remove a bunch of warning suppressions in react-native-windows.

Reviewed By: shergin

Differential Revision: D26900502

Pulled By: rozele

fbshipit-source-id: d5e415282815c2212a840a863713287bbf118c10
2021-03-10 12:39:12 -08:00
Valentin Shergin 2f67c8d5b7 Fabric: surfaceId-based that controls Surface status methods were removed from Scheduler
Summary:
We don't use them anymore.

Changelog: [Internal] Fabric-specific internal change.

Differential Revision: D26376683

fbshipit-source-id: 801e9225502005ed01317ed396346176b2f2f5bc
2021-03-09 11:50:43 -08:00
Igor Klemenski e69f1c9f50 Fix unsafe cast and detect resize overflow. (#31106)
Summary:
Removing unsafe cast from `int` to `uint16_t`.
Also, adding code to detect multiplication overflow during buffer resize.

## Changelog

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

[General] [Fix] - Fix unsafe cast and detect overflow in MapBuffer.

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

Test Plan: Code compiles in Visual Studio 2019 without the unsafe cast warning (or error depending on the configuration).

Reviewed By: mdvacca

Differential Revision: D26865138

Pulled By: rozele

fbshipit-source-id: 4692a38b05fc873e31fbbe94d70803244e82de5d
2021-03-09 08:47:31 -08:00
Andrei Shikov 8dc5ca6a6a Use SurfaceHandler in ReactSurface
Summary:
Changelog: [Internal]

Updates `ReactSurface` to use `SurfaceHandler` internally.
This removes most of the internal state in `ReactSurface` and propagates all the calls to the `SurfaceHandler`.

`FabricUIManager` now uses `SurfaceHandler` to start/stop the surface.
SurfaceId is still used for view operations. SurfaceId is also now mutable to play better with existing Android infra.

Reviewed By: shergin, mdvacca

Differential Revision: D26112992

fbshipit-source-id: 52e6860084d739381317035dc3011956d452063c
2021-03-08 12:20:41 -08:00
Samuel Susla 8b821f8f12 Remove incorrect assert from ScrollViewShadowNode
Summary:
Changelog: [internal]

The assumption was wrong. There can be more than one view on iOS in ScrollView. The other view is pull the refresh component.

Reviewed By: mdvacca

Differential Revision: D26880403

fbshipit-source-id: 69fb1668b5ee7d5f4a4ab3c89222587689c10591
2021-03-08 02:02:15 -08:00
Samuel Susla 077e434d77 Do not retain UIManager inside background executor
Summary:
Changelog: [internal]

UIManager shouldn't be retained in lambda because if it outlives runtime it causes a crash.

UIManager -> ComponentDescriptorRegistry -> ParagraphComponentDescriptor -> TextLayoutManager's cache -> AttributedString::Fragment -> ShaviewView -> EventEmitter -> EventTarget -> Pointer

This is the chain of ownership that can cause a crash if UIManager is retained for longer than JS runtime.

{F459238235}

Reviewed By: JoshuaGross

Differential Revision: D26851194

fbshipit-source-id: 644cdee34ba9286618659d847fb2e78bc301d049
2021-03-07 04:40:26 -08:00
Samuel Susla a206f4fc2e Back out "Don't retain State in StateWrapperImpl"
Summary:
Changelog: [internal]

Original commit changeset: 0703c6dccc62

Reviewed By: yungsters

Differential Revision: D26849056

fbshipit-source-id: 2c6fca3ef06ac4868979d0a93c04c0eabdd56eb0
2021-03-05 10:45:25 -08:00
Samuel Susla 283512cc42 Fix Yoga's right to left offset in horizontal scroll view
Summary:
Changelog: [internal]

Yoga offsets content view of scrollview in RTL environment. React Native Classis deals with it by using a separate component [ScrollContentView](https://github.com/facebook/react-native/blob/6e6443afd04a847ef23fb6254a84e48c70b45896/React/Views/ScrollView/RCTScrollContentShadowView.m#L18-L25
) and making the adjustment there.

In New React Native Renderer, it can be handled inside `ScrollViewShadowNode`.

Reviewed By: JoshuaGross

Differential Revision: D26817121

fbshipit-source-id: ad48374ef19b802d25e919ac0aae05c5890762f2
2021-03-05 10:27:28 -08:00
Samuel Susla e6931caca4 Don't retain State in StateWrapperImpl
Summary:
Changelog: [internal]

StateWrapperImpl shouldn't retain State strongly because cleanup of `StateWrapperImpl` is triggered from Java and isn't guaranteed to take happen before runtime is destroyed.

This should resolve crash where `StateWrapperImpl`'s destruction causes a `~Pointer` to be called after runtime is destroyed.

Chain of ownership that will be broken by storing State weakly inside `StateWrapperImpl`.
`StateWrapperImpl -> ParagraphState -> TextLayourManager's cache -> AttributedString -> ShadowView -> EventEmitter -> EventTarget -> Pointer`

{F451105831}

Reviewed By: JoshuaGross

Differential Revision: D26815275

fbshipit-source-id: 0703c6dccc62c1d152923b786a83273fa8a03694
2021-03-04 13:14:39 -08:00
Samuel Susla 542c7cc357 Pass layoutDirection to surface handler
Summary:
Changelog: [internal]

During transition to SurfaceHandler, layoutDirection got lost. This diff adds it back.

Reviewed By: JoshuaGross

Differential Revision: D26775873

fbshipit-source-id: 9b638b4c2a41eb887312b968a2e113c5fcd7463d
2021-03-04 02:19:00 -08:00
David Vacca fca0442bc8 Extract ComponentNameRegistry out of Fabric modules
Summary:
This diff extracts ComponentNameRegistry out of Fabric modules

This is necessary to avoid depending on Fabric and regressing APK size for other RN apps (e.g. IG)

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D26765328

fbshipit-source-id: 0a22c4279146f5243473c74a84e78fad7f08f956
2021-03-03 14:16:03 -08:00
David Vacca 50621078b5 Introduce NativeComponentRegistryBinding class
Summary:
Introduce the NativeComponentRegistryBinding class, the purpose of this class is to register the  global function __nativeComponentRegistry__hasComponent into JS

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D26716902

fbshipit-source-id: d883b195b30600d3781d41158fd8c57cf22431df
2021-03-03 14:16:02 -08:00
Joshua Gross b08362ade5 Send unix timestamp for touch events instead of systemUptime
Summary:
We want to be able to instrument touch processing delays in JS, which does not have access to systemUptime; therefore we want a UNIX timestamp, which JS has access to and can compare to the touch time.

It only matters that there is relative consistency between multiple touch events in JS, which is still the case; so this should have no impact on product code.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D26705430

fbshipit-source-id: 2acd52ae5873a44edf1e0cb126a9a6c87203d8fa
2021-02-28 15:18:51 -08:00
Valentin Shergin f27621465d Fabric: Fixes in Android TextLayoutManager for better caching performance
Summary:
The is how it works:
* Text is a quite special component with special properties and constraints. Some of them are:
It's expensive to measure (layout) text. It's expensive to measure and expensive to pass AttributedString via JNI.
* When we measure text, we don't concerned about maximum height, only maximum height is important. (Even though theoretically, there are text layout systems that can balance these constraints (max height and width) trying to find a perfect result, we don't use such complex (and expensive) layout engines for building UIs).

Yoga, as a flexbox engine, does not aware of such constraints, so it requests remeasuring of text components quite often, so we have an RN built-in text measure cache system just for text measurements that suit these constraints. This way when Yoga requests a text measuring, we always measure with `Inf` height and store that result in the cache. And when Yoga requests another measure with the same width but a different height we retrieve the value from the cache and then just clamp it.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D26696637

fbshipit-source-id: f65b275d33c77073bc2359cbf0a741ddcf05d8d4
2021-02-28 08:47:05 -08:00
Valentin Shergin 5f1012c6f2 Back out "Fix incorrect Height in Text components"
Summary:
Original commit changeset: 3e769e0ca35b

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D26696638

fbshipit-source-id: 1dd432b35505be8e1b437a4578342cf84a6a5134
2021-02-28 08:47:05 -08:00
Samuel Susla f7d006e60c Fix memory leak convertJSIFunctionToCallback
Summary:
changelog: [internal]

### When does leak happen?
Leak happens anytime a callback isn't executed inside native module, it will never get cleaned up.
Imagine a native module with method that takes onSuccess and onFail callbacks. Only one of them will be called at any time and the other one will leak.

### Why does it leak?
It leaks because when `CallbackWrapper` is created using `CallbackWrapper::createWeak`. Inside `CallbackWrapper::createWeak`, the newly created object is inserted into `LongLivedObjectCollection`. This object collection will keep it alive until `CallbackWrapper::destroy` is called, which isn't called in case closure isn't executed.

### Solution
Introduce class RCTBlockGuard which ties cleanup of resources to lifetime of the block.

Reviewed By: RSNara

Differential Revision: D26664173

fbshipit-source-id: 9348f7c39eb317cf1e8e5d59e77a378e5e04f3eb
2021-02-27 04:55:52 -08:00
Joshua Gross 9f120efcf4 ReactCommon/utils: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695275

fbshipit-source-id: 85aae94105a2817d345d25f736386e545dff0a9a
2021-02-26 23:30:01 -08:00
Joshua Gross da73cca5e2 ReactCommon/renderer/scheduler: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695253

fbshipit-source-id: b0ff02416ab208dfd71f71c2b3d83009f40be0a9
2021-02-26 23:30:01 -08:00
Joshua Gross 88088b7851 ReactCommon/renderer/mapbuffer: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695224

fbshipit-source-id: 3044049cb2447a733a9ecae84dcc099b26731acd
2021-02-26 23:30:00 -08:00
Joshua Gross c24fc75dce ReactCommon/renderer/components/view: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695203

fbshipit-source-id: df09af5a62044c711368954b5e9b3a114491e2ed
2021-02-26 23:30:00 -08:00
Joshua Gross 768296823d ReactCommon/renderer/components/unimplementedview: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695184

fbshipit-source-id: fd98843f3485e13c9650c5a2576a1186ebb121db
2021-02-26 23:30:00 -08:00
Joshua Gross 7f792c8376 ReactCommon/renderer/core: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695162

fbshipit-source-id: 5615355f76b9c78d0f8981b3443b7c5900939ede
2021-02-26 23:29:59 -08:00
Joshua Gross 4326cb1527 ReactCommon/renderer/textinput: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695151

fbshipit-source-id: f5447e0a6d2b6bc06ff9456a35386a22106102f8
2021-02-26 23:29:59 -08:00
Joshua Gross 248c2dd7f2 ReactCommon/renderer/components/text: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695125

fbshipit-source-id: 3055dd3db7cd34bba9b3fc141032ac0f663523a1
2021-02-26 23:29:59 -08:00
Joshua Gross bca02c1008 ReactCommon/renderer/components/slider: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695097

fbshipit-source-id: 0a861b9f8a435267b16dcb9c37fd501901a544fd
2021-02-26 23:29:58 -08:00
Joshua Gross acb57ff2b6 ReactCommon/renderer/components/picker: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695073

fbshipit-source-id: f59b6ce7d8f2fd2c68bba41070228be981684ce0
2021-02-26 23:29:58 -08:00
Joshua Gross bdad5f6432 ReactCommon/renderer/components/modal: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695055

fbshipit-source-id: d70fdda569c09277d511dc154605559ef3cd56e8
2021-02-26 23:29:58 -08:00
Joshua Gross 01dcec401b ReactCommon/renderer/components/image: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695038

fbshipit-source-id: afcf2aecad8305b112e1b4ddcc1693380f3defcc
2021-02-26 23:29:58 -08:00
Joshua Gross ee98e6a493 ReactCommon/nativemodule: Migrate uses of NDEBUG to REACT_NATIVE_DEBUG + react_native_assert
Summary:
For better cross-platform consistency, migrate usages of NDEBUG to REACT_NATIVE_DEBUG. See flags.h for explanation.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D26695016

fbshipit-source-id: 63e6f6fc919076d94f04416f6821f21e0b3707a3
2021-02-26 21:20:25 -08:00
David Vacca b3cdf8cd7e Fix incorrect Height in Text components
Summary:
This diff fixes a bug in the calculation of layout for text components

The rootcause of the bug is that fabric is not taking into consideration height constraints as part of the cache for text measurments.
The title text was being measured with a specific height constraint (22px) at the begining of the render, later there was a re-measure for the same Text component with a different height constraint, but fabric was reusing the result of the first calculation instead of re-measuring the text.

changelog: [internal] internal

Reviewed By: JoshuaGross

Differential Revision: D26676716

fbshipit-source-id: 3e769e0ca35b3e363b96d3a6d1626a091eaad908
2021-02-25 17:57:21 -08:00
Joshua Gross 4e243ca7a3 Fix RTL scrolling
Summary:
We recently fixed RTL scrolling in Fabric on iOS: D26608231 (https://github.com/facebook/react-native/commit/e5921f7f384af45df4f355fa3fa1b58a20a269d3)

Turns out, the mechanism for RTL scrolling on Android is completely different. It requires that content be wrapped in a "directional content view", which is `View` in LTR and `AndroidHorizontalScrollContentView` in RTL, backed by `ReactHorizontalScrollContainerView.java`.

iOS doesn't require that and just uses View and some custom logic in ScrollView itself.

In the future it would be great to align the platforms, but for now, for backwards-compat with non-Fabric and so we don't have to tear apart ScrollView.js, we codegen the AndroidHorizontalScrollContentView so it exists in C++, register the component, and stop mapping it to View explicitly in C++.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D26659686

fbshipit-source-id: 3b9c646dbdb7fe9527d24d42bdc6acb1aca00945
2021-02-25 10:09:32 -08:00
Andrei Shikov ac704690dc Update Android.mk to ensure the rn-tester compiles in debug mode
Summary:
Changelog: [Internal]

Adds react_debug dependency in Android.mk where it was missing

Reviewed By: mdvacca

Differential Revision: D26617400

fbshipit-source-id: 5ac799269b106eadd881d30490ac34bd2134a9b7
2021-02-24 12:29:00 -08:00
Samuel Susla e5921f7f38 Fix horizontal scrolling in RTL scripts
Summary:
Changelog: [internal]

Fabric's scrollView now supports horizontal scroll view.

Reviewed By: JoshuaGross

Differential Revision: D26608231

fbshipit-source-id: 176a7802fa580247d12657e08780805daacd8357
2021-02-24 06:29:51 -08:00
Samuel Susla c060f368b9 Check for null in eventTargetFromValue
Summary:
Changelog: [internal]

Check for null before passing it to `EventTarget` constructor.

Reviewed By: JoshuaGross

Differential Revision: D26605779

fbshipit-source-id: a2773c8123d83c25736bccefe656d1def8794091
2021-02-24 06:07:16 -08:00
Samuel Susla f7eecc68cb Nullcheck before dispatching view command
Summary:
Changelog: [internal]

`shadowNodeFromValue` can return nullptr. Let's make sure it returns valid value before dispatching command.

Reviewed By: JoshuaGross

Differential Revision: D26605350

fbshipit-source-id: eb9a0347c95ba07fd7e9b7ddeca7e6d6011f50ad
2021-02-24 01:59:44 -08:00
Samuel Susla 270060e1d9 Pass weak pointers to background executor lambda
Summary:
Changelog: [internal]

### Why does the crash happen?

The crash can happen if runtime is destroyed before background executor lambda is run. Destroying a shadow node after runtime leads to a crash through the chain of ownerships.

Chain of ownership:
`ShadowNode -> ShadowNodeFamily -> EventEmitter -> EventTarget -> Pointer`

Pointer tries to call `invalidate` method on raw pointer to the runtime which is gone.

https://www.internalfb.com/intern/diffusion/FBS/browse/master/xplat/js/react-native-github/ReactCommon/jsi/jsi/jsi.h?commit=2ee3ae0c6a64&lines=335-339

To work around this, weak pointers are passed to lambda. This way the lambda is less likely to be the last owner of shadow nodes. Possibility of race still exists but it less likely to happen.

## Other solution
Alternatively, we could make sure native Runnable queue in Java is emptied as part of tear down process. We can even implement both solutions as they are semantically correct.

Reviewed By: shergin

Differential Revision: D26582554

fbshipit-source-id: b1b8a92237902bc4c40376176f575caa24a41a05
2021-02-22 17:02:19 -08:00
Valentin Shergin 099e7aa94d Fabric: New way (third attempt) to specify layout constraints for YGNodeCalculateLayout
Summary:
Surprisingly, it's not that trivial to pass `LayoutContrants` to `YGNodeCalculateLayout` in a way that always works. The problem is that `YGNodeCalculateLayout` does not allow expressing the constraints explicitly, so we need to pass them as `YGStyle` properties of a root node. With this approach, we unconditionally apply them as `YGStyle`s as actual values or `Undefined` value (which overrides some other values that can be previously set by calling this function or other code). We also intentionally preserve `height` and `width` values because it's a common use-case when a component explicitly specifies its size.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D26583550

fbshipit-source-id: 2cd506fbdc9e6a1a8f119d09ccfd34f876a13625
2021-02-22 14:47:40 -08:00
Samuel Susla f303266d69 Correctly handle null values in dynamic props in prop forwarding
Summary:
Changelog: [internal]

shergin found that folly's merge_patch implementation doesn't propagate `null` correctly (details in D26435620 (https://github.com/facebook/react-native/commit/1e9f63fe277c42d812ef007ced7eff1688602b62)). This is a requirement and needs to be adjusted in props forwarding on Android.

As far as we know this isn't causing any bugs but it is an error that should be fixed.

Reviewed By: shergin

Differential Revision: D26545821

fbshipit-source-id: 9edd24aecfcde17f5d9c1197f65db0e0f3f9e364
2021-02-22 05:53:24 -08:00
Joshua Gross 1fe5cac52a Remove custom STUB_VIEW_ASSERT in favor of react_native_assert
Summary:
We have a custom STUB_VIEW_ASSERT that helps debugging stub view issues on platforms (like iOS) where flushing logs around assert-time isn't 100% guaranteed.

Move that logic into react_native_assert since it's generally useful.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D26567218

fbshipit-source-id: 79f5ae66fc65a0af48dbcf4c7204ac8245911cb0
2021-02-20 20:08:02 -08:00