Commit Graph

813 Commits

Author SHA1 Message Date
Janic Duplessis 102a31c13e Fix RefreshControl layout on screen rotation and consecutive pull to refresh not working properly
Summary:Fixes the RefreshControl layout after a screen rotation. See #6311 for a more detailed explanation. I fixed it by adjusting the frame of the RefreshControl in `layoutSubviews` of the parent ScrollView.

While working on fixing this I noticed that when doing a 'pull to refresh' and then not scrolling and wait for it to end the next one will not behave like the first one (it will require pulling further down for the spinner to start spinning). I fixed that too by scrolling the scrollview back to 0 manually before calling `UIRefreshControl.endRefreshing`.

**Test plan (required)**
Tested using the UIExplorer RefreshControl example.

When doing a pull to refresh and then rotating the screen the RefreshControl must stay positioned properly.
Doing multiple consecutive pull to refresh without scrolling after should all behave the same.

Fixes #6311
Closes https://github.com/facebook/react-native/pull/6359

Differential Revision: D3023727

fb-gh-sync-id: f50ae52ea769c2b3e5025c362544a8809a71aa00
shipit-source-id: f50ae52ea769c2b3e5025c362544a8809a71aa00
2016-03-08 04:00:34 -08:00
Tadeu Zagallo 24c458aa08 Fix JS deallocation on load errors
Summary:Fixes #6281

The JS executor is invalidated from `[RCTBatchedBridger stopLoadingWithError:]`
which prevented another blocks that depended on the executor to run in the bridge
invalidation.

Reviewed By: javache

Differential Revision: D3018299

fb-gh-sync-id: 4f482b9b697bfabd24b405398d25c72b9e1a3c84
shipit-source-id: 4f482b9b697bfabd24b405398d25c72b9e1a3c84
2016-03-07 09:46:36 -08:00
Nick Lockwood 006907bdaa Initialize bridge on a background queue
Summary: This diff adds support for initializing the bridge on an arbitrary thread. This is helpful if you want to defer bridge creation, or prevent it from delaying your app startup.

Reviewed By: javache

Differential Revision: D2965725

fb-gh-sync-id: 8065fa89e850031c72ee4427351300986985e9de
shipit-source-id: 8065fa89e850031c72ee4427351300986985e9de
2016-03-07 09:31:26 -08:00
Martín Bigio cde58a61aa Rename dev menu option to Hot Reloading on boths ios and android
Reviewed By: sam-swarr

Differential Revision: D3013121

fb-gh-sync-id: 4fc5ff73425c1d896bc4fb0085d39b5eef7e0e94
shipit-source-id: 4fc5ff73425c1d896bc4fb0085d39b5eef7e0e94
2016-03-06 10:12:25 -08:00
Kyle Corbitt 2d27cf0ceb Don't warn when jsSchedulingOverhead is negative
Summary:This commit modifies the jsSchedulingOverhead warning to only fire if the JS clock is more than 5 seconds ahead of the native clock. This fixes the issue in #1598 for the common case when there's only a minor difference between the two clocks, while still keeping a sanity check if they're extremely off.

cc nicklockwood tadeuzagallo
Closes https://github.com/facebook/react-native/pull/5731

Differential Revision: D3014985

Pulled By: tadeuzagallo

fb-gh-sync-id: bf57e48b7d97ad02d2aefb6e5aac845824a6fdb0
shipit-source-id: bf57e48b7d97ad02d2aefb6e5aac845824a6fdb0
2016-03-04 17:30:06 -08:00
Eric Lo 8c25181c44 Add onShow callback for RCTModalHostView
Summary: Added ability to include a callback to the modal. The callback is invoked when the modal is shown.

Reviewed By: javache

Differential Revision: D3005212

fb-gh-sync-id: 12648e17bd1cf831daf65529b87ae8cfdb901c65
shipit-source-id: 12648e17bd1cf831daf65529b87ae8cfdb901c65
2016-03-03 12:43:36 -08:00
Nick Lockwood dc13115445 Dispatch module setup asynchronously to avoid blocking main thread when bridge starts
Summary:Initializing native modules can block the main thread for tens of milliseconds when it starts up, making it difficult to instantiate the bridge on demand without causing a performance blip.

This diff splits up the initialization of modules so that - although they still happen on the main thread - they don't block the thread continuously.

