Summary:
@public
Creates a single header file for `YGValue`. This is in preparation of a more compact representation of `YGValue` within `YGStyle`.
Also fixes the incorrect definition of NAN.
Reviewed By: SidharthGuglani
Differential Revision: D13172444
fbshipit-source-id: 4250dbcf8fe15ec3ecdee3913360a73bab633ce3
Summary: Each app may provide different impl for its runtime specific behaviors, then Fabric and other new infra can share the same config instance to configure stuffs.
Reviewed By: sahrens
Differential Revision: D13290319
fbshipit-source-id: 30e3eeedc6ff6ef250ed233b27e38cb7c1062b55
Summary:
There is a problem that the `mediaPlaybackRequiresUserAction` property does not work in WKWebView(`useWebKit`) under iOS 10.
I fully know you are currently working to migrate the core's WebView to the standalone `react-native-webview` project. This has already been submitted to PR in `react-native-webview` and will be merged soon. I hope this fix applies to `react-native` before your migration is done.
Pull Request resolved: https://github.com/facebook/react-native/pull/22208
Differential Revision: D13334868
Pulled By: cpojer
fbshipit-source-id: f2a811a477054155ed5fe62ab31e4d63f70e7848
Summary:
This avoids an intermittent reentrancy bug in JSC on iOS 11
(https://bugs.webkit.org/show_bug.cgi?id=186827). It also makes the
code more consistent with android.
Reviewed By: amnn
Differential Revision: D13313265
fbshipit-source-id: f42476b2f660e127ecfc9c72584554817eea1010
Calling -[UIScrollView setContentOffset] with NaN values can cause a crash. That's not clear why exactly the computation returns NaN sometime, but the implemented sanitizing should help to detect this problem during development (and this also prevents the app from crashing).
See attached task for more details.
Reviewed By: fkgozali
Differential Revision: D13242729
fbshipit-source-id: 747bf1b42e02597e9f1300eee24547563ab29b27
Summary:
ShadowView, ShadowViewMutation, and Differentiator were decoupled to separate module.
That enables us to use ShadowView more widely without facing a circular dependency problem.
Reviewed By: mdvacca
Differential Revision: D13205229
fbshipit-source-id: 7373864bf153a7813c2f97edb263a41454ce0b88
Summary:
This may be controversial.
Right now, RelayPrefetcher is initialized [here](https://fburl.com/p01iunr1), after bridge is initialized. I want to create a FBRelayPrefetcherModule instance eagerly (diff 3 in stack), and then pass that into the bridge module registry. This way, native side gets to use RelayPrefetcher before bridge is init, and JS still accesses the same instance of FBRelayPrefetcherModule.
The only other option is drastically change bridge init, to allow passing in some eagerly initialized instances.
Reviewed By: shergin
Differential Revision: D13164277
fbshipit-source-id: b45111cd68d78820e61e4fca7e54a7e8df32a3f0
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: 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:
[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: 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
Summary:
If text is truncated and an inline view appears after the truncation point, the user should not see the inline view. Instead, we have a bug such that the inline view is always visible at the end of the visible text.
This commit fixes this by marking the inline view as hidden if it appears after the truncation point.
This appears to be a regression. React Native used to have logic similar to what this commit is adding: 1e2a924ba6/Libraries/Text/RCTShadowText.m (L186-L192)
**Before fix**
Inline view (blue square) is visible even though it appears after the truncation point:

The full text being rendered was:
```
<Text numberOfLines={1}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
<View style={{width: 50, height: 50, backgroundColor: 'steelblue'}} />
</Text>
```
**After fix**
Inline view is properly truncated:

**Test Plan**
Tested that the inline view is hidden if it appears after the truncation point when `numberOfLines` is 1 and 2. Similarly, verified that the inline view is visible if it appears before the truncation point.
**Release Notes**
[IOS] [BUGFIX] [Text] - Fix case where inline view is visible even though it should have been truncated
Adam Comella
Microsoft Corp.
Pull Request resolved: https://github.com/facebook/react-native/pull/21456
Differential Revision: D10182991
Pulled By: shergin
fbshipit-source-id: a5bddddb1bb8672b61d4feaa04013a92c8224155
Summary:
Update reference to property in code comment in `RCTBridgeModule`. There is no such thing as `requiresMainThreadSetup` in the codebase. Its called `requiresMainQueueSetup` now.
Pull Request resolved: https://github.com/facebook/react-native/pull/22328
Differential Revision: D13115352
Pulled By: shergin
fbshipit-source-id: 511d627388b51029821c4b1ddf4caac30e573040
Summary: That's a temporary change that useful only while we don't have deeper/proper intergration with UIKit's navigation infra.
Reviewed By: mdvacca
Differential Revision: D13104172
fbshipit-source-id: 024e71e04470d56d2c5e9b3f6c3392555ce50b63
Summary:
Apparently, if a gesture recognizer got 'reset', OS does not call `touchesCancelled:` method, so we have to do it manually.
To implement this we have to split `_dispatchTouches:eventType:` into two methods: the first converts Objective-C touches to C++ touches, the second consumes that. We have to do this because during reset we don't have a collection of UIKit touches.
Reviewed By: mdvacca
Differential Revision: D13072807
fbshipit-source-id: 677e2febf9f96dcdfaadfadf5b9ab3893f93e796
Summary: Every C++ engineer (except me several months ago) knows that `operator []` can mutate the collection (Yeah! Don't ask), so this is especially dangerous if your hash function is broken (see the previous diff).
Reviewed By: mdvacca
Differential Revision: D13072805
fbshipit-source-id: 4436a8ff12fb27a57bfb6ee0ff986d7a9a825549
Summary:
Without this fix the PointerHasher hashed not a pointer, but an address where the pointer is stored, which is obviously incorrect.
The incorrect hash function compromised the whole `_activeTouches` caused many issues with logically invalid invariants (e.g. removing element from the collection silently didn't work).
Reviewed By: mdvacca
Differential Revision: D13072804
fbshipit-source-id: d68289e940fe21e2df08a31439619b7e2fe0fa13
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/22316
Pull Request resolved: https://github.com/facebook/react-native/pull/22315
In order for TLS Mutual Auth to work for webviews, the caller must present a credential. Expose a setter that can be called to set a credential.
Reviewed By: RSNara
Differential Revision: D13095969
fbshipit-source-id: d136556a0030f799651d574b6e47ce38295b108e
Summary:
Now, Objective-C part of RN is in `xplat` directory, so global Objective-C clang-format does not affect that.
Explicit clang-format is also useful for external contributors who don't have access to the rest of monorepo.
The actual rules are copy-paste from ReactCommon folder with small changes (like 120 characters max line length) that conform to regular Facebook code style and which make sense only for Objective-C.
Reviewed By: fkgozali
Differential Revision: D13093150
fbshipit-source-id: 79d64b4fba6eeb94e9b8d87ef9c3f86b3a5ed94e
Summary:
Some module classes may not be loaded yet, so looking up via classes may not always give the correct instance. This diff added a new lookup method that delegate to the bridge delegate to force load the modules as needed.
The existing moduleForName: method was left untouched because it's solely used by RCTUIManager at the moment.
Reviewed By: dshahidehpour
Differential Revision: D13033876
fbshipit-source-id: 4082fcd68498004f678b4b95adc82b5b134fefdf
Summary: This diff changes the behavior of the Scheduler.schedulerDidRequestPreliminaryViewAllocation to avoid pre-allocating views that are non-layoutables
Reviewed By: shergin
Differential Revision: D12962008
fbshipit-source-id: cb2670beafdcbd2116fbdaf2dc5d1b4726330ec2
Summary: We are moving to more stable APIs removing all mentiones of the effort name from the codebase.
Reviewed By: mdvacca
Differential Revision: D12912894
fbshipit-source-id: 4a0c6b9e7454b8b14e62d419e9e9311dc0c56e7a
Summary:
D12911108 fixed a UBN race condition by adding a flag for module registry.
This flag was never reset if react instance gets reset, causing an assert to fire in IG.
Reviewed By: fkgozali
Differential Revision: D13010651
fbshipit-source-id: e20453f3c546d759a58fd7fb93553f774410905f
Summary: Depending on when Chrome debugger is attached, modules may get double registered. Simply ignore it for this case. The redbox was not a fatal error, which can be dismissed.
Reviewed By: shergin
Differential Revision: D12996107
fbshipit-source-id: 292f63102337077848842ca46b3daed08b1cae12
Summary:
it's possible that moduleForName won't return anything, so we should return.
Created from Diffusion's 'Open in Editor' feature.
Reviewed By: spredolac
Differential Revision: D12963342
fbshipit-source-id: c059595a68bfcaa38221e05fb62d70cc29887ca7
Summary:
It does not supported on Android and nobody uses it.
I could find only one use cases: Very old versin of `SectionList` library (4 years ago).
Reviewed By: sahrens
Differential Revision: D12972361
fbshipit-source-id: a5dfef5e877e996adec2d4941417b4a2e727cfb7
Summary: This diff exposes rootTag as part of SchedulerDelegate.schedulerDidRequestPreliminaryViewAllocation(). This will be necessary to be able to pool views per Surface in Android
Reviewed By: shergin
Differential Revision: D12875656
fbshipit-source-id: d2a8c1f9bcc6b14c17b34bf59085da44ae3c3416
Summary: Before lazily-loading code existed, modules that were already loaded into memory took precedent over modules that were additionally registered. With lazily loading modules, instead of giving eagerly loaded modules precdence, it throws a redbox. This diff fixes that behavior.
Reviewed By: PeteTheHeat
Differential Revision: D12983805
fbshipit-source-id: fe4fcf35d5c2ca6f9f4e3f0d1d8c2ca35468fb1b
Summary:
Previously, asking for an instance of NativeModule from the native side gave `nil` if the lazy modules have not been loaded, which is not consistent with the access from JS. This at least attempts to force load the lazy modules when asked from native.
p.s. one asks for a module by doing `[bridge moduleForClass:[FooBar class]]`.
Reviewed By: spredolac
Differential Revision: D12931640
fbshipit-source-id: 15d2dc574067d3386ef921512ce4bc837749dabd
Summary: Trivial. We don't use it anymore.
Reviewed By: mdvacca
Differential Revision: D12876743
fbshipit-source-id: dc979aaea1fef443b8caf2e58d44b0c7aad90246
Summary:
We double down on JSI in Fabric. So, practically, JSI is now a hard dependency for Fabric. I hope it's for good.
Now `jsi::Runtime` is coupled with scheduling via `EventExecuter`, so we have to make `jsi::Runtime` a part of `EventBeat` to proxy runtime reference to bindgings.
Reviewed By: sahrens
Differential Revision: D12837225
fbshipit-source-id: 98edc33d6a3358e6c2905f2f03ce0004a9ca0503
Summary: Now we use RuntimeExecutor instead of MessageQueue; that's more clear and remove a dependency from Bridge.
Reviewed By: sahrens
Differential Revision: D12837226
fbshipit-source-id: 0ea3782ce2f49c7f3a91425880863e3b3ea37712
Summary:
It works great on iOS, and mostly works on Android, and is now OTA'able as part of the screen config! Haven't done template view yet. One remaining issue:
Layout is borked on Android. I'm guessing the issue has to do with the timing of setting the constraints in `updateRootLayoutSpecs` and calling `mBinding.startSurface` which actually builds the shadow tree. If I try to call `updateRootLayoutSpecs` earlier, it just crashes immediately. Here's the layout it spits out, which clearly has -440 for the x of 420006, which is the RCTText component, causing it to get cut off on the left of the screen:
```
updateLayoutMountItem for reactTag: 420006 x: -440, y: -13, width: 931, height: 78
updateLayoutMountItem for reactTag: 420010 x: 26, y: 79, width: 0, height: 1651
updateLayoutMountItem for reactTag: 420012 x: 0, y: 26, width: 0, height: 158
updateLayoutMountItem for reactTag: 420016 x: 0, y: 210, width: 454, height: 454
updateLayoutMountItem for reactTag: 420018 x: 454, y: 210, width: 455, height: 454
updateLayoutMountItem for reactTag: 420022 x: 0, y: 690, width: 454, height: 454
updateLayoutMountItem for reactTag: 420024 x: 454, y: 690, width: 455, height: 454
updateLayoutMountItem for reactTag: 420028 x: 0, y: 1171, width: 454, height: 454
updateLayoutMountItem for reactTag: 420030 x: 454, y: 1171, width: 455, height: 454
updateLayoutMountItem for reactTag: 420032 x: 0, y: 1651, width: 0, height: 0
```
Reviewed By: mdvacca
Differential Revision: D12813192
fbshipit-source-id: 450d646af4883ff25184141721351da67b091b7c
Summary:
D12904277 was my sad, optimistic attempt to fix this crash.
As @[100006577537606:Slobodan] mentioned on T35879909, the real issue is that moduleRegistry is being created (using _moduleDataByID dict) concurrently while we try to append to this dict.
I added locks around these usage of _moduleDataByID.
Reviewed By: fkgozali
Differential Revision: D12911108
fbshipit-source-id: 2435b7a477c27585898f351c4a0d4c1bd4056756
Summary:
T35879909 is a UBN caused by a race condition in RN initialization. I haven't been able to repro, but the crash logs point to a bad memory access in this method. Another thread must be deallocating something concurrently.
This is a quick fix to patch into v197.
Reviewed By: fkgozali
Differential Revision: D12904277
fbshipit-source-id: 5740183f9a7c8f2c45ca627662891cb0c1048764
Summary:
@public
This allows apps to specify custom lazy modules that they need to load during chrome debugging. This is because lazy modules won't be available on start up, hence these modules will be missing in JS land, causing problems.
Reviewed By: shergin
Differential Revision: D12899408
fbshipit-source-id: dca313648e994b22e3ee5afec856ef76470065f9
Summary: Simply changing RCTLogWarn() to RCTLogInfo(), since some modules can be loaded without explicit export (experimental).
Reviewed By: mdvacca
Differential Revision: D12899442
fbshipit-source-id: 524d345265eda4a601101d878d51c244a8441fb5
Summary: Adds copyright headers to all files that are missing them.
Reviewed By: hramos
Differential Revision: D12837494
fbshipit-source-id: 6330a18919676dec9ff2c03b7c9329ed9127d930
Summary:
Fix the lazily LaodedView to avoid weird naming issues
This makes more sense. i would like to not have this suffix Manager at all in play, but it is possible that some of the names should be tweaked for that. Since TurboModule is coming we should probably not invest in that removal.
Reviewed By: dshahidehpour
Differential Revision: D12831482
fbshipit-source-id: 1cc557cf0bdfaca35032f75823b2facb778dc3ac