Summary: Apparently we don't need this at this level. This will be implemented as part of RCTSufraceHostingView.
Reviewed By: rsnara
Differential Revision: D6367071
fbshipit-source-id: 71a2361b8a0c6594c63602165ce5e054de62630d
Summary: We need this trivial funcs to unify spinner appearance logic.
Reviewed By: rsnara
Differential Revision: D6367072
fbshipit-source-id: 70e288bc1fed5911828a5f6deaa829597bf8ebff
Summary: We don't really need sync dispatch here. We only need sequential execution of our UIManager blocks.
Reviewed By: rsnara
Differential Revision: D6367069
fbshipit-source-id: cc675aafd6c762506048bcf65c24e54080b013a5
Summary: We previously incorrectly communicated to the delegate changed fragment instead of compound value.
Reviewed By: rsnara
Differential Revision: D6367070
fbshipit-source-id: 373a7c14a79a4727a7e8f61178dea3ca16ea1f40
Summary:
Integration testing with Appium on iOS is slow. Profiling with Instruments.app points to `RCTView`'s `accessibilityLabel` method being a hot point in React Native, due to the `RCTRecursiveAccessibilityLabel` function.
I did a baseline benchmark by using Appium's `find_element(accessibility_id: <label>)` call on our application 10 times and got a baseline result of 0.6s for one of our primary screens.
After implementing the change and performing the same call 10 times, I got 0.48s for the same call, for a 20% performance increase in `find_element`.
[iOS] [View] - Improve performance of `RCTView` `accessibilityLabel`
<!--
Help reviewers and the release process by writing your own release notes
**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**
CATEGORY
[----------] TYPE
[ CLI ] [-------------] LOCATION
[ DOCS ] [ BREAKING ] [-------------]
[ GENERAL ] [ BUGFIX ] [-{Component}-]
[ INTERNAL ] [ ENHANCEMENT ] [ {File} ]
[ IOS ] [ FEATURE ] [ {Directory} ] |-----------|
[ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} |
[----------] [-------------] [-------------] |-----------|
[CATEGORY] [TYPE] [LOCATION] - MESSAGE
EXAMPLES:
[IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
[ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
[CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
[DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
[GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
[INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Closes https://github.com/facebook/react-native/pull/17022
Differential Revision: D6459462
Pulled By: shergin
fbshipit-source-id: 3de7e5dc075281e35e62b4d4234d3f7fac5aae23
Summary:
New super simple abstraction in RCTUIManager.
Nothing really changed and RCTUIManager became shorter.
Reviewed By: rsnara
Differential Revision: D5990342
fbshipit-source-id: b38397b789a999168ac14625585065eda73d328f
Summary:
Fix the following warning:
> Module RCTTVNavigationEventEmitter requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
Trivial change.
[IOS] [MINOR] [RCTTVNavigationEventEmitter] - Implement `requiresMainQueueSetup` in `RCTTVNavigationEventEmitter`
Closes https://github.com/facebook/react-native/pull/16915
Differential Revision: D6394636
Pulled By: shergin
fbshipit-source-id: 3981655832715e73e93ef917d987e25097029b84
Summary:
Incorrect render for borders that are not proportional to device pixel: borders get stretched and become significantly bigger than expected.
Rdar: http://www.openradar.me/15959788
Incorrect render for borders that are not proportional to device pixel: borders get stretched and become significantly bigger than expected.
Rdar: http://www.openradar.me/15959788
Reviewed By: shergin
Differential Revision: D6317674
fbshipit-source-id: 6bc331447458583a02c0e56d0d011a31d31d70a8
Summary:
RCTSurface instance represents React Native-powered piece of a user interface
which can be a full-screen app, separate modal view controller,
or even small widget. It is called "Surface".
The RCTSurface instance is completely thread-safe by design;
it can be created on any thread, and any its method can be called from
any thread (if the opposite is not mentioned explicitly).
The primary goals of the RCTSurface are:
- ability to measure and layout the surface in a thread-safe and synchronous manner;
- ability to create a UIView instance on demand (later);
- ability to communicate the current stage of the surface granularly.
Differential Revision: D6202576
fbshipit-source-id: 8e644c87fcaad2b6a9c9304b58384d7192747556
Summary: This logic was decoupled from RCTRootView to make it reusable.
Reviewed By: javache
Differential Revision: D6214785
fbshipit-source-id: e7419be03ba0e20d95b47c11e41789636aa6e916
Summary:
set the y offset to 0, since 0 offset is where we want to be after we hide the refreshControl.
Tested in emulator with ios 8, 9, 10 and also with section headers.
Closes https://github.com/facebook/react-native/pull/15033
Differential Revision: D6265930
Pulled By: shergin
fbshipit-source-id: b249c4713de68fc6b3a32cee7f995dc352315970
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.
You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html
Happy contributing!
-->
While building a React Native application, I've come across the use case of wanting to set a specific locale for DatePickers irrespective of the users OS region setting. Since this is a feature available to native DatePicker components, I think it would be helpful to expose this in React Native as well.
Testing can be done by passing a `locale` prop to a DatePickerIOS. Example:
```
<DatePickerIOS
date={this.state.date}
mode="date"
locale="fr_FR"
onDateChange={date => this.setState({ date: date })}
/>
```
<!--
Help reviewers and the release process by writing your own release notes
**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**
CATEGORY
[----------] TYPE
[ CLI ] [-------------] LOCATION
[ DOCS ] [ BREAKING ] [-------------]
[ GENERAl ] [ BUGFIX ] [-{Component}-]
[ INTERNAL ] [ ENHANCEMENT ] [ {File} ]
[ IOS ] [ FEATURE ] [ {Directory} ] |-----------|
[ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} |
[----------] [-------------] [-------------] |-----------|
[CATEGORY] [TYPE] [LOCATION] - MESSAGE
EXAMPLES:
[IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
[ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
[CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
[DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
[GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
[INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
[IOS][ENHANCEMENT][DatePickerIOS] - Adding a locale prop.
Closes https://github.com/facebook/react-native/pull/16639
Differential Revision: D6241981
Pulled By: hramos
fbshipit-source-id: 77b1b85c09f3e12d6b3e103b3d1ffd1f12e2cea9
Summary:
According to the retain code collector, RCTSafeAreaView is in a cycle:
-> _bridge -> RCTCxxBridge -> _moduleDataByName -> __NSDictionaryM -> RCTModuleData -> _instance -> RCTUIManager -> _viewRegistry -> __NSDictionaryM -> RCTSafeAreaView
This should break the cycle.
Reviewed By: shergin
Differential Revision: D6213668
fbshipit-source-id: efb9c1dd148b72f66fe4485b81c16cd4c2d18b17
Summary:
Same IOS 11 issue as https://github.com/facebook/react-native/pull/15023
Fixes the annoying 20px content insert on top.
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.
You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html
Happy contributing!
-->
Fix the behaviour of WebView when building the iOS project with Xcode 9 due to the `contentInsetAdjustmentBehavior`.
![expected](https://user-images.githubusercontent.com/5630513/32207551-b7789668-bdca-11e7-840a-f325b2767d08.jpg)
![iphone_x_after](https://user-images.githubusercontent.com/5630513/32207557-beb8fd6e-bdca-11e7-87d0-18d533f20125.jpg)
![issue_normal_iphone_ios11](https://user-images.githubusercontent.com/5630513/32207572-d773be5c-bdca-11e7-8e28-8f0783eef1cd.jpg)
![iphone_x_before](https://user-images.githubusercontent.com/5630513/32207581-e3e93234-bdca-11e7-847d-f801bbf05d55.jpg)
<!--
Help reviewers and the release process by writing your own release notes
**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**
CATEGORY
[----------] TYPE
[ CLI ] [-------------] LOCATION
[ DOCS ] [ BREAKING ] [-------------]
[ GENERAl ] [ BUGFIX ] [-{Component}-]
[ INTERNAL ] [ ENHANCEMENT ] [ {File} ]
[ IOS ] [ FEATURE ] [ {Directory} ] |-----------|
[ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} |
[----------] [-------------] [-------------] |-----------|
[CATEGORY] [TYPE] [LOCATION] - MESSAGE
EXAMPLES:
[IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
[ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
[CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
[DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
[GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
[INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
[IOS] [BUGFIX] [WebView] - Fix extra white space added to webView due to iOS 11 contentInsetAdjustmentBehavior
Closes https://github.com/facebook/react-native/pull/16519
Differential Revision: D6195670
Pulled By: shergin
fbshipit-source-id: 08d4d4dc700059bb7707e038dc4f592af0275896
Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.
You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html
Happy contributing!
-->
When initializing react native module using a url pointing to local jsbundle and hot reload is enabled, bridge, is trying to initialize the feature but crashes because there is no host in a local file url.
1. Create a new project.
```sh
$ react-native init testPlanApp && cd testPlanApp
```
2. Create jsbundle.
```sh
$ react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ios/main.jsbundle
```
3. Run the app and enable hot reload.
4. Enable airplane mode.
5. Close application and re-run.
6. See app crashes.
<!--
Help reviewers and the release process by writing your own release notes
**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**
CATEGORY
[----------] TYPE
[ CLI ] [-------------] LOCATION
[ DOCS ] [ BREAKING ] [-------------]
[ GENERAl ] [ BUGFIX ] [-{Component}-]
[ INTERNAL ] [ ENHANCEMENT ] [ {File} ]
[ IOS ] [ FEATURE ] [ {Directory} ] |-----------|
[ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} |
[----------] [-------------] [-------------] |-----------|
[CATEGORY] [TYPE] [LOCATION] - MESSAGE
EXAMPLES:
[IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
[ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
[CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
[DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
[GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
[INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
[IOS] [BUGFIX] [Hot reloading] - Fix crash when loading local bundle and hot reload is enabled.
Closes https://github.com/facebook/react-native/pull/16504
Differential Revision: D6133767
Pulled By: shergin
fbshipit-source-id: 3f7668e3e8fa7e772f58420e5a8a0985a5f8e48b
Summary:
ExtraBold is a fairly common suffix in font naming. A good example is "Circe-ExtraBold". It's usually synonymous with Heavy or Black at font weight 800, as described here: https://www.webtype.com/info/articles/fonts-weights/
This fixes a regression with ExtraBold fonts introduced in d3007b0 where simply having an extrabold font will cause `weightOfFont` to choose this weight aggressively, resulting in all bold text erroneously interpreted as extrabold/heavy. This fix ensures that extrabold is detected before bold, and correctly attributed to `UIFontWeightHeavy`.
Closes https://github.com/facebook/react-native/pull/16323
Differential Revision: D6119059
Pulled By: shergin
fbshipit-source-id: 56a5c30584f220974308a7d6068c8d952aa20fb8
Summary:
This provides a way to customize the return type of a sync exported method, instead of just using `id`.
```
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, sync1:(NSString *)x)
{
return @"hello";
}
```
The return type needs to be a sub type of `id` - so scalars like `double` won't work (the bridge will crash).
Differential Revision: D6068884
fbshipit-source-id: 43a98141f1d0aef335aa0b33a24219f8e574e58b
Summary:
- The version check that ensures the JS and native versions match is now in its own module for two reasons: it is easier to test and it allows react-native-windows to override just this module to implement its own version check (ex: more advanced checks for RNW-specific code).
- Added unit tests for the version checking to specify its behavior more clearly, including parity between dev and prod to avoid prod-only behavior and mitigate SEVs.
- Prefixed the Obj-C `#define` with `RCT_` to conform with other RN globals.
Closes https://github.com/facebook/react-native/pull/16403
Differential Revision: D6068491
Pulled By: hramos
fbshipit-source-id: 2b255b93982fb9d1b655fc62cb17b126bd5a939a
Summary: It saves 8 bytes per shadowView instance, and it is more logical because it does nothing by default.
Reviewed By: javache
Differential Revision: D5997804
fbshipit-source-id: c985a11aeea881e95911469e10c8c27429a2718a
Summary:
Queues Problem Intro:
UIManager queue is special queue because it has special relationship with
the Main queue.
This particular relationship comes from two key factors:
1. UIManager initiates execution of many blocks on the Main queue;
2. In some cases, we want to initiate (and wait for) some UIManager's work *synchronously* from
the Main queue.
So, how can we meet these criteria?
"Pseudo UIManager queue" comes to rescue!
"Pseudo UIManager queue" means safe execution of typical UIManager's work
on the Main queue while the UIManager queue is explicitly blocked for preventing
simultaneous/concurrent memory access.
So, how can we technically do this?
1. `RCTAssertUIManagerQueue` is okay with execution on both actual UIManager and
Pseudo UIManager queues.
2. Both `RCTExecuteOnUIManagerQueue` and `RCTUnsafeExecuteOnUIManagerQueueSync`
execute given block *synchronously* if they were called on actual UIManager
or Pseudo UIManager queues.
3. `RCTExecuteOnMainQueue` executes given block *synchronously* if we already on
the Main queue.
4. `RCTUnsafeExecuteOnUIManagerQueueSync` is smart enough to do the trick:
It detects calling on the Main queue and in this case, instead of doing
trivial *synchronous* dispatch, it does:
- Block the Main queue;
- Dispatch the special block on UIManager queue to block the queue and
concurrent memory access;
- Execute the given block on the Main queue;
- Unblock the UIManager queue.
Imagine the analogy: We have two queues: the Main one and UIManager one.
And these queues are two lanes of railway go in parallel. Then,
at some point, we merge UIManager lane with the Main lane, and all cars use
the unified the Main lane.
And then we split lanes again.
This solution assumes that the code running on UIManager queue will never
*explicitly* block the Main queue via calling `RCTUnsafeExecuteOnMainQueueSync`.
Otherwise, it can cause a deadlock.
Reviewed By: mmmulani
Differential Revision: D5935464
fbshipit-source-id: 6a60ff236280d825b4e2b101f06222266097b97f
Summary:
This is pretty normal and harmless case, we should not crash here.
I plan to refactor similar places in this file soon.
Reviewed By: AaaChiuuu
Differential Revision: D5983443
fbshipit-source-id: 922fea8ed12ebef45d249f16739aa81fe3254f19
Summary: As RCTNativeModule can be destructed at any time, it's unsafe to capture "this" in a callback.
Reviewed By: javache
Differential Revision: D5963728
fbshipit-source-id: c80a01c851d97813e4fead2b31c442eaeb8ae204
Summary:
If you are a product developer and you need to fix your app's issues related to iPhone X limitations asap,
you can temporary use `DeviceInfo.isIPhoneX_deprecated`.
You can, but you should not. Please consider use new <SafeAreaView>.
This prop was initially named so ugly because we are trying to discourage the community to use it.
However, we understand that sometimes we need a "band-aid" to prevent our apps bleeding.
Note: This prop (DeviceInfo.isIPhoneX_deprecated) will be removed completely after 06/18.
Reviewed By: fkgozali
Differential Revision: D5946329
fbshipit-source-id: 5d6dcaf0e2d175327d59cde4b5ec2e01cd77ec70
Summary:
Reasons:
* It is more clear and readable;
* It is more semantical;
* It allows us to add some magic (and complexity, to be fair) to the RCTExecuteOnUIManagerQueue. (See next diffs in the stack.)
Reviewed By: javache
Differential Revision: D5935466
fbshipit-source-id: aeb18d6e11c047eb19182a656da581b6ce073602
Summary:
This fixes [#15801](https://github.com/facebook/react-native/issues/15801)
We ran into a strange crash on iOS (debug only). After removing the clutter I was able to reproduce it in a tiny app. You can check it out [here.](https://github.com/simonracz/textinput_stress)
The UI in JS and native are not always in sync (which is okay). Due to this, a native view might call back into JS, which is no longer present in the shadow view hierarchy there. I think this should be also okay.
TextInput in some cases calls into [setIntrinsicContentView](6d67e2dbbc/React/Modules/RCTUIManager.m (L382)), where it triggers an overly enthusiastic `NSAssert` and crashes the app.
Check out [textinput_stress](https://github.com/simonracz/textinput_stress)
Rotate the simulator a few times to see the crash or the lack of crash.
Closes https://github.com/facebook/react-native/pull/16170
Differential Revision: D5959776
Pulled By: shergin
fbshipit-source-id: f39f5a3f1d86b330ecf7cbccd90871bc01fd69d9
Summary:
This is required for D5874536, wherein I'll be introducing direction-aware props for borders.
When a view's border changes due to a direction update, only the frames of its children update. Therefore, only the children `UIView`s get a chance to be re-rendered. This is incorrect because the view that's had its borders changed also needs to re-render. So, I keep a track of the layout direction in a property on all shadow views. Then, when I update that prop within `applyLayoutNode`, I push shadow views into the `viewsWithNewFrames` set.
Reviewed By: mmmulani
Differential Revision: D5944488
fbshipit-source-id: 3f23e9973f3555612920703cdb6cec38e6360d2d
Summary: Now it compiles and works.
Reviewed By: fromcelticpark
Differential Revision: D5952026
fbshipit-source-id: df0408108ab29b77592d78b29553d2e65686f2f2
Summary:
Basic implementation of the proposal in #15271
Note that this should not affect facebook internally since they are not using OSS releases.
Points to consider:
- How strict should the version match be, right now I just match exact versions.
- Wasn't able to use haste for ReactNativeVersion because I was getting duplicate module provider caused by the template file in scripts/versiontemplates. I tried adding the scripts folder to modulePathIgnorePatterns in package.json but that didn't help.
- Redscreen vs. warning, I think warning is useless because if the app crashes you won't have time to see the warning.
- Should the check and native modules be __DEV__ only?
**Test plan**
Tested that it works when version match and that it redscreens when versions don't before getting other errors on Android and iOS.
Closes https://github.com/facebook/react-native/pull/15518
Differential Revision: D5813551
Pulled By: hramos
fbshipit-source-id: 901757e25724b0f22bf39de172b56309d0dd5a95
Summary: Because `RCTUIManager` is already overcomplicated and that stuff deserves separate file and header.
Reviewed By: javache
Differential Revision: D5856653
fbshipit-source-id: 7001bb8ba611976bf3b82d6a25f5619810a35b34
Summary:
This issue has been open for a really long time, but I'm pretty sure this is the line that needed to change:
https://github.com/facebook/react-native/issues/1831
What was happening here is that `CGRectIsEmpty` returns true when either height or width is zero. With the current logic, one of those would always be zero when the parent was rendered off screen. This ensures that there the intersection be of CGSizeZero for the view to actually be clipped.
That being said, there seems to be something more complex going on here that I'm not understanding? I would think that you'd simply want to check if the child view's frame is within the bounds of the parent at all. If it was, then don't clip it. If I'm in the wrong, could someone explain this a bit more? If so, I'll fix this issue.
Using this [repository](https://github.com/jcharlet/react_native_listview_bug), this one line change fixes the issue and still clips cells as they are scrolled off screen.
Closes https://github.com/facebook/react-native/pull/15669
Differential Revision: D5815056
Pulled By: shergin
fbshipit-source-id: 32382e4954139e4d5af67d786422fd87173b1a1a
Summary: As per the comment, <Modal> uses entering/leaving the view hierarchy as a cue to show/hide the modal. By re-adding it, we are causing a bunch of confusion.
Reviewed By: shergin
Differential Revision: D5893607
fbshipit-source-id: ecd05799751a9bba843998ae93f24fe35edca8b4
Summary:
<SafeAreaView> renders nested content and automatically applies paddings reflect the portion of the view
that is not covered by navigation bars, tab bars, toolbars, and other ancestor views.
Moreover, and most importantly, Safe Area's paddings feflect physical limitation of the screen,
such as rounded corners or camera notches (aka sensor housing area on iPhone X).
Reviewed By: mmmulani
Differential Revision: D5886411
fbshipit-source-id: 7ecc7aa34de8f5527c4e59b0fb4efba3aaea28c8
Summary:
In some cases we need a way to specify some environmental data to shadow view
to improve layout (or do something similar), so `localData` serves these needs.
For example, any stateful embedded native views may benefit from this.
Have in mind that this data is not supposed to interfere with the state of
the shadow view.
Reviewed By: mmmulani
Differential Revision: D5884711
fbshipit-source-id: f0bf66e4608894ec4479b8aca262afcfba6b9f4b
Summary: Adds an onDismiss so that navigation events can be chained to the dismissing of a modal.
Reviewed By: sahrens
Differential Revision: D5852953
fbshipit-source-id: a86e36fdd5b0b206c2dd9fa248e2a88da22efa31
Summary:
This should be much more performant (and it better illustrates the intension of the code).
The fix was suggested by Adlai-Holler.
Reviewed By: mmmulani
Differential Revision: D5851595
fbshipit-source-id: 45d172a5fa796549c6dcea8f35c5cbb2a4c2d2e0
Summary:
iOS 11 now requires this to be accessed on the main thread.
I think this is causing tests to fail, as the Main Thread Checker is turned on there.
Reviewed By: javache
Differential Revision: D5826570
fbshipit-source-id: 6acb7174c756a2ad657602f14c666f71b1ee8fe9
Summary:
Remove fallback logic.
It is hard to test whether a bundle is good or bad on device, since it does the fallback, remove the fallback logic now.
Reviewed By: javache
Differential Revision: D5773542
fbshipit-source-id: 8bb4fdad4c5761ccce915f9f1c2577464e8d37d8
Summary:
fix the regression I mentioned in https://github.com/facebook/react-native/pull/15162#issuecomment-319696706
as no one is working on this, I take the step, although I know nothing about Objective C
I find the key point is that the keys in `NSDictionary` are not ordered as presented, it's a hash table, so no grantee on keys order, so I create a new array to do that, then it will check `ultralight` before `light` and `semibold` before `bold`
Closes https://github.com/facebook/react-native/pull/15825
Differential Revision: D5782142
Pulled By: shergin
fbshipit-source-id: 5346b0cb263e535c0b445e7a2912c452573248a5
Summary:
Shame on me.
Naming can be hard. We have to use positive logic to avoid this kind of bugs. :(
In the bright future we also have to rename `isYogaLeafNode` to something with positive logic, like `canHaveYogaChildNodes`.
But before we can do this, we have to have solid plan how to unify it with Android.
Reviewed By: mmmulani
Differential Revision: D5780917
fbshipit-source-id: 1ddaaea06f5618b91528cc87f1433a55b5fae4ac
Summary:
This is revert of revert of https://github.com/facebook/react-native/pull/15542
WITHOUT default RCT_MAIN_THREAD_WATCH_DOG_THRESHOLD value. So, it makes it completly opt-in feature.
When code blocks the UI thread for too long, it's a bad sign because this can prevent the app from remaining responsive. This change helps detect such responsiveness issues by warning when a React method executes on the UI thread longer than some threshold.
Reviewed By: mmmulani
Differential Revision: D5772433
fbshipit-source-id: 24fe4fc0deffe9c091a4bfc4cbd76cb4f34c4091
Summary:
Content offset was broken because on initial render contentSize is {0,0} so any positive offset is lost. Also inset top/bottom and left/right were inversed �, this led to bad initial scrolling offset when using contentInset. This fixes it by making sure contentSize is actually measured (not {0,0}. I guess it's possible that the content is ACTUALLY {0,0} but in that case I don't think it really matters).
**Test plan**
Tested that a scrollview has proper scroll position when specifying contentOffset. Also tested that it works well with contentInset.
```js
<ScrollView contentOffset={{y: 100}}>
<View style={{height: 1000}} />
</ScrollView>
```
Closes https://github.com/facebook/react-native/pull/15670
Differential Revision: D5771221
Pulled By: shergin
fbshipit-source-id: 455ed8fd5a4ad1ec61780b573d1a8ef1d77dd124
Summary:
We assign the value to an NSInteger so we should convert the NSString to an NSInteger instead of an int.
Build the app in Xcode and run it.
Closes https://github.com/facebook/react-native/pull/15806
Differential Revision: D5767118
Pulled By: shergin
fbshipit-source-id: b310511f13f5f4026d595a219d69811801d313c2
Summary:
This fixes the `testModulesAreDeallocated` test. It was sometimes failing because the bridge's module was still alive. I debugged with the Xcode memory graph and found that the bridge was actually kept alive by a pointer from the NSThread.
By killing the runloop on the thread, the thread will eventually die and thus free the bridge.
One thing I didn't investigate was whether the thread was alive because of it receiving actual messages or just because the run loop was spinning.
Reviewed By: javache
Differential Revision: D5729925
fbshipit-source-id: 304f526129d2c5e137bfd791a6f957f6169b783e
Summary: Expose webSocketDidOpen in RCTReconnectingWebSocket in order to get notified when the reconnecting websocket is opened to the endpoint.
Reviewed By: emilsjolander
Differential Revision: D5725547
fbshipit-source-id: e904c5a84d670ecf936993ec1739614f99fce09c
Summary:
When code blocks the UI thread for too long, it's a bad sign because this can prevent the app from remaining responsive. This change helps detect such responsiveness issues by warning when a React method executes on the UI thread longer than some threshold.
**Test Plan**
Changed AppState's getCurrentAppState method to sleep for 500 ms and verified that a warning was emitted:
```
2017-08-17 19:45:29.479 [warn][tid:main][RCTModuleMethod.mm:527] mainThreadWatchdog: invocation of [RCTAppState getCurrentAppState:error:] took 501ms
```
Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/15542
Differential Revision: D5724764
Pulled By: shergin
fbshipit-source-id: f1dc4bf17d3657c397720a47fabc7f32bf81b7ac
Summary:
We have to have a way to track ownership of shadow view.
Previous solution with traversing the hierarchy to figure out the root view does not actually work in some cases when the view is temporary detached from hierarchy.
This is also how it work on Andorid.
Reviewed By: mmmulani
Differential Revision: D5686112
fbshipit-source-id: a23a10e8c29c7572ac69403289db136c9d5176a9
Summary:
- [x] Explain the **motivation** for making this change.
- [x] Provide a **test plan** demonstrating that the code is solid.
- [x] Match the **code formatting** of the rest of the codebase.
- [x] Target the `master` branch, NOT a "stable" branch.
There is a problem where setting a bigger fontSize in PickerItem style
clips the top and bottom of the text.
This solves that problem by computing the row height using the font
size.
Create a PickerIOS component and set a larger font size (e.g. 50). The row height will grow accordingly.
Example with `fontSize=50`: [Screenshot](http://i.imgur.com/YwK5fOc.png)
Closes https://github.com/facebook/react-native/pull/13513
Differential Revision: D5692124
Pulled By: shergin
fbshipit-source-id: 4629403e37ad68cdbc0b17b48ba924a77e133078
Summary:
> The property contentInset can change the maximum and minimum values of the content offset to allow scrolling outside of the scrollable area. Its type is UIEdgeInsets, which consists of 4 numbers: {top, left, bottom, right}. When you introduce an inset, you change the range of the content offset. For example, setting the content inset to have a value of 10 for its top value allows the content offset’s y value to reach -10. This introduces padding around the scrollable area.
( https://www.objc.io/issues/3-views/scroll-view/ )
See also: https://github.com/facebook/react-native/pull/15395
Reviewed By: mmmulani
Differential Revision: D5607192
fbshipit-source-id: 1acd6a84e2bcfefc6e82861cfbdfe6247d0e4264
Summary:
On an iPhone running iOS 10.3.3, I'm not seeing the UIContentSizeCategoryDidChangeNotification fire when changing the system's font scale setting. Registering for the event on `nil` instead of on the application object fixes the issue.
**Test Plan**
Verified that text in an RN app changes size when you change the system's font scale setting (Settings -> General -> Accessibility -> Larger Text). By default, RN text is supposed to scale with the system setting.
Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/15522
Differential Revision: D5657449
Pulled By: shergin
fbshipit-source-id: d7a6a730c5cd6eb3833274a1f2029663ad3a7ad2
Summary:
**Motivation**
On Apple TV, pressing the menu button destroys the native view that backs the `Modal` component, causing an app using this component to get into a broken state. This fix implements `onRequestClose` for tvOS to have the same behavior as it does for the Android back button.
**Test plan**
Manually tested this with the `ModalExample` in the `RNTester` app. See also the test code in issue #15313.
Closes https://github.com/facebook/react-native/pull/15341
Differential Revision: D5651035
Pulled By: shergin
fbshipit-source-id: 54bf66887bbe85940567e63e90b437ac4a8daf9a
Summary:
(This diff was decoupled from D4983054 which landing was quite delayed.)
`RCTUnsafeExecuteOnMainQueueOnceSync()` synchronously executes a block once, on main queue.
I found that our old implementation of `RCTScreenScale()` causes deadlock when it is called from main and background thread simultaneously.
After I implemented my own solution I googled this issue and found an article by Ben Alpert with this awesome helper:
https://benalpert.com/2014/04/02/dispatch-once-initialization-on-the-main-thread.html
So, I found it super useful and borrowed it.
Hey spicyj! :)
Reviewed By: fkgozali
Differential Revision: D5632592
fbshipit-source-id: dff43a5780b7404a3cc109c66c131cef4f4df429
Summary:
This shows progress for the download of the JS bundle (different from the packager transform progress that we show already). This is useful especially when loading the JS bundle from a remote source or when developing on device (on simulator + localhost it pretty much just downloads instantly). This will be nice for the expo client since all bundles are loaded over the network and can take several seconds to load.
This depends on https://github.com/facebook/metro-bundler/pull/28 to work but won't crash or anything without it, it just won't show the progress percentage.
![img_05070155d2cc-1](https://user-images.githubusercontent.com/2677334/28293828-2c08d974-6b24-11e7-9334-e106ef3326d9.jpeg)
**Test plan**
Tested that bundle download progress is shown properly in RNTester on both localhost + simulator and on real device with network conditionner to simulate a slow loading bundle.
Tested that it doesn't cause issues if the packager doesn't send the Content-Length header.
Closes https://github.com/facebook/react-native/pull/15066
Differential Revision: D5449073
Pulled By: shergin
fbshipit-source-id: 43a8fb559393bbdc04f77916500e21898695bac5
Summary:
**Motivation**
Fix flickering in TabBarIOS on Apple TV... issue #15081
After this change, on Apple TV, TabBarIOS item selections will be controlled purely from the native side after initial render with the `selected` prop. This is necessary because the `UITabBar` implementation in tvOS moves the selection before calling `shouldSelectViewController:`; this issue does not occur on iOS.
**Test plan**
Existing CI should still pass. Issue is resolved when testing the example code in #15081 .
Closes https://github.com/facebook/react-native/pull/15220
Differential Revision: D5601671
Pulled By: javache
fbshipit-source-id: c18e7d3482d6c07d534ff40a443a6f642d4267bb
Summary:
It is not itemPositoning it is itemPositioning
I have test it on iOS and tvOS
Closes https://github.com/facebook/react-native/pull/15426
Differential Revision: D5591807
Pulled By: javache
fbshipit-source-id: 0ad0bc32012c63f93f6b1528cae46c6dcba56706
Summary:
Here, `reactTag` is an `NSNumber *` which uses `%@` as the format specifier. Newer versions of clang can warn or error on this. This change prevents that from happening.
See also #15402
Local builds with clang 5.
Closes https://github.com/facebook/react-native/pull/15414
Differential Revision: D5583703
Pulled By: javache
fbshipit-source-id: a6d0d2246725cd096b1f3cd062ab5924740ab76c