Summary:
Previously, we stored a pointer to ShadowNode inside NSAttributedString's attributes to make possible retrieving an EventEmitter associated with some text fragment.
That worked fine besides only one caveat: the internal implementation of NSAttributedString is quite strange and that causes a memory leak. Because of some reason, NSAttributedString does not release stored attributes after own destruction (maybe OS uses some kind of caching).
So, now, instead of storing a strong pointer to ShadowNode inside NSAttributedString, we store a weak pointer to EventEmitter. Storing a weak pointer is okay because a desired lifetime of EventEmitter is guaranteed by LocalData stored inside a View. Storing a weak EventEmitter instead of weak ShadowNode will also help us with migration to ShadowView (we cannot store ShadowView weakly because it's a stack allocated object).
Reviewed By: sahrens
Differential Revision: D13196886
fbshipit-source-id: f8714e4b3709765629d6456edf0c635bf5f7c53b
Summary:
Consider this:
* ParagraphShadowNode retains LocalData,
* LocalData contains AttributedString,
* AttributedString contains Fragments,
* Fragment can contain a pointer to parent shadow node, so it can be the ParagraphShadowNode.
In this case it's a retain cycle.
We actually don't need to store pointers to not TextShadowNodes, so we don't now.
Later, after we fully migrate to ShadowView, we can remove this condition because it will become harmless.
Reviewed By: sahrens
Differential Revision: D13196885
fbshipit-source-id: d386ce0a067df0a72e6619d62d56038aaf80eccb
Summary: Over-retaining a LocalData object inside the View can cause a crash during tearing down JS VM because LocalData can indirectly retain EventEmitter objects which were not properly "disabled".
Reviewed By: sahrens
Differential Revision: D13196887
fbshipit-source-id: 001d9fadf775c89f750c84fe8da9b84d4636631c
Summary: RCTViewComponentView retains an EventEmitter, so we have to clear this up after we recyled the view.
Reviewed By: sahrens
Differential Revision: D13196884
fbshipit-source-id: e9f2e2400be864c5c6177227255012101ed8c4d1
Summary:
Updated the configuration for all projects on xplat/js to only consider tests that end with `-test.js`.
All tests were migrated in the previous diff of the stack.
Reviewed By: mjesun
Differential Revision: D13185676
fbshipit-source-id: baaba94fabc403acb30b0b5a0462788813d7a870
Summary:
Renamed test files to match `-test.js`, so people can add test helpers without blacklisting.
Codemod code: P60365841
Script executed:
```
cd xplat/js
./scripts/node/node rename-script.js > result.txt
```
Reviewed By: mjesun
Differential Revision: D13185673
fbshipit-source-id: 87451635aa538c2c1d1886e75574d0e5c889596e
Summary:
@public
Marking the node as dirty when isReferenceBaseline property is changed
Reviewed By: davidaurelio
Differential Revision: D13147742
fbshipit-source-id: 3bbff1cfceeadfbf77380519e4638f2984fc2009
Summary: As suggested by yungsters in D13138187
Reviewed By: mjesun
Differential Revision: D13192765
fbshipit-source-id: 8ab3dc74b3a9aaebf043bc3b5ed4f2590f480d10
Summary: There is only a single use of this function across RN, and one more use in a test file. I inlined this function in both places to reduce the dependency on fbjs.
Reviewed By: yungsters
Differential Revision: D13138137
fbshipit-source-id: 32660c965a975d17e236bdd13ff0b2a8d64751ee
Summary: There are no DOM Nodes in React Native so our Map polyfill does not need to consider that use case. I deleted the references to `isNode` and `IE. In case this is important for react-native-web, I suggest to shim the Map polyfill with an IE compatible one outside of react-native.
Reviewed By: yungsters
Differential Revision: D13138030
fbshipit-source-id: 661511ea03b4477bd55d0fdf5e485178fe59d96b
Summary: This module simply forwards to the `promise` module. I inlined the code to remove the dependency.
Reviewed By: yungsters
Differential Revision: D13137980
fbshipit-source-id: e3d6208068911711fc5f5378f2d5bb6ac38f2eb2
Summary:
[Folly upgrade](a70625abd7) introduced changes that have to be applied to `Install Third Party` script in order to use `New build system` from Xcode 10. Unfortunately, this might happen again if someone changes folly. Also removes non-existent files from folly podspec.
Pull Request resolved: https://github.com/facebook/react-native/pull/22394
Differential Revision: D13192463
Pulled By: hramos
fbshipit-source-id: ea0eeb6e1e7f6d7dfcdb6d1dee28b1a640ee7097
Summary: View recycling can be pretty aggressive and memory intensive, so we can properly react on system memory-pressure notification.
Reviewed By: mdvacca
Differential Revision: D13176278
fbshipit-source-id: 38ea1b27da988aeaaa5db6ac0b94389a0bd2799e
Summary:
Apparently, the previous behavior brings more problems than some *possible-in-the-future* features and flexibility.
The new model allows us to easily implement "nested text" feature.
(We temporary hope the old behavious for Android only for compatibility reasons.)
Reviewed By: mdvacca
Differential Revision: D13176277
fbshipit-source-id: 01f7bfb3c2e70cc89d76ecb78add016ee91cbd63
Summary:
The whole mounting iOS infra now uses `ComponentHandle` instead of `std::string` as a reference to particular `ComponentView` implementation. All changes are pretty straightforward, we use a different thing/type to refer to the particular class; no changes in the logic besides a new `RCTComponentViewFactory` that serves the same role of classes registry as Objective-C runtime served previously.
That has several benefits:
* It should be slightly faster, mostly because we don't need to convert `char *` strings to `std::string` and then to `NSString *`.
* We don't need string-based component-name maps anymore (at least on this layer). We can call classes as we want and it will work because of classes are now explicit about which ShadowNodes they are compatible with.
* Most importantly, it's explicit now! That means that no runtime magic is involved anymore and we can rely on static linting tool now and not be afraid of improper code stripping/overoptimization.
Reviewed By: mdvacca
Differential Revision: D13130760
fbshipit-source-id: aadf70525a1335b96992443abae4da359efdc829
Summary: The new method in the protocol enforces view component classes to expose a component handle of the component that the view component represents. That will allow us to wire up those classes with shadow views in runtime explicitly and in a much more performant way than it is now.
Reviewed By: mdvacca
Differential Revision: D13114663
fbshipit-source-id: 853187d978aab200f85719d9c1d9fea2e3ad4e55
Summary:
This diff changes the method to calculate the hash of an AttributedString (removing shadowNode and parentShadowNode from it).
This is necessary becuase otherwise hashcode of clonned parent keep changing in every state change, when the text doesnt change
With this change we are able to cache spannables in android properly
Reviewed By: shergin
Differential Revision: D13189110
fbshipit-source-id: c1f7372809ce98a5b4d091485cc15281a4ab5e1e
Summary: This diff adds support to cache the Spannable objects that are created during measure() and updateLocalData() for text
Reviewed By: shergin
Differential Revision: D13188599
fbshipit-source-id: 6547d8ce2bb8b1dfb3c91e64facff3ba0cd97472
Summary:
Removing two props that are not currently used
They are being set as quiet_NaN in C++ and this brings problems in the Android side
Reviewed By: shergin
Differential Revision: D13188600
fbshipit-source-id: e8412497a80300cfbc3770b829e9633206aaf427
Summary: This diff fixes re-measures of a text component result of a change of state. For details of the bug see: T36838266
Reviewed By: shergin
Differential Revision: D13188601
fbshipit-source-id: ea9a889540f600d4e4e788105d5fa22e6cd5448c
Summary: In this diff we expose the text local data hash to android, this will be used in the future to cache metadata when rendering text in android
Reviewed By: shergin
Differential Revision: D13161873
fbshipit-source-id: cd13a4beba75a3fe62ac9ff3def26f88e874834b
Summary: Simple diff that adds a systrace to start measuring the calculation of Yoga layout() in Fabric
Reviewed By: shergin
Differential Revision: D13124641
fbshipit-source-id: 6bd03e9f56524221f5d91606ffde50253673c1bb
Summary: This diff refactors the types used when Yoga requires to measure the size of a View in C++
Reviewed By: shergin
Differential Revision: D13124086
fbshipit-source-id: 89dfe80bb41b4fb2eaba84af630d52ef2509b1e1
Summary:
@public
Adds types for a marker API in Yoga.
This will allow us to register callbacks that Yoga can use to log performance data without hard-coding the backend system for that.
Reviewed By: SidharthGuglani
Differential Revision: D13118830
fbshipit-source-id: b42a42c609f0cf66212186f7f20ee572522d59e3
Summary:
> Configure project :ReactAndroid
> The Task.leftShift(Closure) method has been deprecated. This is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
> Task :ReactAndroid:buildReactNdkLib
> A problem was found with the configuration of task ':ReactAndroid:buildReactNdkLib'. Registering invalid inputs and outputs via TaskInputs and TaskOutputs methods has been deprecated and is scheduled to be removed in Gradle 5.0.
> - File '[...]/react-native/ReactAndroid/src/main/jni/react' specified for property '$1' is not a file.
Pull Request resolved: https://github.com/facebook/react-native/pull/22360
Differential Revision: D13176269
Pulled By: hramos
fbshipit-source-id: cf6d498049b955d3920d356f2d68f3bc43008c56
Summary: This is the tweak on the release process of metro: after publishing D13075199 and releasing a new version of Metro, this diff upgrades it in RN along with its yarn.lock file. This should allow us to publish new versions of metro without breaking the RN sanity scripts (or disable them).
Reviewed By: hramos
Differential Revision: D13084224
fbshipit-source-id: 19781ae142db11d7dd8b6ca4303366f7ccb32dcc
Summary: Stop ignoring `metro` folder from RN and use their flowtypes correctly
Reviewed By: hramos
Differential Revision: D13085169
fbshipit-source-id: f285223afb7e89ac2c63e53d36be2f3645fa6761
Summary:
@public
`YGNodeComputeFlexBasisForChildren` was using an output parameter (`float&`) that is always initialised to `0.0f`.
Here, we move the initialisation inside `YGNodeComputeFlexBasisForChildren`, and simply return the result.
Reviewed By: astreet
Differential Revision: D13167509
fbshipit-source-id: cbea20e2deb82ec75a1c158b16c94f4a3e5e4c99
Summary:
@public
passes all enum values by value, not by reference.
Reviewed By: astreet
Differential Revision: D13156390
fbshipit-source-id: 56aea66c16ab3325594f67b9017afa18a678d281
Summary:
@public
Remove ability to configure Yoga to run with/without JNI fast calls on dalvik / art.
This switches to always run with fast calls.
Reviewed By: astreet
Differential Revision: D13144652
fbshipit-source-id: 091aab0cd1290d46346323d3e26a11dd0bb17187
Summary:
@public
Passes all `float`, `bool`, etc. by value, not by reference.
Reviewed By: astreet
Differential Revision: D13153500
fbshipit-source-id: 95529bc2efcff144044e2c25087915b2b7ede179
Summary:
Add getUndefined() method to obtain the undefined value.
This would allow to obtain the Yoga undefined value in runtime, and not just in compile time
Reviewed By: davidaurelio
Differential Revision: D13136972
fbshipit-source-id: aa198aa1ea65bb6b7302abeba6f9f5d483a45ff3
Summary:
During C++ build, we need the libjsc.so.
But arm64-v8a and x86_64 libjsc.so are in different path and this error raised:
Android NDK: ERROR:/home/circleci/react-native/ReactAndroid/build/third-party-ndk/jsc/Android.mk:jsc: LOCAL_SRC_FILES points to a missing file
/opt/ndk/android-ndk-r17c/build/core/prebuilt-library.mk:45: *** Android NDK: Aborting . Stop.
Android NDK: Check that /home/circleci/react-native/ReactAndroid/build/third-party-ndk/jsc/jni/arm64-v8a/libjsc.so exists or that its path is correct
The commit moves prebuilt libjsc.so into
ReactAndroid/src/main/jni/third-party/jsc/jni and let ndkbuild script find the prebuilt libjsc.so.
For AAR packaging, modify the jniLibs so that gradle android library plugin could find the prebuilt libjsc.so as well.
Pull Request resolved: https://github.com/facebook/react-native/pull/22377
Differential Revision: D13166556
Pulled By: hramos
fbshipit-source-id: 61daaede7defbc66491a3e2f20058e7d248ba13e
Summary: Now we don't update `LocalData` for `ParagraphShadowNode` if the attributed string hasn't changed.
Reviewed By: mdvacca
Differential Revision: D13160128
fbshipit-source-id: 6ffe76ad187452fa37ba36a132b885cbcedfd1d3
Summary: This method is underlying infra for all `measure`-like methods exposed to JavaScript.
Reviewed By: mdvacca
Differential Revision: D13036553
fbshipit-source-id: cb5135f1db97ec8144b31a24ee4fb9f5d61f0df1
Summary: The diff adds a pointer to ShadowTreeRegistry to UIManager which enables the possibility of implementing ShadowTree mutating and inspecting methods like `setNativeProps` and `getRelativeLayoutMetrics`.
Reviewed By: mdvacca
Differential Revision: D13036549
fbshipit-source-id: 5ed1252d84c8dd895fe0e6e8cc71afbaa9dab4b7
Summary:
Why do we need a dedicated registry class?
* We need to simplify registry-related logic in Scheduler.
* We need to couple threading aspect of the registry with the registry itself, otherwise it's not clear why exactly we acquire the mutex. We also should not acquire the mutex in a per-method way (as we did before), because it's incorrect and misleading (only lines that access the registry should by protected).
* We need to have a way to share the registry with other classes (e.g. UIManager) without passing a reference to the whole Scheduler.
Reviewed By: mdvacca
Differential Revision: D13036550
fbshipit-source-id: 644da910e823666c586834a3da2b4cdcb90eebb2
Summary: Trivial. Those are not used.
Reviewed By: fkgozali
Differential Revision: D13017883
fbshipit-source-id: cf285e537eb85c8fca6852f7c03a5ef661b85757
Summary:
The generic method that returns relative (to some specified node) layout metrics.
We need this as a building block to implement `UIManager.measure*()` methods family.
Reviewed By: mdvacca
Differential Revision: D12932549
fbshipit-source-id: 79064551d32b0cd40e72dc87d0ed194e3779ba29
Summary:
We have to have a way to backtrack a pointer to a parent node and this is generalized version of that.
This is the first naive implementations of the algorithm. We will invest in optimizing this later.
Reviewed By: mdvacca
Differential Revision: D12920856
fbshipit-source-id: 9facb4e16a0b5608feb6747df3804952025ef093
Summary: Future::then taking a value-taking function is deprecated and being deleted. This cleans up a few more callsites.
Reviewed By: yfeldblum, shergin
Differential Revision: D13163277
fbshipit-source-id: 98d1f78c5b34ca34603cc24d79157a4718573576