Summary:
X-link: https://github.com/facebook/yoga/pull/1294
Pull Request resolved: https://github.com/facebook/react-native/pull/37383
Add -Wextra to the build, and fixup some more instances of -Wunused-parameter that it sufaces which were not automatically fixable.
Reviewed By: javache
Differential Revision: D45772846
fbshipit-source-id: 29bf71006f63161521fe5869c3a7d8bf7aae9c81
Summary:
X-link: https://github.com/facebook/yoga/pull/1291
Pull Request resolved: https://github.com/facebook/react-native/pull/37371
This makes React Native use `libyogacore` as provided by Yoga's reference CMake build. This in turn matches Yoga in the OSS RN build to the same compilation settings we use internally. It also means less differences between all the builds (maintainability win).
This does not yet do the same for the Yoga JNI bindings.
Changelog:
[Android][Changed] - Use reference Yoga CMake Build
Reviewed By: cortinico
Differential Revision: D45764537
fbshipit-source-id: 1aafd221d2afa994b6efae3c267ee7ffbdf0faad
Summary:
> The `buildPropSchema` function in `parsers/typescript/components/props.js` and `parsers/flow/components/props.js` is the same. move it to `parser-commons` and use it in the original files.
part of https://github.com/facebook/react-native/issues/34872
- [x] Make the getTypeAnnotation signature from the Flow package to be equal to the typescript one. Specifically, the Typescript one needs an additional parameter withNullDefault that we can safely ignore in the implementation.
- [x] buildPropSchema signature can be updated to accept those two functions in input as callbacks. Then, the getProps function can feed the right functions based on the language to the shared build prop schema.
ref: https://github.com/facebook/react-native/issues/34872#issuecomment-1517519254
bypass-github-export-checks
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Use `buildPropSchema` from parser-commons
Pull Request resolved: https://github.com/facebook/react-native/pull/37043
Test Plan: - [ ] `yarn jest react-native-codegen` pass
Reviewed By: rshest
Differential Revision: D45209982
Pulled By: cipolleschi
fbshipit-source-id: c241bc0542ba662c965d70d1dc283f48541e14ea
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37375
Adds internal helpers to YGConfig to make bit manipulation more readable. We also expose `hasErrata()` to YGNode beacuse checking that will be a common pattern. We intentionally don't add mutating functions to the node, since current model is to inval a node on commiting whole config.
This is not exposed via the C ABI.
Reviewed By: yungsters
Differential Revision: D45765971
fbshipit-source-id: eadaee4b9cf5204ac4984ecc52cc08650d144a30
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37372
For usage in shelling into the reference build. I separately looked at moving `cmake` to be inline inside of `yoga`, but this ends up having a worse structure than being at the top level.
I also cleaned up the dirsync naming to be more easy to understand.
Changelog: [Internal]
Reviewed By: yungsters
Differential Revision: D45764337
fbshipit-source-id: f810db5d6acc7c4c92003beb2ac3399bd78b9886
Summary:
This adds script to better work with RN Tester from the root of the repo.
- `yarn start` is broken as of today
- `yarn android` is not working fine and I've adapter it here.
This should make easier to work with RN Tester from within the Repo.
Changelog:
[Internal] [Changed] - Add scripts to `yarn start` and `yarn android` from root
Reviewed By: mdvacca, cipolleschi
Differential Revision: D45735926
fbshipit-source-id: eaebf80b8819ee42ccb9c14b67f8945167bf05e6
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37243
X-link: https://github.com/facebook/litho/pull/944
X-link: https://github.com/facebook/yoga/pull/1279
Java bindings for Yoga rely solely on garbage collection for memory management. Each Java `YogaNode` has references to its children and parent Java Nodes. This means, for a node to be garbage collected, it cannot be reachable from any user accessible node. Each node then has single ownership of a `YGNodeRef`. When the `YogaNode` is garbage collected, a finalizer is run to call `YGNodeFree` and free the underlying native Yoga Node.
This may cause a use-after-free if finalizers are run from multiple threads. This is because `YGNodeFree` does more than just freeing, but instead also interacts with its parent and children nodes to detach itself, and remove any dangling pointers. If multiple threads run finalizers at once, one may traverse and try to mutate a node which another is freeing.
Because we know the entire connected tree is dead, there is no need to remove dangling pointers, so I want to expose a way to just free a Yoga Node, without it mutating the tree as a side effect.
This adds a currently private `YGNodeDeallocate` that frees without traversal. Ideally from naming this is what `YGNodeFree` would do, but we think changing the behavior of that might be too disruptive to OSS. At the same time there may be other memory safety related API changes we would like to eventually make, so this isn't made public beyond the JNI bindings to prevent needing to transition more APIs.
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D45556206
fbshipit-source-id: 62a1394c6f6bdc2b437b388098ea362a0fbcd0f7
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37368
## Changes
This diff hooks up global.nativeModuleProxy to the TurboModule interop layer.
Now, when you call NativeModules.Foo, the TurboModule system will create the Foo legacy module, and return it to JavaScript.
## Example
global.nativeModuleProxy.Foo:
- ObjC++: Use RCTTurboModuleManager to create the ObjC legacy module for Foo
- C++: Use the ObjC legacy modules to create and return a ObjCInteropTurboModule object to JavaScript.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D45243456
fbshipit-source-id: 14748b5efd73b95bbdddf28a4f7ed2a8e80e0788
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37364
When the TurboModule interop layer is enabled, it should create modules that conform to RCTBridgeModule (i.e: legacy and turbo modules).
When the TurboModule interop layer is disabled, it should only create modules that conform to RCTTurboModule (i.e: turbo modules).
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D45706884
fbshipit-source-id: be6f054556d1506e2934884ab5014394f0c08e8f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37347
This fixes the file-structure of `eslint-config-react-native-communtiy`, and `eslint-plugin-react-native-communtiy` to match the name they were renamed to as part of 0.72.
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D45721173
fbshipit-source-id: 7ad784dbf56fb4cd05d7dba608e6d5064392e43d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37345
This moves from `tsconfig/react-native`, a centralized repository of tsconfigs, to `react-native/typescript-config`, a package maintained as part of the RN monorepo.
We end up wanting to make changes where the versions are coupled, so this publishes them as part of the same repo, etc. It also means Meta engineers can more freely make changes to it with normal approval processes.
Changelog:
[General][Added] - Add react-native/typescript-config
Reviewed By: cortinico
Differential Revision: D45721088
fbshipit-source-id: b949bffb14014695abf3b9b359d3f5e30bfc8919
Summary:
Adds changelog for new patch.
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - add changelog entry for 0.71.8
Pull Request resolved: https://github.com/facebook/react-native/pull/37354
Test Plan: N/A
Reviewed By: lunaleaps
Differential Revision: D45733332
Pulled By: cipolleschi
fbshipit-source-id: 0505378aef165f66361f6fc21128fa85f0ef5e32
Summary:
Just a small upgrade to keep us current and remove unused suppressions
(probably fixed by some upgrade since).
- `*` is no longer allowed and has been an alias for `any` for a while
now.
DiffTrain build for commit https://github.com/facebook/react/commit/fda1f0b902b527089fe5ae7b3aa573c633166ec9.
Changelog: [Internal]
Reviewed By: tyao1
Differential Revision: D45695294
Pulled By: kassens
fbshipit-source-id: 1090328c30faf5ca8c22744f0b25ddf7fa60cd93
Summary:
Hi 👋
During the [react-native-bootsplash](https://github.com/zoontek/react-native-bootsplash) implementation of the new architecture, I noticed a few thing regarding `RCTRootView` / `RCTFabricSurfaceHostingProxyRootView` compat.
Currently `RCTRootView` inherits from `UIView`, but `RCTFabricSurfaceHostingProxyRootView` does not, which this works:
```obj-c
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName
initProps:(NSDictionary *)initProps {
RCTRootView *rootView = (RCTRootView *)
[super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil];
UIView *loadingView = [[storyboard instantiateInitialViewController] view];
loadingView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
loadingView.frame = rootView.bounds;
loadingView.center = (CGPoint){CGRectGetMidX(rootView.bounds), CGRectGetMidY(rootView.bounds)};
loadingView.hidden = NO;
[rootView addSubview:loadingView];
return rootView;
}
```
But this doesn't:
```obj-c
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName
initProps:(NSDictionary *)initProps {
RCTFabricSurfaceHostingProxyRootView *rootView = (RCTFabricSurfaceHostingProxyRootView *)
[super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil];
UIView *loadingView = [[storyboard instantiateInitialViewController] view];
loadingView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
loadingView.frame = rootView.bounds;
loadingView.center = (CGPoint){CGRectGetMidX(rootView.bounds), CGRectGetMidY(rootView.bounds)};
loadingView.hidden = NO;
[rootView addSubview:loadingView];
return rootView;
}
```
Because `RCTFabricSurfaceHostingProxyRootView` is an imperfect proxy as it doesn't give access to the underlaying `UIView *`. As a solution, I added a prop on both: `UIView *view`
PS: I'm well aware that `setLoadingView` also exists in both files, but it's currently not usable as the current `isActivityIndicatorViewVisible` / `isSurfaceViewVisible` / `_activityIndicatorViewFactory` logic in `RCTSurfaceHostingView.mm` doesn't work: a situation where `isActivityIndicatorViewVisible == true && isSurfaceViewVisible == false && _activityIndicatorViewFactory != nil` never happen:
<img width="1162" alt="Screenshot_2023-05-06_at_18 10 18" src="https://user-images.githubusercontent.com/1902323/236883439-2256ddfb-7846-482a-b957-002a7d51a148.png">
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
Pull Request resolved: https://github.com/facebook/react-native/pull/37310
Test Plan:
Add this block of code in `AppDelegate.mm`:
```obj-c
#import <React/RCTRootView.h>
#if __has_include(<React/RCTFabricSurfaceHostingProxyRootView.h>)
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
#endif
// …
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
moduleName:(NSString *)moduleName
initProps:(NSDictionary *)initProps {
#ifdef RCT_NEW_ARCH_ENABLED
RCTFabricSurfaceHostingProxyRootView *rootView = (RCTFabricSurfaceHostingProxyRootView *)
#else
RCTRootView *rootView = (RCTRootView *)
#endif
[super createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
// accessing the "real" root view on both arch
UIView *view = rootView.view;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"LaunchScreen" bundle:nil];
UIView *loadingView = [[storyboard instantiateInitialViewController] view];
loadingView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
loadingView.frame = view.bounds;
loadingView.center = (CGPoint){CGRectGetMidX(view.bounds), CGRectGetMidY(view.bounds)};
loadingView.hidden = NO;
[view addSubview:loadingView];
return rootView;
}
```
It should persist the splash screen on both old and new architecture.
Reviewed By: sammy-SC
Differential Revision: D45688644
Pulled By: cipolleschi
fbshipit-source-id: b6f2fc8091a15189ea2eceb8ea426593f62674cb
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37342
Upgrades to `flow-enums-runtime@0.0.6`, which is just a `README.md` update.
Changelog:
[Internal]
Differential Revision: D45713984
fbshipit-source-id: a458ccb099df53401fa41826f3571bca7e292dbf
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37326
Changelog: [Internal]
in this change, i introduced a block type that returns a `JSEngineInstance`. a block gives a bit more flexibility in terms of lazily loading the engine + its dependencies, but i might get rid of it later and just pass down the engine itself.
Reviewed By: javache
Differential Revision: D45678969
fbshipit-source-id: 52d3ec0de77a3ab74d3cf304ea22fb5fc1315a2e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37317
changelog: [internal]
This diff does three things:
1. Combines Android's mobile config `react_fabric:enable_text_measure_cache` with iOS mobile config `react_fabric:enable_nstextstorage_caching`. We will get into why later.
2. Fixes cache `ParagraphLayoutManager::cachedTextMeasurement_` invalidation logic for iOS and Android.
3. Fixes cache invalidation logic for `ParagraphLayoutManager::hostTextStorage_`.
Initially, Android's text measure cache (D44221170) and iOS's NSTextStorage (D43692171) were design as two separate optimisations. But they overlap and NSTextStorage actually needs some parts of text measure cache to work correctly. That's why I decided to merge them together.
Previously, `ParagraphLayoutManager::cachedTextMeasurement_` was only invalidated if maximum width for the node changed. But node can change in different ways, for example input string changes or attributes change. This diff accounts for that by computing a hash for AttributedString+ParagraphAttributes to check if anything has changed.
Previously, `ParagraphLayoutManager::hostTextStorage_` was not correctly invalidated if maximum width changed. To my surprise, this happens less frequently than one expects.
bypass-github-export-checks
Reviewed By: mdvacca
Differential Revision: D45637797
fbshipit-source-id: 1840b51cdb1423de0560a35fd17c24a71ad115e1
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37303
Intent of a change to the last diff was to make `PropsParserContext` act gracefully if it tried to parse "auto" without a `ReactNativeConfig` being set (e.g. if our tests wanted to do that).
We would actually assert if we tried to do that with what I added, since `ContextContainer::at()` acts like `at()` does in the STL containers and will expect the parameter to be in bounds/present. (`RawProps::at()` is the odd one out that will return `nullptr` instead).
This changes the usage to ContextContainer::find() which will return ` std::optional<std::shared_ptr>>`.
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D45651032
fbshipit-source-id: b1f16f9329ceb4ef7a6c469f968eae57a2fe3da5
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37337
Changelog: [Internal]
Removes usage of a local `Performance` instance, since this the global one is now safe to use.
Reviewed By: christophpurrer
Differential Revision: D45697243
fbshipit-source-id: 4f3f9798e79c15295094d5a4650af04db2856f60