Summary:
Fix flow type platform ios get version
## Changelog
[INTERNAL] [FIXED] - Fix flow type platform ios get version
## Test Plan
Pull Request resolved: https://github.com/facebook/react-native/pull/26639
Differential Revision: D17743074
Pulled By: TheSavior
fbshipit-source-id: de97c612dbf615a8ede1905cb158f258c9ce5737
Summary:
ComponentDescriptor owns a coordinator which is initialised with ViewManager that it represents.
Coordinator is passed to ComponentView through state and ComponentView asks the coordinator for view.
Later, ComponentView will ask coordinator to configure view with specified props.
Reviewed By: shergin
Differential Revision: D17670444
fbshipit-source-id: e920c5c4f033884c4b539ce711286f71c887d896
Summary:
# LegacyViewManagerInterop is born
LegacyViewManagerInterop is a component that should make it possible for legacy components to work in Fabric, new renderer.
This is just a first stage that prints keys of props to screen together with component name.
Reviewed By: shergin
Differential Revision: D17552827
fbshipit-source-id: c3e062f413727729e6a9b683c60f59f0292cc63b
Summary:
Fabric expects the measure method to return the size in density-independent pixels, but getMeasuredWidth and getMeasuredHeight return pixels on Android, so we have to convert these values before returning to C++.
Check the method createUpdateLayoutMountItem in Binding.cpp:
```
local_ref<JMountItem::javaobject> createUpdateLayoutMountItem(
const jni::global_ref<jobject> &javaUIManager,
const ShadowViewMutation &mutation) {
...
int x = round(frame.origin.x * pointScaleFactor);
int y = round(frame.origin.y * pointScaleFactor);
int w = round(frame.size.width * pointScaleFactor);
int h = round(frame.size.height * pointScaleFactor);
auto layoutDirection = toInt(newChildShadowView.layoutMetrics.layoutDirection);
return updateLayoutInstruction(
javaUIManager, newChildShadowView.tag, x, y, w, h, layoutDirection);
}
return nullptr;
}
```
We are interested in the next two lines:
```
int w = round(frame.size.width * pointScaleFactor);
int h = round(frame.size.height * pointScaleFactor);
```
`frame.size.width` and `frame.size.height` are the values returned from the measure method in Java and they are multiplied by the screen density to get the size in pixels, which means Fabric expects these values to be DIPs.
Reviewed By: shergin
Differential Revision: D17626834
fbshipit-source-id: f9856b5d0796c75c26c84adf11e1652b22a1ddef
Summary:
We use `ViewManager.onMeasure` to perform measurements of Android views and pass the measured size back to Yoga. For Android in order to the report correct dimensions of a View, this View must be created using a Context that has a theme associated with it. Before, `onMeasure` only had ReactApplicationContext passed as the first parameter and ReactSwitch, for example, could not be measured correctly (because it uses the size of the thumb drawable, which is extracted from the current theme). This diff adds surfaceId as the first parameter of `FabricUIManager.measure`, so that we can retrieve ThemedReactContext and pass it to `ViewManager.onMeasure`.
The size of the Switch component is still incorrect, but at least the size reported back to Yoga is the same as in Paper. So there is more investigation necessary why this happens in Fabric. I will investigate and publish another diff with the fix.
Reviewed By: JoshuaGross, shergin
Differential Revision: D17625959
fbshipit-source-id: 48197a61240fb13042bef3e9f5d681acacc702fb
Summary:
In this diff we integrate the Switch component on Android in Fabric. Since the component has a custom measure function, we need to write some C++ to call the measure method in Java.
The component isn't fully functional yet (setNativeProps isn't supported in Fabric) and has some problems with measuring itself. I will fix the component in the next diffs in this stack.
Reviewed By: JoshuaGross
Differential Revision: D17571258
fbshipit-source-id: be4e201495b9b197ddec44ee3484357bfb6225a8
Summary: This adds the option to enable or disable the redbox.
Reviewed By: JoshuaGross
Differential Revision: D17720770
fbshipit-source-id: b9e9c948d53f7f284a48b6bd182dc2da47874d1c
Summary:
This changes RCTLog to look for RCTRedBox at runtime and if so, send a log message to it.
This allows people to add their own redbox customizations that could be present at non-debug time.
Reviewed By: PeteTheHeat
Differential Revision: D17718913
fbshipit-source-id: e4545e112af2ff2ad197a0a82551ae4c6911ece9
Summary:
[iOS] [Added] - Add definition for `queryCache` in ImageLoader
This diff is related to moving RCTImageViewManager's commands to a native module, ImageLoader.
Reviewed By: zackargyle, TheSavior
Differential Revision: D17714521
fbshipit-source-id: 722cc17a2ebb03e72d7c080dfc4d0aa6d7440e85
Summary:
[iOS] [Added] - Add `prefetchImage` to ImageLoader native module.
This diff is related to moving RCTImageViewManager's commands to a native module, ImageLoader.
Reviewed By: zackargyle, TheSavior
Differential Revision: D17714519
fbshipit-source-id: 0a50f640cf0c5668a11dd5d40553c257ebbd9d2b
Summary:
Define getSizeWithHeaders in ImageLoader native module.
This diff is related to moving RCTImageViewManager's commands to a native module, ImageLoader.
See it's usage here: D17704091
Reviewed By: TheSavior
Differential Revision: D17693907
fbshipit-source-id: 3c2d7b19ac68ead831e780c4ee23e3ed0643be3a
Summary: I was trying to debug an issue with a method signature mismatch last week, but was having trouble figuring out the problem because the error I was getting was unrelated - apparently JNI will sometimes swallow the error and just fail mysteriously later on. Ramanpreet showed me this macro that will throw any pending exceptions, so let's do that after we try to lookup the Java method in case it fails.
Reviewed By: RSNara
Differential Revision: D17680121
fbshipit-source-id: 1f23e49014f7cc1616e111386d440637e6a74677
Summary:
We are seeing these errors in prod:
```
TypeError: Cannot read property '_nativeTag' of null
at
ReactNativeFiberHostComponent.prototype.measureLayout(ReactNativeRenderer-prod.fb.js:1594)
ScrollResponderMixin.scrollResponderScrollNativeHandleToKeyboard(ScrollResponder.js:557)
```
This error is coming from these lines: 69c38e5a63/Libraries/Components/ScrollResponder.js (L563-L567)
Either `nodeHandle` is null or `this.getInnerViewRef()`. If `nodeHandle` was null, we'd get an error that we can't call `measureLayout` on null. So `this.getInnerViewRef()` must be null.
In the React Native Renderer this error of `_nativeTag of null` is coming from this line: db8afe4f63/packages/react-native-renderer/src/ReactNativeFiberHostComponent.js (L84)
Which means indeed `this.getInnerViewRef()` is null.
So adding a null check here which is what we do at all the other product callsites of `measureLayout`. Flow should have caught this, but because ScrollView is one of the only components left using mixins (ScrollResponder), `this.getInnerViewRef` is typed as `any` instead of what it should be:
```
?React.ElementRef<Class<ReactNative.NativeComponent<mixed>>>
```
If `scrollResponder` was typed correctly then Flow would have caught this.
Changelog:
[Fixed] Exception in scrollResponderScrollNativeHandleToKeyboard when ref is null
Reviewed By: mmmulani
Differential Revision: D17717150
fbshipit-source-id: d7bc4c897ad259fb588e8100f37ccfb8a5d07874
Summary: Previously, I introduced methods to convert `facebook::react::LazyVector<T>` to `NSArray*`, but I realized that there are already methods available in `RCTConvertHelpers` that do this for us. So, I'm switching over to using those methods instead.
Reviewed By: fkgozali
Differential Revision: D17716914
fbshipit-source-id: e1ef7636e36b594bc558d7025573082bd2bccab9
Summary:
When converting an array into a Vec, we should also check whether the array pointer is `kCFNull`.
In TurboModules, when an object's property is mapped to null, we simply do not insert that property into the corresponding `NSDictionary`. This causes the `NSDictionary` lookup to return `nil`. In the legacy infra, it looks like we may insert `kCFNull` into the `NSDictionary`, which will cause the lookup to return `kCFNull`.
Reviewed By: fkgozali
Differential Revision: D17716785
fbshipit-source-id: 62ffbe14aec7040edd6b3ce687769a285b14b5a1
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/26623
I noticed the min version was 10. It is actually 9 if we consider users with developer option turned on.
Changelog:
[Android][Fixed] - Updated Appearance module to allow Android 9/P devices.
Differential Revision: D17632656
fbshipit-source-id: 893699ae37ab1cef64fe2547e0f2d6858bf3c48c
Summary:
[iOS] [Fixed] - Fix how the amount of free memory is calculated to mimic the logic Apple uses.
For example, see https://opensource.apple.com/source/system_cmds/system_cmds-805.250.2/vm_stat.tproj/vm_stat.c.auto.html for how `vm_stat` does it:
```
sspstat("Pages free:", (uint64_t) (vm_stat.free_count - vm_stat.speculative_count));
```
Reviewed By: shergin
Differential Revision: D17671714
fbshipit-source-id: 18ef31e17a0527a9bef7a408922cd687260866db
Summary: This diff fixes the issue with view paddings in Fabric introduced in D17081799. In Paper setting padding on a view was only supported for Text and TextInput components (see https://fburl.com/codesearch/6r6lu5vd). We want to keep Fabric backwards compatible, so we delegate setting the padding to the view manager instead of setting it directly on the view. In this way we can have a no-op implementation in the base view manager and implement this method only in view managers that support setting padding (ReactTextInputManager and ReactTextViewManager at the moment).
Reviewed By: JoshuaGross
Differential Revision: D17665011
fbshipit-source-id: 38bc56278e002bd34881cfcb9ed79df579f79e28
Summary:
Aside from RCTCameraRollManager, this diff makes the following NativeModules TurboModule-compatible:
- RCTAssetsLibraryRequestHandler
- RCTImagePickerManager
- RCTPhotoLibraryImageLoader
I couldn't convert CameraRollManager to a TurboModule because its NativeMoudle spec is located in fb-internal code. We should probably just move all these NativeModules outside of react-native-github. See: T54882565.
Reviewed By: PeteTheHeat
Differential Revision: D17678033
fbshipit-source-id: 4d10b7b1ad4e167bb9e46ff2bfd1559a5092e201
Summary:
Some NativeModules belong to their own buck target (separate from `ReactInternal`). We shouldn't move those NativeModules to `CoreModuels`, because that would unnecessarily bloat `CoreModules`.
In this diff, I extended the `update-plugins.js` script to also generate plugin stubs for those additional targets. This way, we can convert those NativeModules to TurboModules without moving them to CoreModules.
Now, in `update-plugins.js`, we have this array:
```
const libraries = [
{
name: 'CoreModules',
outputFiles: {
ios: ['CoreModulesPlugins.h', 'CoreModulesPlugins.mm'],
android: [],
},
outputPath: {
ios: `${GITHUB_DIR}/React/CoreModules`,
android: '',
},
},
];
```
To codegen another pair of plugin files for another target, simply insert to this array.
**Note:** We'll have to modify RNTesterTurboModuleProvider, but I can take care of that when I setup RNTester for TurboModules.
Reviewed By: fkgozali
Differential Revision: D17671288
fbshipit-source-id: 412d2e730682f82740241506f241dcfb4d302e99
Summary:
Because of the changes made in Fabric, the order of the execution of some methods in ViewManager has changed. In Paper the following order was guaranteed: `createViewInstance -> addEventEmitters -> updateProperties -> onAfterUpdateTransaction`. But in Fabric, the order is the following: `createViewInstance -> updateProperties -> onAfterUpdateTransaction -> addEventEmitters`. This change can actually break some existing view managers, because they rely on the fact that `addEventEmitters` will be called before `onAfterUpdateTransaction`. Check ReactVideoManager:
```
ReactModule(name = ReactVideoManager.REACT_CLASS)
public class ReactVideoManager extends SimpleViewManager<ReactVideoPlayer>
implements VideoManagerInterface<ReactVideoPlayer> {
...
Override
protected void onAfterUpdateTransaction(ReactVideoPlayer view) {
super.onAfterUpdateTransaction(view);
view.commitChanges();
}
Override
protected void addEventEmitters(
final ThemedReactContext reactContext, final ReactVideoPlayer view) {
view.setStateChangedListener(
new ReactVideoPlayer.PlayerStateChangedListener() {
...
}
```
As you can see there is a state change listener registered in `addEventEmitters` and `view.commitChanges()` can actually cause a state change. It means that if `onAfterUpdateTransaction` is executed before `addEventEmitters`, the state change listener will be added after a state change has happened and the event will be missed.
Reviewed By: JoshuaGross
Differential Revision: D17600308
fbshipit-source-id: 044e09e0d64973c8237876311d37c057a1ba384e
Summary: This diff makes the Video component compatible with Fabric on Android.
Reviewed By: JoshuaGross
Differential Revision: D17450815
fbshipit-source-id: 5e47d8cdca96f9fbe72902bac7dd157f7b5fdb1a
Summary: Converting the SourceCode native module to TurboModules. Checking in the Java class generated from the JS spec and extending it in the module implementation.
Reviewed By: fkgozali
Differential Revision: D17586276
fbshipit-source-id: 3d2080f1280791e81a0366d0aab101d960d11157
Summary: Until ComponentDescriptorProviderRequest is not fully implemented we need to disable the assert because it enforces constraints that we don't satisfy yet.
Reviewed By: JoshuaGross
Differential Revision: D17677856
fbshipit-source-id: bdf96a04a16981f1c639f646f254e8f3dd799419
Summary: RCTActionSheetManager is now hooked up to the NativeModule codegen. It's also TurboModule-compatible.
Reviewed By: PeteTheHeat
Differential Revision: D16966007
fbshipit-source-id: 8fdd32cf9fa09ccda9f38513bb0ac9896f8af1b0
Summary: Moves the reason to a constant because APPARENTLY this is a best practice in this establishment
Reviewed By: sammy-SC
Differential Revision: D17627819
fbshipit-source-id: 328fad8b7482d0e379a41b5f8c841f71db2bb5ac
Summary: Report fast refreshes to the native module that handles reporting
Reviewed By: cpojer
Differential Revision: D17528523
fbshipit-source-id: 6f8a0b72a18c2d08ab160dc8b6621fce5420a473
Summary: This diff adds a method to call whenever a fast refresh happens. Right now this is only useful for reporting.
Reviewed By: cpojer
Differential Revision: D17528033
fbshipit-source-id: 17e82abe7a3e2bab6829de5adecda853fe5335c5
Summary: This diff adds reload reasons to Fast Refresh. This will help us understand why, for internal Facebook users, Fast Refresh is bailing out to a full reload so that we can improve it for everyone.
Reviewed By: cpojer
Differential Revision: D17499348
fbshipit-source-id: b6e73dc3f396c8531a0872f5572a13928450bb3b
Summary:
This diff adds reloadWithReason to the NativeDevSettings and updates the exposed DevSettings.reload method to send to it if it's available (setting an 'uncategorized' reason if one isn't set.
[General][Feature] Update DevSettings.reload to accept a reason
Reviewed By: RSNara
Differential Revision: D17499343
fbshipit-source-id: e8c9724800f93d3b9a5d2a8fe9f689d51947d39b
Summary:
This diff adds a new reloading method reloadWithReason that allows callers to provide a reason for why a reload was requested.
This reason is useful for understanding why users are reloading, and why Fast Refresh is bailing out to a full reload. I also updated the places we reload with the reasons listed below.
**Standard native reasons:**
- Redbox
- Command
- Global hotkey
- Profiling controls
- Dev menu - reload
- Dev menu - reset to default
- Dev menu - apply changes
**From JavaScript (added in a later diff):**
- Fast Refresh - Unrecoverable
- Fast Refresh - No root boundary
- Fast Refresh - Invalidated boundary
- Fast Refresh - Invalidated root boundary
**Misc reasons and fallback for when a reason is unavailable:**
- Unknown from JS
- Uncategorized from JS
- Unknown from bridge
- Unknown from cxx bridge
- Requested from bridge
- Custom executor class reset
Reviewed By: cpojer
Differential Revision: D17499339
fbshipit-source-id: 12a21ffa05708c9b921d93911f190cdffc5c78d5
Summary: `_state` should be cleaned up in `prepareForRecycle` as this could potentially cause undesired initial render of the component.
Reviewed By: shergin
Differential Revision: D17628152
fbshipit-source-id: 0116954ab7a5b2f17099db6d9ec47c8568cae8b0
Summary: This diff fixes the height of the Slider component in Fabric on Android. Note that the layout is still broken (no padding and the seek bar is misaligned, but it's another issue).
Reviewed By: JoshuaGross
Differential Revision: D17629798
fbshipit-source-id: af8cae909279dc92ee1c80b9be2f5c578972eafc
Summary: This diff implements the core functionality of "reactive component registration". With a new API now we have a public API that allows registering a component by request on-demand. That can be helpful in some environments where loading of all components is undesirable or impossible due to generic app design constrains.
Reviewed By: mdvacca
Differential Revision: D17211914
fbshipit-source-id: 5a957a4f6541420d70952856599b827ceec63e3b
Summary:
Currently, the same ComponentDescriptor class cannot be registered as a responder for components with different names. However, we have marginal cases where we really need it. The examples are `UnimplementedView` or possible universal interop with the classic RN or any other UI framework.
This change adds a special optional argument to ComponentDescript constructor that allows implementing this functionality.
Reviewed By: fkgozali
Differential Revision: D17211915
fbshipit-source-id: 18f59e09fe06b875a8e8975b7b2ab423489238bb
Summary:
This part of the codebase is very perf sensitive and designed to work without exceptions enabled.
Most of the method was `noexcept` all the time, but some of those missing that by mistake.
Reviewed By: sammy-SC
Differential Revision: D17629426
fbshipit-source-id: b311e4b7eff8e2b7cf29518288480d3a812dda44
Summary:
When sliders are adjusted via accessibility, no onSlidingComplete callback is
generated. This causes problems for components which perform behavior in this
callback, and means that such components don't behave properly when adjusted via
accessibility. For example, if an app hosting a volume control slider only commits the volume change to the hardware on onSlidingComplete, it is impossible for a screen reader user to ever actually adjust the volume.
Ensure that sliders call the onSlidingComplete callback after adjusted via
accessibility.
## Changelog
[General] [Fix] - Add onSlidingComplete callbacks when sliders adjusted via a11y.
[CATEGORY] [TYPE] - Message
Pull Request resolved: https://github.com/facebook/react-native/pull/26600
Test Plan: Prior to this change, using the RNTester slider example with a screen reader, the onSlidingComplete callback tests never shows any callbacks when the slider is adjusted. With this change applied, the callback test will show a number of callbacks corresponding to the number of times the slider was adjusted via the screen reader.
Differential Revision: D17661157
Pulled By: cpojer
fbshipit-source-id: a6eedef099c6c1b571b290c329059ac9b69b53dd
Summary:
## Motivation
I have seen a spike in users reporting this error. Unfortunately I did not receive any repros that would confirm this, but my hypothesis is that they ran into situation when `new XYZPackage()` was present in `getPackages()` method and then the CLI kicked in with autolinking and they were left with this incomplete error.
someone more knowledgeable of autolinking should review this.
Pull Request resolved: https://github.com/facebook/react-native/pull/26467
Differential Revision: D17661242
Pulled By: cpojer
fbshipit-source-id: 63dfcd85a0d41d85a0dd52f84ab16cb7ceb64ba2