Summary:
This is a bandaid fix to address a crash with a stack trace involving
```
com.facebook.react.uimanager.IllegalViewOperationException: Trying to add a root view with an explicit id already set. React Native uses the id field to track react tags and will overwrite this field. If that is fine, explicitly overwrite the id field to View.NO_ID before calling addRootView.
0+com.facebook.react.uimanager.NativeViewHierarchyManager.addRootViewGroup(NativeViewHierarchyManager.java:546) [inlined]
1+com.facebook.react.uimanager.NativeViewHierarchyManager.addRootView(NativeViewHierarchyManager.java:538) [inlined]
2+com.facebook.react.uimanager.UIViewOperationQueue.addRootView(UIViewOperationQueue.java:678) [inlined]
3+com.facebook.react.uimanager.UIImplementation.registerRootView(UIImplementation.java:216) [inlined]
4+com.facebook.react.uimanager.UIManagerModule.addRootView(UIManagerModule.java:355)
5+com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1032)
6+com.facebook.react.ReactInstanceManager.attachRootView(ReactInstanceManager.java:726) [inlined]
7+com.facebook.react.ReactRootView.attachToReactInstanceManager(ReactRootView.java:524)
8+com.facebook.react.ReactRootView.startReactApplication(ReactRootView.java:377)
```
This crash seems to be happening because the root view's id is set to a non NO_ID value, but further up in the stack trace, UIManager.addRootView() is called which always sets the root view's id to NO_ID. It's not clear how this error is happening, but in this code path it's expected that addRootView should always ensure that the id is always reset. In order to avoid crashing for this, let's remove the exception and log the issue instead.
In the future, we should not be overloading the android view id field with these types of react native implementation details. The react tag should be stored as a view tag instead.
Reviewed By: mmmulani
Differential Revision: D10499861
fbshipit-source-id: 4dffedab4e7a34eee7f64bb43ec8209699521c73
Summary: This diff fixes a crash that happens when a component throws an exception that contains a null message
Reviewed By: achen1
Differential Revision: D10429661
fbshipit-source-id: 9faed36906844b51f5a3dc2b3cbc80ede6b93457
Summary: UIImplementationProvider was removed as part of D8650376, this was a breaking change that caused problems in OSS. This diff introduces the concept of a deprecated UIImplementationProvider again to allow OSS community to upgrade to latest version of RN.
Reviewed By: achen1
Differential Revision: D10456317
fbshipit-source-id: 6817629524f927dfcb5ebc054dbfd983877b7606
Summary:
This diff includes a few changes:
1. Move the headers inside `jsiexecutor` into `jsiexecutor/jsireact`. As far as I'm aware, the Android ndk build system isn't flexible enough to support header namespaces, so we can't just expose the headers inside the `jsiexecutor` directory under the `jsireact` namespace. Therefore, I moved the headers to `jsiexecutor/jsireact`, and added `jsiexecutor` to the header search path. This was the easiest way to simulate `jsireact` namespace.
2. Setup the Android.mk files to get RNTester compiling and running.
3. Introduce a `jscexecutor` module to make `JSCExecutor.java` execute without throwing.
**Note:** Moving the header files inside `jsiexecutor` probably breaks the iOS builds and internal builds. I'll fix those in subsequent diffs on this stack.
Reviewed By: shergin
Differential Revision: D9995429
fbshipit-source-id: 418a4ee91f585842c5e317af2f300227a51e9ba8
Summary:
Removing entire files will be the next diff
@public
Reviewed By: fkgozali
Differential Revision: D9328239
fbshipit-source-id: 083847d3b841a3c7bfa751a82e8cc16bd112bace
Summary:
This removes the dependency on JSCExecutor. Everything goes
through JSI now.
Reviewed By: RSNara
Differential Revision: D9328240
fbshipit-source-id: c9c085fec1ebd5d0f4679cd70b89cc263ca33ac4
Summary:
This is similar in function to the old JSCExecutor, but uses the more abstract JSI API to interact with the JSVM.
@public
Reviewed By: axe-fb
Differential Revision: D9328241
fbshipit-source-id: 3212ff4f43d0589a70d7bebc4d463d4433590f1d
Summary:
With this, we send the correct x position when using center or right aligned text. In order to accomplish this though, we have to pass the text alignment into the Layout object that we create.
Also update RNTester to allow us to try different alignments.
Reviewed By: sahrens
Differential Revision: D10316494
fbshipit-source-id: 11c7d2a59e636528f12211168acb46f16b54a126
Summary:
Original PR: https://github.com/facebook/react-native/pull/21340
The original PR fixed a bug with border radius on Android 7.0, but caused a new bug where no `ReactART` components would render if they were nested within a View with border radius set.
Differential Revision: D10409352
fbshipit-source-id: 0b4e36ae9d4c3bc2f4884a43909f8efdeeb41b74
Summary:
DynamicFromMap internally uses SimplePool object to recycle dynamic prop objects. But the pool is not multi-thread safe. Currently the most used dynamic props are size props such as left, paddingVertical, marginTop and so on. These props are only accessed from the layout thread so the pool works fine. If a dynamic prop is needed in UI thread, then the two threads can access the same pool object and cause random errors. This PR make the pool object thread local to avoid synchronization. After this change there are two pool objects created in the process.
Tested in official Airbnb app after updating accessibilityComponentType to be dynamic.
Once this is merged, I'll send another PR to support "disabled" state in `accessibilityComponentType`.
[ANDROID] [BUGFIX] [DynamicFromMap] - Fix a crash caused by dynamic props.
Pull Request resolved: https://github.com/facebook/react-native/pull/17842
Differential Revision: D10374238
Pulled By: hramos
fbshipit-source-id: 7ebf89c5abf06bd5fb43b205348ba4dc7e19517d
Summary:
Today, ReactInstanceManager calls `ReactChoreographer.initialize()` in its constructor. Since `ReactChoreographer` also needs to run on the UI thread, this forces the entire `ReactInstanceManager` to run on the UI thread.
By moving `ReactChoreographer` to lazily set up its Choreographer, we can make `ReactInstanceManager` run on any thread
Reviewed By: mdvacca
Differential Revision: D10097432
fbshipit-source-id: eb8c80aafcba745ea15c86296d11c487329b1df0
Summary: This diff makes sure the native side of the UILayer of RN is deallocated when the a RN screen is reloaded.
Reviewed By: shergin
Differential Revision: D10343030
fbshipit-source-id: 7add841b8875d28fe527f20b96f799733769b11a
Summary: This diff avoids deleting all the views of ReactRootView when the ReactContext is destroyed (ONLY FOR FABRIC). In Fabric these views are removed and deleted by the framework when the ReactShadowNode is destroyed.
Reviewed By: shergin
Differential Revision: D10319737
fbshipit-source-id: 2e2d2599006cd8205e0153c18cd75383387ce1df
Summary: Moving up when we start the CORE marker to `FbReactFragment.onFragmentCreate` on FB4A. Right now the CORE marker gets started with CREATE_REACT_CONTEXT_START, since it's possible for the instance manager to be created before TTI begins. We address this in HOME_TTI by collecting the getInstanceManager time, comparing to TTI start, and using that as bridgeStartupStartTime. Ideally, though, we'd just start the CORE marker at the right time so we can use it independently to measure RN startup. This diff moves up CORE start time to `onFragmentCreate` (even before `getReactInstanceManager`)
Reviewed By: alexeylang
Differential Revision: D10094921
fbshipit-source-id: 77986535915f8e81d4d2c5b9108cbed40d1a75be
Summary:
The end-of-scrollable-range offset was not clipped before the nearestOffset calculation causing the ScrollView to not snap to the end of the view when the width of the ScrollView was not an exact multiple of snapToInterval.
Addresses https://github.com/facebook/react-native/issues/21116#issuecomment-427944838
Reviewed By: yungsters
Differential Revision: D10248545
fbshipit-source-id: 2bdc94ea0a9d9f063769f2c5da4c33d4872b1db2
Summary:
We're currently getting a redbox in Turkish when we try to convert the string 'easeInEaseOut' to an InterpolatorType. This is because I use toLowerCase() to compare the string without setting a locale; in Turkish, the capital letter 'I' doesn't convert to 'i' when you lowercase it, but rather to 'ı' (http://www.i18nguy.com/unicode/turkish-i18n.html).
Passing in a locale param to `toLowerCase()` fixes it. Also updating the test.
Differential Revision: D10315474
fbshipit-source-id: 54be3ff1d3f91cb2ec765ff705ac364b976b8c6f
Summary: This diff enables the onPress event for TextViews that render RawText
Reviewed By: shergin
Differential Revision: D10222183
fbshipit-source-id: 4b6a6ad548286453f7dd3a14a5e4ee453a55b923
Summary: This diff introduces the collapsable props in the viewProps. This prop is used in product code to prevent specific Views to be removed from the view hierarchy
Reviewed By: shergin
Differential Revision: D10254679
fbshipit-source-id: 637665b8998a86e29e839eb6d405a0fac354c8d3
Summary: Adding a test for the newly added InterpolatorType.fromString()
Reviewed By: axe-fb
Differential Revision: D10203814
fbshipit-source-id: f3c70db1a5754c79b1bdd881d266bec110934494
Summary:
If a folly::dynamic contains a double when a Java method is
declared to take an int, getInt() will be called, and a C++ exception
will be thrown. This change uses similar logic to
NativeReadableMap.getInt() to convert a folly::dynamic double to a
jint. This will still throw an exception if the JS value cannot be
represented as a jint without loss.
Reviewed By: fromcelticpark
Differential Revision: D10209492
fbshipit-source-id: fd96416200c6b283ce5c8f8fa4c227ceb8f43054
Summary: Simplifying our OSS enums (remove private variables and methods) so that redex can more easily optimize them for us.
Reviewed By: achen1, Feng23
Differential Revision: D9812796
fbshipit-source-id: 11a8272db41ff04399d1cdf366e28ddf1b07b7be
Summary: D10138128 had some shamefully wrong boolean logic to determine whether we should customize the accessibility delegate. Previously, we did it if BOTH the accessibility label AND role were present. We should actually do it if EITHER are present.
Reviewed By: mdvacca
Differential Revision: D10182135
fbshipit-source-id: 209a8ab43f5869762843fe878cfd59a7b9b5ab1a
Summary:
Since `ChoreographerCompat.getInstance()` is a singleton, we cache its instance.
This will be important in a subsequent diff where we ensure that `ChoreographerCompat.getInstance()` is only called on the UI thread
Reviewed By: achen1
Differential Revision: D9169298
fbshipit-source-id: 2067a50770dd41f5b1a12b62b6a9f8fea83d91e8
Summary:
Reducing the places where we directly access `ChoreographerCompat.getInstance()`.
Since this is a singleton anyway, there was no need to pass this as an argument. In subsequent diffs, we will also ensure that `ChoreographerCompat.getInstance()` runs on the UI thread, so that the `Choreographer` it gets is based on the `Looper` of the main thread.
Reviewed By: achen1
Differential Revision: D10136624
fbshipit-source-id: ad18f7b61eb8b05094aff310f2eb90eb225427dc
Summary: Creating this Handler in the constructor implies that the constructor needs to run on the UI Thread. Since DevSupportManager is also initialized with ReactInstanceManager,
Reviewed By: mdvacca
Differential Revision: D10094981
fbshipit-source-id: b724b05ddbd6af68da1111a1a004491835f7a35a
Summary: This diff removes unused method on the FabricBinding class, these methods were being used as part of the Fabric Android implementation, but they are not necessary anymore.
Reviewed By: shergin
Differential Revision: D10128636
fbshipit-source-id: 5afef4c2e9f4955af008200c5bdd2b6acc7ef333
Summary: This diff introduces the concept of EventBeatManager, this is a class that acts as a proxy between the list of EventBeats registered in C++ and the Android side.
Reviewed By: shergin
Differential Revision: D10127857
fbshipit-source-id: a1956ca42d4c470fbc11cc9f30336a182fe7910c
Summary:
Second attempt at landing D9930713. Notes about the previous issue is mentioned as an inline comment below.
===========
We are currently iterating through each view manager to get its class name to pass to JS. JS uses this list to define lazy property accesses for each view manager to grab the constants synchronously. This results in each view manager's class loading immediately -- causing a small perf hit.
Let's avoid this view managers list entirely. JS is able to access each view manager directly by calling getConstantsForViewManager(name)
Reviewed By: axe-fb
Differential Revision: D10118711
fbshipit-source-id: 78de8f34db364a64f5ce6af70e3d8691353b0d4d
Summary:
The current accessibility implementation tries to generalize every view's accessibility node info by setting an accessibility delegate on every view -- regardless of whether or not any accessibility properties are set. This delegate however doesn't correctly set the appropriate accessibility node fields for every view. For example, ScrollViews needs AccessibilityNode.setScrollable(true) set, but the generic delegate does not account for this. For now let's avoid unnecessarily
setting an accessibility delegate on views that don't have any accessibility props set, which will likely fix the majority of these issues.
Reviewed By: mdvacca
Differential Revision: D10138128
fbshipit-source-id: b999b41e7256e3dce94cd70e9b944979d52f74fd
Summary: ReadableNativeArray initializes the ReactBridge which loads a bunch of c++ classes. Let's avoid doing this on the UI thread.
Reviewed By: mdvacca
Differential Revision: D10108380
fbshipit-source-id: ab4520535288ce450a865952e996b716d571df7f
Summary:
Currently, loading SO libraries is pretty expensive. While they are triggered due to accessing `ReadableNativeArray`. However, with preloader experiments, this block seems to move around and is loaded when the first dependent class loads it.
Also, as a part of D10108380, this will be moved again.
Adding a trace to keep track of where it moves.
Reviewed By: achen1
Differential Revision: D9890280
fbshipit-source-id: 4b331ef1d7e824935bf3708442537349d2d631d0
Summary:
Update several files to use the proper copyright header:
```
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
```
In the case of Xcode project files, I used the shortform version, `Copyright (c) Facebook, Inc. and its affiliates.`
Reviewed By: axe-fb
Differential Revision: D10114529
fbshipit-source-id: a1f2d5a46d04797c1cf281ea9ab80d3a2caa6fb4
Summary:
This fixes cookie missing bug on Android 5.0 and above.
On Android 5.0 and above, after the app successfully obtains the cookie, you kills the App within 30 seconds and restarts the App. It accesses the interface that needs to carry the cookie and finds that the cookie does not exist.
Updated tests for the addCookies function to include test cases specifying Android version, and tested on the command line in my app to make sure it has the expected behavior.
Updated tests for the addCookies function to include test cases specifying Android version, and tested on the command line in my app to make sure it has the expected behavior.
[ANDROID] [BUGFIX] [Cookie] - Fix cookies lost on Android 5.0 and above
Pull Request resolved: https://github.com/facebook/react-native/pull/19770
Differential Revision: D10114102
Pulled By: hramos
fbshipit-source-id: 5b4766f02f70541fd46ac5db36f1179fe386ac7a
Summary:
Fixes our top crash when framework try drop a view from parent, but it's a null (already removed etc.).
Fixes#20288
Pull Request resolved: https://github.com/facebook/react-native/pull/20465
Differential Revision: D10113976
Pulled By: hramos
fbshipit-source-id: 34f5654f3bdbc63eb7f7d0b5c94885576fc3cdcd
Summary:
update creation logic for text shadow: allow shadows with zero offset when the radius is nonzero
(?should we also add a check to drop the node as a no-op when color.alpha == 0 ?)
Reviewed By: yungsters
Differential Revision: D10017778
fbshipit-source-id: 0168ac6db5ad22a5d7eb32dcd184aede361d6651
Summary:
This change adds getter for overflow attribute in ReactViewGroup class. Overflow setting can affect how view children are drawn but also how hit testing behaves when receiving touch. Exposing this setting makes it possible for gesture-handler library to implement proper hit testing that takes into account overflow property of a view.
Pull Request resolved: https://github.com/facebook/react-native/pull/21398
Differential Revision: D10105398
Pulled By: shergin
fbshipit-source-id: 15ae2b31be3bf80e7e1d28b87ce4474af0f486f5
Summary:
We are currently iterating through each view manager to get its class name to pass to JS. JS uses this list to define lazy property accesses for each view manager to grab the constants synchronously. This results in each view manager's class loading immediately -- causing a small perf hit.
Let's avoid this view managers list entirely. JS is able to access each view manager directly by calling getConstantsForViewManager(name)
Reviewed By: TheSavior
Differential Revision: D9930713
fbshipit-source-id: 4aa013f8398d4f51b7eef07937d2977ba1950726