Summary:
Currently `RCTBridgingToOptionalBool` and `RCTBridgingToOptionalDouble` will crash if passed an `NSNull` value. This diff changes these functions to instead treat it as equivalent to a missing value.
Changelog: [Internal]
Reviewed By: sammy-SC
Differential Revision: D18532044
fbshipit-source-id: fa822dcacb49697dd8a4f7b579bcfc029e0cdf41
Summary:
Removes the use of `parseErrorStack` in `_allocateCallback`, which was used to determine which timer API was allocating the callback (for Systrace purposes). Instead, we now use the already-existing `type` argument, which achieves the exact same thing but is much faster than parsing the stack trace.
Changelog: [General] [Fixed] - Reduce overhead of setting up timers in DEV
Reviewed By: yinghuitan
Differential Revision: D18233182
fbshipit-source-id: 190c0ffad8734cd889b790248e5a77cfb147454b
Summary:
We see crashes that happen in the destructor of `EventEmitterWrapper` class which indicates that `EventEmitter`s were not "disabled" before `Runtime` was deallocated. Assuming that `Scheduler` *was* deallocated before the `Runtime` (there is no proof for that), we can suppose that `stopSurface` was not called properly on time. Again, assuming that the moment of Scheduler deallocation is fine, we can try to recover from this situation by forced unmounting of all outstanding `ShadowTree` (that will make future destroying of EventEmitter don't crash).
Why do we believe that `Scheduler` *was* deallocated before `Runtime`?
We are not sure but that's possibly a case or that might be true for some portion of cases.
At least, we will know for sure what exactly went wrong. There is a possibility that all crashes that would happen after will happen exactly here.
And, frankly, from the probability standpoint, earlier we destroy JSI objects, lower chances are that it will be after the death of Runtime.
Changelog: [Internal] Fabric-specific internal change.
Reviewed By: sammy-SC
Differential Revision: D18465408
fbshipit-source-id: 76338ed6fce0621cf11ce3178b4d1be7e0c73ccf
Summary:
* Previously we called `onScrollEndDrag` in `scrollViewWillEndDragging` which was not correct.
* Now we also call `_updateStateWithContentOffset` in the method to update the stored in state `contentOffset`. This fixes all `measure*` infra.
Changelog: [Internal] Fabric-specific internal change.
Reviewed By: sammy-SC
Differential Revision: D18563050
fbshipit-source-id: ade696eda579642c22927c8a56ff122cd61a7534
Summary:
Changelog: [Internal]
For image loading, the loader may need to inspect the imageView itself, so let's pass its reactTag. This only works pre-Fabric.
Reviewed By: sammy-SC
Differential Revision: D18522073
fbshipit-source-id: 400fc7e04b8d7852f6ecef941dd446fbff423c88
Summary:
Changelog: [Internal]
The main use-case here is to get the rootTag off RCTImageView, for image loading instrumentation. The fact is, each RCTView subclass already has `reactTag` attached today. We already have the `rootTag` when the view is created by the UIManager, so why not just attach it like reactTag? If we don't, looking up the rootTag from the native component is non-trivial and extremely inefficient (have to jump to shadow queue, back to main queue, etc).
Reviewed By: sammy-SC
Differential Revision: D18497002
fbshipit-source-id: 8409e3a1c95e09accedd959592cbf178fab0b2c3
Summary:
Changelog: [Internal]
For attribution purpose, pass in the surfaceId and let the app-specific image loader handle it.
Reviewed By: shergin
Differential Revision: D18494106
fbshipit-source-id: e22ca339a2dd12c5bd619b596c7db9c49dc111d0
Summary:
Changelog: [iOS] [Changed] - New internal image attribution support, but files importing RCTImageLoader.h must be converted to ObjC++
This new interface is the same as RCTImageURLLoader, but with additional support to pass in optional attribution information. The attribution info is not strictly defined (we may do so in the future though), and it's up to the hosting application and RCTImageURLLoader classes to handle it.
Reviewed By: sammy-SC
Differential Revision: D18492882
fbshipit-source-id: c3870c60e6c2e7c65758fc3235ebf5db369e07dc
Summary:
Simple renaming. Now the name is aligned with `SchedulerDelegate::schedulerDidFinishTransaction` and actually expresses the idea that not only commit finished but also a transaction was prepared and layout events were sent.
Changelog: [Internal] Fabric-specific internal change.
Reviewed By: mdvacca
Differential Revision: D18542503
fbshipit-source-id: 54d429ed139383621fe926fa48a4de062f724176
Summary:
As soon as we have traits infra, it's pretty straight-forward to implement this kinda flag. Without the traits, it's challenging to build that in a performant and elegant way. The challenges of the dynamic_cast-involved approach are:
* How to check for that feature in YogaLayoutableShadowNode?
* Even if we use `dynamic_cast`, to which class to cast?
* We also need to do that in constructor... and dynamic_cast-like checks for `this` don't work in constructors (C++ design limitation).
* How to scale that if we have more classes like Paragraph (and we will have it for sure)?
* Performance.
* Relying on RTTI.
Changelog: [Internal] Fabric-specific internal change.
Reviewed By: sammy-SC
Differential Revision: D18525347
fbshipit-source-id: b1915f43ff3fe4364ab6345fb9d1becc591b5a35
Summary:
Quite often in the Fabric codebase, we need to iterate on a list of shadow nodes and perform some work depending on the exact type (or kind) of shadow node we have. Today, we exclusively use RTTI to test for exact type. The problem here is that RTTI is not only expensive in terms of code size (we are moving towards removing RTTI), it's expensive in terms of CPU cycles. (Don't mistake RTTI/dynamic_cast overhead with dynamic dispatch overhead!)
`dynamic_cast` has it's own advantages, of cource: it's simple and straight-forward and does not require additional configuration. On the other side, it requires knowledge about exact class relationship configuration and knowing the exact name of the class.
ShadowNodeTraits is the generalized solution for storing predefined traits right inside ShadowNode object and check/set/unset them efficiently and in a particular-class-independent manner.
This diff only implements it in general and switching storing an internal flag of ShadowNode inside the trait collection to save some space (and for illustration purposes as well).
In the coming diff, we will see how this approach allows tackling the real, non-trivial problem.
In addition to the concept, this diff implements some convenience infra, such as `ConcreteShadowNode::BaseTraits()` static method that allows designating intrinsic-to-a-class traits declaratively.
Changelog: [Internal] Fabric-specific internal change.
Reviewed By: sammy-SC
Differential Revision: D18525348
fbshipit-source-id: 083bb85e0a9dc9d6c69bf395bd338d3c18def688
Summary:
We read from / write to `CatalystInstanceImpl.mTurboModuleRegistry` from multiple threads. To ensure that we directly read/write from memory, and not a stale cache, we should make this variable `volatile`.
Changelog:
[Android][Fixed] Make TurboModuleRegistry in CatalystInstanceImpl.java volatile
Reviewed By: fkgozali
Differential Revision: D18542954
fbshipit-source-id: 0a47f05e0653b4f7f58503c678bdf31c68eab9bf
Summary:
This diff deprecates the constructors and getter method exposing CallerContext in ReactImageManager.
This will be replaced by the ReactCallerContextFactory class
Changelog: Deprecation of constructors and methods that expose CallerContext in ReactImageManager class
Reviewed By: JoshuaGross
Differential Revision: D18474012
fbshipit-source-id: d8190f938e00da0499bfef7e81522dc8022a8836
Summary:
This diff exposes the ReactContextContainerFactory class on ReactImageViewManager and it customize ChainContext to improve Fresco logging
Changelog: Expose new ReactContextContainerFactory class as part of ReactImageViewManager
Reviewed By: JoshuaGross
Differential Revision: D18474013
fbshipit-source-id: 143461da22966694e5b1e2c3b5b39e3d6be91fd6
Summary:
This diff exposes the surfaceID as part of ReactRootView.
Changelog: [internal]
Reviewed By: JoshuaGross
Differential Revision: D18474014
fbshipit-source-id: 98f651b211d3cc4df88c6b1eb257bc12129eff57
Summary:
Document which methods can be called on UI thread or ANY thread.
In the future we should see if we can use only `ThreadConfined` or the AndroidX annotations instead of using both / choosing between them at each site.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D18532542
fbshipit-source-id: 3b5406ea5035615a0ebf83484bf8ec0747a6b6f7
Summary:
TextInput now acts as a host component and can be passed directly to our new APIs that require a host component. Callsites no longer need to call
```
inputRef.getNativeRef()
```
We mutate the ref to the host component adding the imperative methods of the TextInput so you can still call `inputRef.clear` and `inputRef.isFocused`.
Changelog:
[General][Changed] TextInput now uses `forwardRef` allowing it to be used directly by new APIs requiring a host component.
Reviewed By: yungsters
Differential Revision: D18458408
fbshipit-source-id: 1f149fd575210d702fa0fdf3d05bb2162436a773
Summary:
When the TextInput class is exported directly Flow complains about some definitions because they don't properly define the export type. This change adds those types but still doesn't export the TextInput directly as there are more things that still need to get fixed.
Changelog:
[Internal]
Reviewed By: JoshuaGross
Differential Revision: D18444096
fbshipit-source-id: 18c88bbf1de5504f350681a71ea21d7e41876e49
Summary:
In order to make this more flow typed and modern we need to get it off of createReactClass. This change converts the class as is with no intended behavior changes to an ES6 class.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D18443018
fbshipit-source-id: 831921976e9de8e965180cdefd1c4a154f04bfea
Summary:
We need to get rid of NativeMethodsMixin. Normally we'd use forwardRef to the HostComponent, however we can't do this here because TextInput has its own imperative methods. I want to refactor this into a class and after that will revisit how to get rid of these methods.
Changelog:
[Internal]
Reviewed By: JoshuaGross
Differential Revision: D18436162
fbshipit-source-id: 0c81fa8b31b3248cbab8680ff680dd09c61c76e2
Summary:
Reordering the methds in TextInput to be a bit more consistent.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D18435732
fbshipit-source-id: 05a1d9d2c70a4b5fa00a3dc6be0520a216a24106
Summary:
We don't need a local mutable copy of props.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D18435731
fbshipit-source-id: 13ec1a78ca26b1372a4aed484a821204a93b6437
Summary:
The TouchableWithoutFeedback is almost exactly the same between both branches.
The responderReject prop was added in https://github.com/facebook/react-native/pull/16755.
The PR seems to say that it is the default behavior on Android. I don't want to make risky changes in this refactor so I'm not doing anything special about that prop for now.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D18435733
fbshipit-source-id: 372d17d8e67884930409a6a863757944cec4737e
Summary:
These functions are quite similar and I'm going to refactor out the shared pieces. To make it easy to review this change just inlines those two functions with no other changes.
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D18435734
fbshipit-source-id: 826f510359358427856993b536d41054ddf8c792
Summary:
This diff extends ThemeReactContext class to store the surfaceID field
The getSurfaceID method is being exposed as a public method
Changelog: [internal]
Reviewed By: JoshuaGross
Differential Revision: D18474015
fbshipit-source-id: ee1f859a802d36c51dec537fa91d90022523e88d
Summary:
This interface is used from ReactImageManager to customize the CallerContext object associated with each instance of ReactImageView.
CallerContext are used on Fresco to customize Debug and logs
Changelog: Introduce ReactCallerContextFactory interface, this interface is intended to customize Debug and logging on Fresco
Reviewed By: JoshuaGross
Differential Revision: D18474017
fbshipit-source-id: eda0fc9d3f64bbcc23ee1b7f5d779b441da1fe6c
Summary:
We want completely remove usages of Bitfield as it uses templates which bloats binary size
This stack will reduce 2.2 Kb in binary size bringing it down to 61.3KB on armv7
In this diff we are removing usage of template while updating styles.
## Changelog:
[Internal][Yoga] : Not using templates for updating styles
Reviewed By: astreet
Differential Revision: D18519570
fbshipit-source-id: 2324088b8c63154f818b1da1edf24c0533e10082
Summary:
Upgrading CLI to latest. It's likely not yet compatible with master, because we depend on Metro 0.56, and master is on 0.57. This diff is intended to be cherry-picked to 0.61 and 0.62.
cc grabbou
## Changelog
[Internal] [Changed] - Bump CLI to ^3.0.0
Pull Request resolved: https://github.com/facebook/react-native/pull/27235
Test Plan: None
Differential Revision: D18527709
Pulled By: cpojer
fbshipit-source-id: 44448058c48a66d22a1d71abdc908f532f5aa547
Summary:
Changes the Fast Refresh message for when metro disconnects to remove "Reload to reconnect.". The most common use case for this happening is when Metro is stopped, and reloading will not reconnect to a stopped metro server.
Long term we should reconnect to Metro automatically and then this message would be followed up with a "Reconnected to Metro" message, never needing a reload.
Changelog: [Internal]
Reviewed By: cpojer
Differential Revision: D18527705
fbshipit-source-id: 40768ce1089348b612e9d86638f07169d2a34b67
Summary:
Feedback from multiple people has been that the "see more" is hard to discover and that it should be at the bottom left, so this diff moves it there.
Changelog: [Internal]
Reviewed By: cpojer
Differential Revision: D18487041
fbshipit-source-id: 1543c54e1de5fa16fa5b2e427812b6e72977bfb2
Summary:
The margin and padding are resolved incorrectly for leaf nodes (nodes with measure function set) if margin and padding are used in percentages.
Here we were using node's width instead of container width to calculate the margin and padding.
Fixed this to use container's width.
## Changelog:
[General][Yoga] : Fixed an issue where margin and padding were resolved incorrectly for leaf nodes (nodes with measure function set) if margin and padding are used in percentages.
Reviewed By: alickbass
Differential Revision: D17130520
fbshipit-source-id: ac904d432f121973e7739debd9136909b5ca1427
Summary:
Fixes T54997838 by preventing any view mutations during `onMeasure` calls.
There might still be places where this is possible, but this is where I'm seeing all the crashes currently.
See comments in ReactRootView for why views were mutated during onMeasure.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D18518591
fbshipit-source-id: 1406af8a6b0bfcc86f4cc5b451b3967f312dfd85
Summary:
This change is not only more correct, it's also fixes the modal in the the next diff.
It's more accurate because in the previous location, the redbox dismissal was done as a hack in order to hide non-syntax errors so that the syntax error would be visible when it fired. This is unnecessary for LogBox because it always puts syntax errors on top of any other error.
The main motivation for changing this, however, is that this strategy is broken when switching to the Modal component because the Modal component does not work well with quickly unmounting and remounting. With the old strategy, the inspector would flicker and then collapse even though there was a syntax error.
Changelog: [Internal]
Reviewed By: cpojer, gaearon
Differential Revision: D18461431
fbshipit-source-id: e8ed83e3d2b002e5d45cc13dc9533ed841ed5cae
Summary:
Fixes an issue where unhandled exceptions would unmount the app and LogBox, hiding the exception and leaving the user stuck. This is a temporary solution until we either decide to provide an error boundary by default or move this to a separate root.
Changelog: [Internal]
Reviewed By: cpojer
Differential Revision: D18504346
fbshipit-source-id: 4bca8693e63c367bf3070f12606a50824aa4cc23
Summary:
`ReactFeatureFlags.useTurboModules` can be written to and read from any number of threads. We should use `volatile` to make sure that all threads read/write this data straight from/to memory.
Changelog:
[Android][Fixed] - Make ReactFeatureFlags.useTurboModules volatile
Reviewed By: fkgozali
Differential Revision: D18505673
fbshipit-source-id: 0b2527b8cb95c1e1aedc6b03b12a6b1e6a6cdaa4
Summary:
Now that the networking module is a TurboModule request handlers need to be passed at module creation. The code was missing for RNTester.
## Changelog
[Internal] [Fixed] - Fix RNTester networking conversion to TurboModule
Pull Request resolved: https://github.com/facebook/react-native/pull/27218
Test Plan: Tested that RNTester XMLHttpRequest example now works on iOS
Differential Revision: D18506038
Pulled By: RSNara
fbshipit-source-id: cd88319e386c7b7b6e11cfb920f2ceb761a4136a
Summary:
Why crash in production if we can make potential bug not compile?
Changelog: [INTERNAL]
Reviewed By: sammy-SC
Differential Revision: D18499813
fbshipit-source-id: dc2d7ac12b8a2ae27d1e6b832fccc1555cab3b75
Summary:
Extracts a new `RCTFormatStackTrace` function from `RCTFormatError`.
Changelog: [Internal]
Reviewed By: shergin
Differential Revision: D18114387
fbshipit-source-id: 4466f52d75d9da3a257cd1cc7067492a0c19a7d5
Summary:
This diff makes number of improvements to stack frames:
- Adds padding around stack frame pressables
- Fixed wrapping for the closing bracket on component stacks
- Adds passing around "see more" buttons
- Fixed the count for "Show x more frames" when it's 0 and otherwise
- Add more cases for the count text
- Switches button back to minimize (snuck this in here)
Changelog: [Internal]
Reviewed By: cpojer
Differential Revision: D18495331
fbshipit-source-id: 8b9efa88c4205b23e734893d8db6deccce88344c
Summary:
## Changelog:
[General] [Yoga] - Use vanilla jni instead of fbjni for all the jni communication
Reviewed By: astreet
Differential Revision: D17808005
fbshipit-source-id: 5e9a1ed73978f519c71c248774a28e5a294e7c7f
Summary:
The original implementation had an incorrect order of fields in the struct wich causes bugs with border drowing.
Changelog: [Internal] Fabric-specific internal change.
Reviewed By: sammy-SC
Differential Revision: D18444733
fbshipit-source-id: e4611e6e90eee85e7cdebcee3c5bb6886417aa26
Summary:
We already have the exact same function in RCTConvertions.h, why have a copy of it here?
Changelog: [Internal] Fabric-specific internal change.
Reviewed By: sammy-SC
Differential Revision: D18444731
fbshipit-source-id: ba1ebd538f92145c2ec0c30e0f7d14f1d05b381c
Summary:
We will use it soon for `EdgeInsets`
Changelog: [Internal] Fabric-specific internal change.
Reviewed By: sammy-SC
Differential Revision: D18444732
fbshipit-source-id: f03aa2a8889d426095a954d88f9cb6172c3e376e
Summary:
The moved code fragment is a workaround for a bug in UITextField in iOS 8. There is no need to have this code in a general base class that serves both UITextField- and UITextView-based components. Especially for such workarounds like that, we have a dedicated class RCTUITextField. This diff moves that there.
Read more about the bug:
https://stackoverflow.com/questions/14220187/uitextfield-has-trailing-whitespace-after-securetextentry-toggle/22537788#22537788
Changelog: [Internal]
Reviewed By: sammy-SC
Differential Revision: D18444734
fbshipit-source-id: a3764c19f562231ba3fa3d4c0ad7de069ea04d98
Summary:
This diff changes LogBox to say "Render Error" instead of "Fatal Error" for errors thrown in render.
Changelog: [Internal]
Reviewed By: cpojer
Differential Revision: D18466237
fbshipit-source-id: 737759f3febb937f70698dae5f1b1617e233fc98