Reviewed By: javache

Differential Revision: D2965438

fb-gh-sync-id: 38c9c9d281e4672b5874d68b57d4c60d1d268344
shipit-source-id: 38c9c9d281e4672b5874d68b57d4c60d1d268344
2016-03-03 02:21:36 -08:00
Eloy Durán 6bae7f93f5 Add suggested ‘view size’ powers to -[RCTShadowView setFrame:]
Summary:The UICollectionView example is actually my use-case, which is discussed in a
bit more detail [here](https://github.com/alloy/ReactNativeExperiments/issues/2).

----

This is useful when wrapping native iOS components that determine their
own suggested size and which would be too hard/unnecessary to replicate
in the shadow view. For instance a `UICollectionView` that after layout
will update its `contentSize`, which could be used to suggest a size to
the shadow view.

The reason for adding it to -[RCTShadowView setFrame:] is mainly so it
can be used via the existing -[RCTUIManager setFrame:forView:] API and
because it might not be a feature you want to expose too prominently.

An origin of `{ NAN, NAN }` is used as a sentinel to indicate that the
frame should be used as a size suggestion. The size portion of the rect
may contain a `NAN` to skip that dimension or a suggested value for the
dimension which will be used if no explicit styling has been assigned.

Examples:

* Without any expl
Closes https://github.com/facebook/react-native/pull/6114

Differential Revision: D2994796

Pulled By: nicklockwood

fb-gh-sync-id: 6dd3dd86a352ca7d31a0da38bc38a2859ed0a410
shipit-source-id: 6dd3dd86a352ca7d31a0da38bc38a2859ed0a410
2016-03-01 10:14:32 -08:00
Nick Lockwood 35da174339 Added unit tests for module init
Summary: The module initialization process is complex and full of race conditions. This diff adds a set of unit tests that verify that modules setup happens in the correct order, and enforces all the various conditions for main/background init.

Reviewed By: javache

Differential Revision: D2994145

fb-gh-sync-id: 92ea84508cdeeb280ff0fb9e9b2dffa8dbc37e66
shipit-source-id: 92ea84508cdeeb280ff0fb9e9b2dffa8dbc37e66
2016-03-01 09:44:37 -08:00
Pieter De Baets f67fa82008 Add UIManager.measureInWindow to get window coordinates
Summary: When embedding in a hybrid app, we sometimes present new modal views or windows that have a different frame from the original root view. This API allows us to get coordinates in the application's window frame, which should be valid in any fullscreen view.

Reviewed By: majak

Differential Revision: D2939827

fb-gh-sync-id: 06b93cc2cb3519a25819c6efa445c779314dd673
shipit-source-id: 06b93cc2cb3519a25819c6efa445c779314dd673
2016-03-01 06:51:33 -08:00
Marc Horowitz ffdd3e43b0 remove dead code
Summary: This property is now in the bridge.

Reviewed By: tadeuzagallo

Differential Revision: D2985894

fb-gh-sync-id: 38821e0c5998bc96fc8f6164fbbc82c721f5c5ad
shipit-source-id: 38821e0c5998bc96fc8f6164fbbc82c721f5c5ad
2016-02-29 10:09:54 -08:00
Marc Horowitz f331a58ed0 Move initialization of RCTBatchedBridge into its own method.
Summary: This makes room for local development without touching OSS code.

Reviewed By: tadeuzagallo

Differential Revision: D2986122

fb-gh-sync-id: 2f23088a078b0f0fb4b74946490fd5b67b01c0ac
shipit-source-id: 2f23088a078b0f0fb4b74946490fd5b67b01c0ac
2016-02-29 10:05:57 -08:00
Nick Lockwood d7d47d8120 Defer constants gathering until after setup
Reviewed By: javache

Differential Revision: D2986095

fb-gh-sync-id: 1f449e69ca74466e7951d621ceaf624abe034139
shipit-source-id: 1f449e69ca74466e7951d621ceaf624abe034139
2016-02-29 09:50:32 -08:00
Nick Lockwood 8d44c2db4f Fix bridge tests
Summary:The `RCTDevMenu.hotLoadingAvailable` check always returned YES if `bridge.bundleURL` was nil. This caused the `setHotLoadingEnabled:` method to repeatedly reload the bridge, resulting in the following tests failing:

`- [RCTBridgeTests testHookRegistration];`
`- [RCTBridgeTests testCallNativeMethod];`

Also, the `RUN_RUNLOOP_WHILE()` macro did not actually assert when timing out, and the logic in `- [RCTBridgeTests tearDown];` was broken in such a way that tests would always take 5 seconds to run (and then timeout silently). This adds an assertion, and removes the broken nil check for `jsExecutor`.

Reviewed By: majak

Differential Revision: D2988885

fb-gh-sync-id: 91307585ac8acb0181f0cddeeddf6cb4b198e4fe
shipit-source-id: 91307585ac8acb0181f0cddeeddf6cb4b198e4fe
2016-02-29 09:26:06 -08:00
Walter Luh 8a042f4654 Minor path change for message socket between packager and bridge (3/N)
Summary: New path is '{base_url}/message?role=shell'

Reviewed By: javache

Differential Revision: D2957640

fb-gh-sync-id: 2994857d874fd2314c9056e71acda008573911eb
shipit-source-id: 2994857d874fd2314c9056e71acda008573911eb
2016-02-26 18:18:32 -08:00
Martín Bigio 4b98511a3e Remove gating code for HMR on iOS
Reviewed By: javache

Differential Revision: D2977197

fb-gh-sync-id: 001447ad0b0275f5de6f6454aa8cd0b1c34ce3d8
shipit-source-id: 001447ad0b0275f5de6f6454aa8cd0b1c34ce3d8
2016-02-26 09:38:01 -08:00
Nick Lockwood 7032a640e7 Fix WebView example on iOS
Summary: Fixed broken scaling logic in Webview example for iOS. Pages must be reloaded after toggling `scalesPageToFit`, but that wasn't happening.

Reviewed By: javache

Differential Revision: D2982371

fb-gh-sync-id: 8442609179bfe9ade10d1d0bac1807e4a8855d00
shipit-source-id: 8442609179bfe9ade10d1d0bac1807e4a8855d00
2016-02-26 08:20:34 -08:00
Nick Lockwood f7df3bb78a Removed eager init of all ViewManagers on layout
Summary:The `uiBlockToAmendWithShadowViewRegistry:` is called on every single view manager, on every single layout pass. This causes all view managers to be eagerly intiialized, even if not being used.

In practice very few modules actually use this method, so by checking if the method is implemented before calling it, we can eliminate most of this work.

(Hopefully in future we can get ride of this method altogether, but right now it's integral to the way that text layout is implemented).

Reviewed By: majak, javache

Differential Revision: D2982181

fb-gh-sync-id: 818d0aac61197df89263c919c2c80a003e293ac5
shipit-source-id: 818d0aac61197df89263c919c2c80a003e293ac5
2016-02-26 08:18:34 -08:00
wenzhao.yin 50141f9d3f fix RCTPerfMonitor display unit error
Summary:The  RCTPerformanceLogger log the time in ms not us. Especially the unit of RCTPLBundleSize is byte.
Closes https://github.com/facebook/react-native/pull/5919

Differential Revision: D2982116

Pulled By: nicklockwood

fb-gh-sync-id: 18aad5ff2eb83c6f302b2c10382bf214b51df133
shipit-source-id: 18aad5ff2eb83c6f302b2c10382bf214b51df133
2016-02-26 04:54:32 -08:00
Pieter De Baets 45a52c72ff Support multiple interface orientations in RCTDevLoadingView
Summary: When rotating on iPad, the dev loading view just looks clowny since it doesn't rotate properly.

Reviewed By: majak

Differential Revision: D2939721

fb-gh-sync-id: 7f1926f5cee4761cde8881e9387ae6e0063c5d6c
shipit-source-id: 7f1926f5cee4761cde8881e9387ae6e0063c5d6c
2016-02-25 09:52:30 -08:00
Pieter De Baets f51c16b270 Avoid dirtying layout when frame doesn't change
Reviewed By: nicklockwood

Differential Revision: D2939782

fb-gh-sync-id: e2346f053e9594e5d24d1e73d493a34446fb228c
shipit-source-id: e2346f053e9594e5d24d1e73d493a34446fb228c
2016-02-25 09:39:29 -08:00
Nick Lockwood 4b4455f827 Removed 'screen' option from snapshot API
Summary:Unfortunately the 'screen' option in the `UIManager.takeSnapshot` API appears to work only on the iOS simulator, not on an actual device.

This diff removes the 'screen' option until a solution can be found that works on the device.

(Taking a snapshot of the window still works fine - it just won't include the status bar, etc.)

Reviewed By: javache

Differential Revision: D2971091

fb-gh-sync-id: 026b9d4eb2f59f686f58c18a16381ff325df612b
shipit-source-id: 026b9d4eb2f59f686f58c18a16381ff325df612b
2016-02-24 09:06:31 -08:00
Nick Lockwood ac12f98689 Added support for taking snapshots of the screen, window or individual views
Summary:This adds a `takeSnapshot` method to UIManager that can be used to capture screenshots as an image.

The takeSnapshot method accepts either 'screen', 'window' or a view ref as an argument.

You can also specify the size, format and quality of the captured image.

I've added an example of capturing a screenshot at UIExplorer > Snapshot / Screenshot.
I've also added an example of sharing a screenshot to the UIExplorer > ActionSheetIOS demo.

Reviewed By: javache

Differential Revision: D2958351

fb-gh-sync-id: d2eb93fea3297ec5aaa312854dd6add724a7f4f8
shipit-source-id: d2eb93fea3297ec5aaa312854dd6add724a7f4f8
2016-02-23 02:26:33 -08:00
Pieter De Baets 7964d80759 Replace ModalFullscreenView constants by Dimensions
Reviewed By: jingc

Differential Revision: D2954172

fb-gh-sync-id: 8b2f68d13632de25830678ddc32a36c239970427
shipit-source-id: 8b2f68d13632de25830678ddc32a36c239970427
2016-02-22 05:29:32 -08:00
Pieter De Baets eb2cd077a9 Support rotation in RCTModalHostView
Summary: When rotating a modal view we should adjust the root view's frame.

Reviewed By: majak

Differential Revision: D2939712

fb-gh-sync-id: 974634276d2c0ad22b46976020d0a21e1dac9026
shipit-source-id: 974634276d2c0ad22b46976020d0a21e1dac9026
2016-02-22 04:44:34 -08:00
Nick Lockwood f961b78c51 Set WebView baseURL to 'about:blank' instead of nil
Reviewed By: javache

Differential Revision: D2953831

fb-gh-sync-id: 2b11353ee453711f32e19011c13d89c128fa16ab
shipit-source-id: 2b11353ee453711f32e19011c13d89c128fa16ab
2016-02-19 06:44:00 -08:00
Janic Duplessis 671b975d92 Fix a bug with ListView with sticky headers + RefreshControl
Summary:The bug is caused by a weird race condition. What happens is that when calling `UIRefreshControl#endRefreshing` the `UIScrollView` delegate `scrollViewDidScroll` function is called synchronously and then `dockClosestSectionHeader` crashes because the sticky header indexes are updated but not the contentView children.

I fixed it by adding an updating property on `RCTRefreshControl` and setting it before calling `endRefreshing` so we can know not to call `dockClosestSectionHeader` at that moment.

Tested with both `RefreshControl` and `onRefreshStart` prop.

I reproduced the bug by replacing ListViewExample.js in UIExplorer with https://gist.github.com/janicduplessis/05fc58e852f3e80e51b9

Fixes #5440

cc nicklockwood
Closes https://github.com/facebook/react-native/pull/5445

Differential Revision: D2953984

Pulled By: nicklockwood

fb-gh-sync-id: c17a6a75ab31ef54d478706ed17a8115a11d734e
shipit-source-id: c17a6a75ab31ef54d478706ed17a8115a11d734e
2016-02-19 05:55:36 -08:00
Pieter De Baets f9e81d9bcc Fix OSS iOS build
Reviewed By: majak

Differential Revision: D2943923

fb-gh-sync-id: d0a827780ee93a1e702295198c65729b1a72f045
shipit-source-id: d0a827780ee93a1e702295198c65729b1a72f045
2016-02-17 07:38:33 -08:00
Walter Luh dab24b4a6c Enable persistent socket between packager and bridge (1/N).
Reviewed By: javache

Differential Revision: D2920590

fb-gh-sync-id: 120d812d1e9bcb79b186d3e41e8f7e153ca34f8b
shipit-source-id: 120d812d1e9bcb79b186d3e41e8f7e153ca34f8b
2016-02-16 23:05:36 -08:00
Jesse Ruder 0176ac488e Add hitSlop prop on iOS and Android
Summary:New prop `hitSlop` allows extending the touch area of Touchable components. This makes it easier to touch small buttons without needing to change your styles.

It takes `top`, `bottom`, `left`, and `right` same as the `pressRetentionOffset` prop. When a touch is moved, `hitSlop` is combined with `pressRetentionOffset` to determine how far the touch can move off the button before deactivating the button.

On Android I had to add a new file `ids.xml` to generate a unique ID to use for the tag where I store the `hitSlop` state. The iOS side is more straightforward.

terribleben worked on the iOS and JS parts of this diff.

Fixes #110
Closes https://github.com/facebook/react-native/pull/5720

Differential Revision: D2941671

Pulled By: androidtrunkagent

fb-gh-sync-id: 07e3eb8b6a36eebf76968fdaac3c6ac335603194
shipit-source-id: 07e3eb8b6a36eebf76968fdaac3c6ac335603194
2016-02-16 16:51:39 -08:00
Nick Lockwood 0427c3d273 Added throttling on requests made by RCTImageLoader
Reviewed By: javache

Differential Revision: D2938143

fb-gh-sync-id: bac1185d4792dcca0012905126c9ef2aa45905d5
shipit-source-id: bac1185d4792dcca0012905126c9ef2aa45905d5
2016-02-16 12:42:34 -08:00
Scott Kyle e5ba46c30d Expose way for native modules to modify JSC context
Reviewed By: svcscm

Differential Revision: D2933197

fb-gh-sync-id: 32eb943ab341804343bbcadd29f0377fccf75de6
shipit-source-id: 32eb943ab341804343bbcadd29f0377fccf75de6
2016-02-15 12:58:29 -08:00
Nick Lockwood 194273f5f5 Fixed hitTest crash due to sticky header out-of-range
Reviewed By: javache

Differential Revision: D2932227

fb-gh-sync-id: 05d69ec391685dd7e72d3d5f7d56b189a6eab413
shipit-source-id: 05d69ec391685dd7e72d3d5f7d56b189a6eab413
2016-02-12 09:28:21 -08:00
Nick Lockwood 313d84d507 Allocate RCTRootView.reactTag when it's first requested, instead of waiting until bundle has loaded.
Reviewed By: javache

Differential Revision: D2931937

fb-gh-sync-id: 1cc421a30028e3de1b2d22143edd645d8a34e4d4
shipit-source-id: 1cc421a30028e3de1b2d22143edd645d8a34e4d4
2016-02-12 08:32:36 -08:00
Adam Miskiewicz e018aa3100 Enable HMR
Reviewed By: svcscm

Differential Revision: D2932137

fb-gh-sync-id: 8bfab09aaac22ae498ac4fa896eee495111abc0d
shipit-source-id: 8bfab09aaac22ae498ac4fa896eee495111abc0d
2016-02-12 08:10:33 -08:00
Pieter De Baets 84f51da123 Make JS async always the top thread in systrace
Reviewed By: tadeuzagallo

Differential Revision: D2905828

fb-gh-sync-id: b64cbe6b41771dc94d8d7e6d3610af845b4383f0
shipit-source-id: b64cbe6b41771dc94d8d7e6d3610af845b4383f0
2016-02-12 03:50:35 -08:00
Dave Miller d96a4ba94d Minor fixes to clipboard and Linking to remove TODOs
Reviewed By: nicklockwood

Differential Revision: D2921782

fb-gh-sync-id: e387b720421ed6ed03a50633d71e08791f87c761
shipit-source-id: e387b720421ed6ed03a50633d71e08791f87c761
2016-02-10 12:25:51 -08:00
Dave Miller c9a1956c4f Fix promises on iOS to no longer wrap values in Arrays
Summary:
public
In 9baff8f437 (diff-8d9841e5b53fd6c9cf3a7f431827e319R331), I incorrectly assumed that iOS was wrapping promises in an extra Array.  What was really happening is that all the callers were doing this.  I removed the wrapping in the callers and the special case handling MessageQueue.

Now one can pass whatever object one wants to resolve and it will show properly in the resolve call on the js side.  This fixes issue https://github.com/facebook/react-native/issues/5851

Reviewed By: nicklockwood

Differential Revision: D2921565

fb-gh-sync-id: 9f81e2a87f6a48e9197413b843e452db345a7ff9
shipit-source-id: 9f81e2a87f6a48e9197413b843e452db345a7ff9
2016-02-10 07:25:35 -08:00
slycoder 758d9e8304 Add observers for local notifications
Summary:
This commit adds the delegate hooks so that local notifications get
passed onto the JS and adds a new event listener type for local
notifications.

Also add functions to clear local notifications
Closes https://github.com/facebook/react-native/pull/2084

Reviewed By: svcscm

Differential Revision: D2908096

Pulled By: nicklockwood

fb-gh-sync-id: 759d299ea35abea177e72934076297d666d3ea20
shipit-source-id: 759d299ea35abea177e72934076297d666d3ea20
2016-02-09 05:46:33 -08:00
Nick Lockwood 855d411321 Moved constants export to bridge init
Summary:
public
Lazy export of module constants required a sync dispatch to the main thread, which was deadlocking in some of our projects.

This moves the constants export to the initial bridge init, which may slightly increase initial startup time, but avoids the deadlock.

Reviewed By: javache

Differential Revision: D2911295

fb-gh-sync-id: 0d14a629ac4fc7ee21acd293c09595c18232659b
shipit-source-id: 0d14a629ac4fc7ee21acd293c09595c18232659b
2016-02-09 03:30:32 -08:00
Tadeu Zagallo c00049ce4f Expose flow events to JS + add JS -> Native flows
Summary:
public

Expose JS hooks to create flow events in systrace (the nice arrows to show async work flow) +
add support to the showing all the work enqueued from the JS thread as added in D2743733

Depends on D2743733

Reviewed By: jspahrsummers

Differential Revision: D2815293

fb-gh-sync-id: 4278f61a67a6e78cf2704bacce34b1389328c6df
2016-02-08 07:07:34 -08:00
Janic Duplessis 3e1f1ea7bb Allows RefreshControl to be mounted with refreshing = true
Summary:
RefreshControl did not start refreshing when refreshing was set to true initially. It also did not start refreshing on iOS when setting the prop from false to true without doing a pull to refresh gesture.

This was a pain in the ass to make work on iOS because UIRefreshControl seems super sensitive to when beginRefreshing can be called, for the initial render I need to call it in layoutSubviews. I also have to manually adjust the scrollview content offset when calling beginRefreshing. The code is a bit hacky but it was the only solution I found that was actually working.

Fixes #5716
Closes https://github.com/facebook/react-native/pull/5745

Reviewed By: svcscm

Differential Revision: D2910716

Pulled By: nicklockwood

fb-gh-sync-id: d60e73bcfe8d86bb01249ba5f17e6a23c5a5aff6
2016-02-07 13:40:29 -08:00
Christopher Chedeau 375abc3f06 More helpful description for native-js prop mismatch
Summary:
Similar as https://github.com/facebook/react-native/pull/5605
Closes https://github.com/facebook/react-native/pull/5673

Reviewed By: svcscm

Differential Revision: D2908218

Pulled By: nicklockwood

fb-gh-sync-id: da5e42ea660df2c0bb60165c7429d480414a0a20
2016-02-05 16:34:30 -08:00
Christopher Chedeau 58738483ab Stop spamming the logs
Summary:
We should have 0 logs at startup. In theory it could be useful to know if the profiler is enabled, but in practice 99% of the time you don't care and it ends up spamming you for no good reason. Then more people add logs and not only do the logs are not useful, they prevent people from actually using them when debugging.
Closes https://github.com/facebook/react-native/pull/5766

Reviewed By: svcscm

Differential Revision: D2902987

Pulled By: androidtrunkagent

fb-gh-sync-id: d47f8e58edf5f2c8e2a7a4373fd7d9036d2309a0
2016-02-04 15:33:35 -08:00
Ian Cervantez 98373ac6e3 Conditionally allowing showCompass view property
Summary:
Only allow the showsCompass view property when iOS 9+ is used.  Fixes #5706.
Closes https://github.com/facebook/react-native/pull/5708

Reviewed By: svcscm

Differential Revision: D2896322

Pulled By: nicklockwood

fb-gh-sync-id: 16b789d3516ad1ff7189d6ceab4300039ce2a76b
2016-02-03 11:36:36 -08:00
Janic Duplessis 34389c529d Fix sticky headers position when scrolling while RefreshControl is refreshing
Summary:
When scrolling while RefreshControl is refreshing the sticky headers are offset by the height of the UIRefreshControl. This simply removes the height of the UIRefreshControl while it is refreshing and fixes the problem.

You can repro the bug using this example in UIExplorer by doing a pull to refresh and scrolling the ListView immediately after.
https://gist.github.com/janicduplessis/26b4f2758e90b2aa1620

Fixes #5405
Closes https://github.com/facebook/react-native/pull/5517

Reviewed By: svcscm

Differential Revision: D2895623

Pulled By: nicklockwood

fb-gh-sync-id: 81df36cccfc3e7b973c2be78565f8b8408c9fc12
2016-02-03 08:00:42 -08:00
Pieter De Baets 41f5a21b56 Improve systrace markers
Reviewed By: jspahrsummers

Differential Revision: D2851737

fb-gh-sync-id: 4aa0872e7d56d59de2fa42b87a795b2d64e0faa0
2016-02-03 07:11:35 -08:00
Martin Kralik fff4688423 fix UIExplorer project
Summary:
I forgot to add new files manually to `React.xcodeproj` (it's not managed by buck).

public

Reviewed By: javache

Differential Revision: D2895546

fb-gh-sync-id: ed58e3505c269f5ed9433e94994471485adb2378
2016-02-03 07:10:33 -08:00
Martin Kralik 2e8eb652e1 coalesce "touchMove" events (7/7)
Summary:
This is a final diff in the stack, which makes us not send a bazillion events to js after it's been busy while an user dragged his finger on a screen (resulting in ~two events per frame).
I made "touchMove" event to be coalescable, which makes us not send anything while dragging (since this makes both scroll events and touch move events coalesced and not being  send until either next js frame or the next different touch event occurs).

This change is far from perfect. The event name is a hard coded string and the coalescing works with some (reasonable) assumptions on internal structure of these touch events. Which may or may not be really true. It would be great if someone could comment on these.
I'm thinking about making the touches more strongly typed. Any thoughts on this?

public
___
//This diff is part of a larger stack. For high level overview what's going on jump to D2884593.//

Reviewed By: nicklockwood

Differential Revision: D2884595

fb-gh-sync-id: f3c2f13430679e2bf52e0c7a3689650b3acae42f
2016-02-03 05:24:14 -08:00
Martin Kralik 4aaa35a22e use RCTEventDispatcher for touch events (6/7)
Summary:
This diff finally makes touch events to be emitted to js from the same object as scroll events. Thanks to changes in previous diffs this means the js will now process them in the right order.

This diff on its own would cause us to send events to js on every frame while dragging a finger on the screen. This is something we tried to avoid with event coalescing in the past, and gets fixed in the following diff D2884595.

public
___
**This diff is part of a larger stack. This is a high level overview about what’s going on here.**

This stack of diffs fixes an issue where scroll events and touch events wouldn’t be processed in the correct order on js side.
Current state of world:
* touch events are send to js immediately when they happen (this makes js respond to touches as soon as possible)
* scroll events are buffered, coalesced and send at the beginning of each js frame (coalescing helps in a case where js is busy processing for several native frames and would get all scroll event for that period afterwards)

How did I change this?
1. I’ve made touch events go through the same class every other event (scroll events included) go, RCTEventDispatcher. This gives us a single place to handle all events.
2. I’ve changed RCTEventDispatcher to flush all buffered events every time it gets a touch event before dispatching the touch. This fixes the original ordering issue.
3. I’ve made “touchMove” behave the same way as scroll events do - they are buffered and coalesced. Since “touchMove” events are fired as often as scroll events (while you drag your finger around), doing only 2. would bring back the issue buffering was fixing.
All of this together effectively still keeps the order of events right, avoids overloading js in the important case we care about. The only downside is an increased latency for “touchMove” events, since they are to longer send to js immediately.

(Even better solution would be changing the native->js event passing system to be pull based instead of push based. That way js would always request touches that has happened since the last time it has asked, which would make it get them as soon as it’s possible to process them and native could do coalescing at that point.
However this change has a much bigger scope, so I’m going with this stack of diffs for now.)

Reviewed By: nicklockwood

Differential Revision: D2884593

fb-gh-sync-id: 749a4dc6256f93fde0d8733687394b080ddd4484
2016-02-03 05:24:08 -08:00