Commit Graph

902 Commits

Author SHA1 Message Date
Janic Duplessis 18394fb179 Initial implementation of requestIdleCallback on Android
Summary:
This is a follow up of the work by brentvatne in #5052. This addresses the feedback by astreet.

- Uses ReactChoreographer with a new callback type
- Callback dispatch logic moved to JS
- Only calls into JS when needed, when there are pending callbacks, it even removes the Choreographer listener when no JS context listen for idle events.

** Test plan **
Tested by running a background task that burns all remaining idle time (see new UIExplorer example) and made sure that UI and JS fps stayed near 60 on a real device (Nexus 6) with dev mode disabled. Also tried adding a JS driven animation and it stayed smooth.

Tested that native only calls into JS when there are pending idle callbacks.

Also tested that timers are executed before idle callback.
```
requestIdleCallback(() => console.log(1));
setTimeout(() => console.log(2), 100);
burnCPU(1000);
// 2
// 1
```

I did *not* test with webworkers but it should work as I'm using executor tokens.
Closes https://github.com/facebook/react-native/pull/8569

Differential Revision: D3558869

Pulled By: astreet

fbshipit-source-id: 61fa82eb26001d2b8c2ea69c35bf3eb5ce5454ba
2016-07-13 18:58:20 -07:00
Chris Hopman c89c25f27d Make new bridge default in OSS
Reviewed By: bestander

Differential Revision: D3553208

fbshipit-source-id: 35d466e87032618978230b118772e366ba1deea9
2016-07-13 16:13:19 -07:00
Emil Sjolander 8dd8c41553 Point csslayout deps over to xplat
Reviewed By: bestander

Differential Revision: D3555221

fbshipit-source-id: cad4c74f4780c6d636fd244f7a4dcd1806241b25
2016-07-13 14:28:45 -07:00
Emil Sjolander 86e304f6a3 Move csslayout into xplat
Reviewed By: lucasr

Differential Revision: D3509483

fbshipit-source-id: dfd0b00002b7da6432667b4a795edb5a15cf9a88
2016-07-13 10:28:27 -07:00
Philipp von Weitershausen 08c375f828 Add responseType as a concept to RCTNetworking, send binary data as base64
Summary:
In preparation for Blob support (wherein binary XHR and WebSocket responses can be retained as native data blobs on the native side and JS receives a web-like opaque Blob object), this change makes RCTNetworking aware of the responseType that JS requests. A `xhr.responseType` of `''` or `'text'` translates to a native response type of `'text'`. A `xhr.responseType` of `arraybuffer` translates to a native response type of `base64`, as we currently lack an API to transmit TypedArrays directly to JS. This is analogous to how the WebSocket module already works, and it's a lot more versatile and much less brittle than converting a JS *string* back to a TypedArray, which is what's currently going on.

Now that we don't always send text down to JS, JS consumers might still want to get progress updates about a binary download. This is what the `'progress'` event is designed for, so this change also implements that. This change also follows the XHR spec with regards to `xhr.response` and `xhr.responseText`:

- if the response type is `'text'`, `xhr.responseText` can be peeked at by the JS consumer. It will be updated periodically as the download progresses, so long as there's either an `onreadystatechange` or `onprogress` handler on the XHR.

- if the response type is not `'text'`, `xhr.responseText` can't be accessed and `xhr.response` remains `null` until the response is fully received. `'progress'` events containing response details (total bytes, downloaded so far) are dispatched if there's an `onprogress` handler.

Once Blobs are landed, `xhr.responseType` of `'blob'` will correspond to the same native response type, which will cause RCTNetworking to only send a blob ID down to JS, which can then create a `Blob` object from that for consumers.

Closes https://github.com/facebook/react-native/pull/8324

Reviewed By: javache

Differential Revision: D3508822

Pulled By: davidaurelio

fbshipit-source-id: 441b2d4d40265b6036559c3ccb9fa962999fa5df
2016-07-13 04:58:37 -07:00
sathya 33a1f28654 Android WebView “tel:” links show web page not found - issue fixed
Summary:
Submitting PR #6810 -  Android WebView “tel:” links show web page not found - issue fixed.
'tel:' link web page not loading:
![screenshot_2016-07-01-19-48-05](https://cloud.githubusercontent.com/assets/11989113/16525364/b3e9f10c-3fc9-11e6-8119-93cdf24d54df.png)

After Fixing the issue:
![screenshot_2016-07-01-19-52-00](https://cloud.githubusercontent.com/assets/11989113/16525371/c0d74d92-3fc9-11e6-899b-570a940692f6.png)
Closes https://github.com/facebook/react-native/pull/8526

Differential Revision: D3554500

fbshipit-source-id: e8cc1ac4c36ddf0c6b261a29b2e038caddc03e75
2016-07-12 22:13:25 -07:00
Konstantin Raev 0d3c4f8e5e Temporarily enable ReactHorizontalScrollViewTestCase to run in SandCastle
Reviewed By: emilsjolander

Differential Revision: D3548925

fbshipit-source-id: f56a812316470f1ee4b6a53a83b439bf66f5035f
2016-07-12 08:58:24 -07:00
Michał Gregorczyk 1331e20db5 add API to CatalystInstanceImpl for executing optimized bundle
Reviewed By: tadeuzagallo

Differential Revision: D3545345

fbshipit-source-id: 538fec77b816c3fd767e8c2eda81c78971996b17
2016-07-12 08:13:32 -07:00
Michał Gregorczyk a665914d18 Unpack files required by optimized bundle format
Reviewed By: tadeuzagallo

Differential Revision: D3522855

fbshipit-source-id: 2d14db33ce9b98ea1aeea5a12e292e5926e43796
2016-07-12 08:13:32 -07:00
Michał Gregorczyk e632025917 Allow apps to provide JSBundleLoader of their choice
Reviewed By: tadeuzagallo

Differential Revision: D3522798

fbshipit-source-id: 90324e44a02ad78885ff3c2a33ba58d4ee6a021a
2016-07-12 08:13:31 -07:00
Tim Yung ed4db631fa RN: Change Time Drift Error into Warning
Summary: Changes the time drift error into a warning that will only get logged once per debugging session.

Reviewed By: jingc

Differential Revision: D3539067

fbshipit-source-id: 357db15750d867a91c39b5fc5fd6ed4ae2852bc7
2016-07-11 10:28:27 -07:00
Andy Street 6d3c7b8a4c Fix 'Unexpected EOF' in old bridge
Summary: This is caused by receiving \u2028/2029 in callbacks/function calls. The correct solution is to not evaluate these strings as scripts but instead parse them as json and pass them through the JSC API.

Reviewed By: lexs

Differential Revision: D3543098

fbshipit-source-id: 4d8acce1d510bb17361d32103d4738fc0208b0a8
2016-07-11 09:58:27 -07:00
Tadeu Zagallo 5d06918d07 Add new FileSourceProvider
Summary: Add a new interface to JSC that allows loading a file lazily from disk, i.e. using mmap, instead of loading the whole file upfront and copying into the VM.

Reviewed By: michalgr

Differential Revision: D3534042

fbshipit-source-id: 98b193cc7b7e33248073e2556ea94ce3391507c7
2016-07-11 06:58:26 -07:00
Emil Sjolander 70b989eb67 Revert land of css-layout PR #199
Reviewed By: bestander

Differential Revision: D3536627

fbshipit-source-id: e89b2a5fd38d1228bd8526c46bb26c594947837a
2016-07-08 16:48:13 -07:00
Michał Gregorczyk dd06b74157 Make SoLoader an external dependency
Reviewed By: bestander

Differential Revision: D3535233

fbshipit-source-id: 9fddb654123a7606d46069a98e2f68dec7f520fa
2016-07-08 16:48:13 -07:00
Emil Sjolander ca66383941 Correctly size cross axis when measuring flex basis
Summary:
https://github.com/facebook/css-layout/pull/199

- Nodes were measured with the assumption of being text nodes (height depends on width) when determining flex basis. This is not always true. Even when we are just interested in the main axis (flex basis) we need to correctly constrain the cross axis.
- Some tests were wrong. Measuring texts.big and expecting it to have textSizes.smallHeight which doesn't make a lot of sense.

Reviewed By: vjeux

Differential Revision: D3510163

fbshipit-source-id: ee53b548dd078005fdd153d279e4c7fef3dd02d0
2016-07-08 09:28:35 -07:00
Emil Sjolander 89a53b687c Use AT_MOST measurespec when onyl max dimension is defined
Summary:
https://github.com/facebook/css-layout/pull/200
Make use of max dimension styles to allow root to be measured with AT_MOST measure mode

Reviewed By: IanChilds

Differential Revision: D3513505

fbshipit-source-id: 169f49717e896eb6270b52fb7115ce005aa0e3a8
2016-07-08 03:58:28 -07:00
Clement Genzmer 80c23ae324 Reverted commit D3207541
Reviewed By: michalgr

Differential Revision: D3207541

fbshipit-source-id: 36366188b7cb74c51d4aa974abd4a648498bcf78
2016-07-07 14:58:43 -07:00
Andy Street b5c3550857 Don't hard crash if you get a null stack trace in Android
Summary: If stacktrace-parser can't parse a stack trace, it'll return null. This can cause us to accidentally enter a crash loop where whenever you start your app, you load the last JS bundle you had, get a crash, and then hard crash trying to print the stack trace.

Reviewed By: frantic

Differential Revision: D3528141

fbshipit-source-id: 1146f43bc40492bfa79b6a1c0f81092383896164
2016-07-07 09:15:04 -07:00
Janic Duplessis 2537157d99 Implement TextInput onContentSizeChange
Summary:
This adds proper support for tracking a TextInput content size as discussed in #6552 by adding a new callback that is called every time the content size changes including when first rendering the view.

Some points that are up for discussion are what do we want to do with the onChange callback as I don't see any use left for it now that we can track text change in onChangeText and size changes in onContentSizeChange. Also a bit off topic but should we consider renaming onChangeText to onTextChange to keep the naming more consistent (see [this naming justification](https://twitter.com/notbrent/status/709445076850597888)).

This is split in 2 commits for easier review, one for iOS and one for android.

The iOS implementation simply checks if the content size has changed everytime we update it and fire the callback, the only small issue was that the content size had several different values on initial render so I added a check to not fire events before the layoutSubviews where at this point the value is g
Closes https://github.com/facebook/react-native/pull/8457

Differential Revision: D3528202

Pulled By: dmmiller

fbshipit-source-id: fefe83f10cc5bfde1f5937c48c88b10408e58d9d
2016-07-07 09:00:01 -07:00
Alexander Blom be0abd17e5 Remove a bunch of copies
Reviewed By: astreet

Differential Revision: D3475592

fbshipit-source-id: 37148bb8d8d47e9301ad549b183029337f7c4ca0
2016-07-07 09:00:01 -07:00
Alexander Blom 95401aba72 Create tracing name in C++ instead of Java
Reviewed By: mhorowitz

Differential Revision: D3469140

fbshipit-source-id: 77a00a7150573e44f219972556cbb936a57d7054
2016-07-07 09:00:00 -07:00
Tadeu Zagallo af24e8001a Add new FileSourceProvider
Reviewed By: michalgr

Differential Revision: D3207541

fbshipit-source-id: d53599c3cf36ae7c89e85a29f637987bc7139159
2016-07-07 08:44:30 -07:00
Alexander Blom f11a783e64 Make packager reconnect less noisy
Reviewed By: frantic

Differential Revision: D3509012

fbshipit-source-id: 66742ebed80ecf48ce8291b1816ef0ec672febee
2016-07-07 08:44:29 -07:00
Mike Lambert 6779d13dcb Reverted commit D3528215
Summary:
So `PanReponder.onPanResponderRelease/onPanResponderTerminate` receive a `gestureState` object containing a `onPanResponderTerminate.vx/vy` property. On Android and iOS, they appear to be orders of magnitude different, which appear to be due to the different scale of timestamps that are used when generating touch events.

This pull request fixes the timestamps to be milliseconds on both platforms (since I assume iOS is the more authoritative one, and is the one that `react-native-viewpager`'s vx thresholds written written to compare against.)

As far as I can tell, the RN code doesn't use the `vx/vy` properties, so they should be okay. And looks like the RN code only cares about relative values of `startTimestamp/currentTimestamp/previousTimestamp` though, so should be fine too. it's quite possible there will be downstream android breakage with this change, particularly for those who are already compensating for the RN discrepancy.
Closes https://github.com/facebook/react-native/pull/8199

Differential Revision: D3528215

Pulled By: davidaurelio

fbshipit-source-id: d81732e50a5ece2168e8347309d8d52a0db42951
2016-07-07 08:16:26 -07:00
Mike Lambert 4f5c2b48fe Fix timestamps on android touch events to use milliseconds, to be consistent with iOS
Summary:
So `PanReponder.onPanResponderRelease/onPanResponderTerminate` receive a `gestureState` object containing a `onPanResponderTerminate.vx/vy` property. On Android and iOS, they appear to be orders of magnitude different, which appear to be due to the different scale of timestamps that are used when generating touch events.

This pull request fixes the timestamps to be milliseconds on both platforms (since I assume iOS is the more authoritative one, and is the one that `react-native-viewpager`'s vx thresholds written written to compare against.)

As far as I can tell, the RN code doesn't use the `vx/vy` properties, so they should be okay. And looks like the RN code only cares about relative values of `startTimestamp/currentTimestamp/previousTimestamp` though, so should be fine too. it's quite possible there will be downstream android breakage with this change, particularly for those who are already compensating for the RN discrepancy.
Closes https://github.com/facebook/react-native/pull/8199

Differential Revision: D3528215

Pulled By: dmmiller

fbshipit-source-id: cbd25bb7e7bb87fa77b661a057643a6ea97bc3f1
2016-07-07 05:59:43 -07:00
Marc Horowitz a7d032b707 Display JS exceptions and stacks in a red box
Reviewed By: astreet

Differential Revision: D3510875

fbshipit-source-id: a7042434b68cb849f5b0c4ef782befff6a27ef5c
2016-07-06 16:13:21 -07:00
Marc Horowitz 7f790dc0de Pull an updated version of fbjni into RN OSS
Differential Revision: D3521227

fbshipit-source-id: 57db97ea2af2b2c9e55f380ce05d9e78a5f9d48c
2016-07-06 12:58:42 -07:00
Dave Miller 8c9f190038 Fix Spacing lifecycle issue introduced by D3516692
Summary: D3516692 incorrectly assumed that the Spacing object was immutable.  This is not true as it can change in a measure pass on the shadow thread while the UI is displaying some other data.  This fixes it to just pull the values we need and pass them instead of the object.

Reviewed By: foghina

Differential Revision: D3523004

fbshipit-source-id: 056baecf60a9c2f2494d173a3c60396a93b97d42
2016-07-06 11:14:05 -07:00
Alexander Blom c57eb94b34 Execute init task on thread pool executor
Reviewed By: foghina

Differential Revision: D3522112

fbshipit-source-id: 8a0880d0e7bf3e0bce02c44e8d504f01ab47beb8
2016-07-06 10:43:24 -07:00
Dave Miller c3f2bba834 Fix padding with Text on Android
Summary: Text was not correctly respecting padding.  We would account for it when measuring, but then not actually apply the padding to the text.  This adds support for proper padding

Reviewed By: andreicoman11

Differential Revision: D3516692

fbshipit-source-id: 9a0991d89e9194c0e87af0af56c6631a6b95700a
2016-07-06 09:43:37 -07:00
Siqi Liu ac18025d7c Change the Exception Message of Time Drift
Summary: We prefer not showing the accurate time information in the exception message of time drift, in order to be able to group this kind of exception only by exception message.

Reviewed By: foghina

Differential Revision: D3515390

fbshipit-source-id: f38bf3091ba749d4daeae24f7d42653b76c3289c
2016-07-05 09:58:29 -07:00
David Aurelio bd60d828c5 Remove `node_modules/react` from the list of discoverable haste modules
Summary: This removes `node_modules/react` from the list of directories that are used for haste module resolutions. Modules required from React are now imported with `require('react/lib/…')`.

Reviewed By: astreet

Differential Revision: D3509863

fbshipit-source-id: 32cd34e2b8496f0a6676dbe6bb1eacc18124c01e
2016-07-05 06:44:33 -07:00
danielbasedow 4ac4f86bf5 Add ping to WebSocket
Summary:
Idle WebSocket connections get reset after a few minutes of inactivity. To prevent this, most WebSocket implementations offer sending special ping messages. This PR adds a method `sendPing()` to  WebSocket. Ping payloads are not supported.

Manual testing can be done by adding `connection.on('ping', _ => console.log('Received ping'));` to a ws connection or using a packet sniffer while sending pings.
Closes https://github.com/facebook/react-native/pull/8505

Differential Revision: D3516260

Pulled By: dmmiller

fbshipit-source-id: cfebf5899188ae53254d5be6b666a9075e0eed89
2016-07-05 05:58:23 -07:00
Andy Street 950cefa2d6 Add debug statements to UIManager
Summary: These are helpful for development and shouldn't affect anything when DEBUG=false

Reviewed By: lexs

Differential Revision: D3515015

fbshipit-source-id: 0bd5ff833f90fea8e70b3103eb1f9bc803bef27c
2016-07-05 04:28:21 -07:00
Konstantin Raev 1d86be3a6e Turned on old bridge for OSS
Summary:
This should revert back to using old bridge by default until we fix gradle script to build new bridge for OSS correctly
Closes https://github.com/facebook/react-native/pull/8539

Differential Revision: D3514263

Pulled By: bestander

fbshipit-source-id: db9e0232b9bde27206814212dedc487c366e3511
2016-07-03 14:43:20 -07:00
Konstantin Raev f78e819f20 Reverted commit D3510867
Differential Revision: D3510867

fbshipit-source-id: 365eb22e143f1c0eec6e4b8810c93dbb0e9fbbfa
2016-07-02 13:43:23 -07:00
Marc Horowitz 8b2adeaa2e Pull an updated version of fbjni into RN OSS
Differential Revision: D3510867

fbshipit-source-id: b4f3300ef003c57aa7d4f3513bca537c464f7647
2016-07-01 16:28:47 -07:00
Chris Hopman bf79f87895 Make the new bridge the default
Reviewed By: astreet

Differential Revision: D3507482

fbshipit-source-id: b62f3bf0fe1dd4f49594e441f4e00b9e20ec972b
2016-07-01 14:43:22 -07:00
Felix Oghina adea8d5fc9 use MultiSourceHelper in PhotoViewer
Reviewed By: andreicoman11

Differential Revision: D3509011

fbshipit-source-id: 96fe96f28da24efb00b98589cea28e6c9cfc7180
2016-07-01 10:58:34 -07:00
Felix Oghina 2ce76771b5 extract MultiSourceHelper
Reviewed By: andreicoman11

Differential Revision: D3505224

fbshipit-source-id: e731325af7fd0c1cbd600695607302c968e0f36e
2016-07-01 10:58:33 -07:00
Felix Oghina 3d4adb8c34 extract ImageSource class for sharing
Summary: Move ImageSource out of ReactImageView so it can be used by other views dealing with images. Make ResourceDrawableIdHelper static in the process.

Reviewed By: dmmiller

Differential Revision: D3505103

fbshipit-source-id: 776a5b22a6934eeaa370826cb71c00cd937d3187
2016-07-01 10:58:33 -07:00
Franklyn Tackitt 22fbb6d46d Remove iOS platform check for running devtools
Summary:
Currently, DevTools only work under ios (although this is undocumented!),
because the JavaScriptEngine initialization process skips setupDevTools() on
android.

DevTools work fine with Android, as tested on 0.26, 0.27, and 0.28 using
Nuclide's inspector.

For reference, the relevant issue on react-devtools.
Closes https://github.com/facebook/react-native/pull/8095

Reviewed By: bestander

Differential Revision: D3492788

Pulled By: andreicoman11

fbshipit-source-id: 1eda9196d7125da19a8d7baaab22b61b744ca629
2016-07-01 04:28:48 -07:00
Felix Oghina 010e1977a8 Promote ResourceDrawableIdHelper to new module
Summary:
Found a couple of places where we were copy-pasting the logic `ResourceDrawableIdHelper` had. This class was only available on the image module and it had package visibility. I moved it to its own module so that we can easily use it from others.

This diff is pretty simillar to 54ed44628d but it fixes a bug due to which we had to revert it.

Reviewed By: andreicoman11

Differential Revision: D3499062

fbshipit-source-id: f912f57e5ac21a9f30fe42067c784f49fa46ed48
2016-07-01 04:28:48 -07:00
Konstantin Raev 88bd5e4d90 Reverted commit D3428952
Reviewed By: frantic

Differential Revision: D3428952

fbshipit-source-id: 61e5195399746d6511719971121c7c63f87ef4f4
2016-07-01 02:13:21 -07:00
James Ide a8011bbfdc Set LayoutParams in ReactTextView to fix crash
Summary:
ReactTextView occasionally crashes when `setText` is called. Doing some cursory research, it looks like this could be a bug in Android. We also suspect it might be related to removeClippedSubviews though.

The LayoutParams don't actually matter because RN controls layout, but on occasion (haven't narrowed down what this is...) `mLayout` is non-null and triggers relayout during `setText`, which fails because the LayoutParams are null. jesseruder came up with this fix and it appears to be working well.

Stack trace: http://pastebin.com/P8VbxvPz
Closes https://github.com/facebook/react-native/pull/7011

Differential Revision: D3508097

fbshipit-source-id: 12b4aa11e42112c8ba19a1af325e3ee9a232d08f
2016-06-30 20:50:09 -07:00
Andrew Y. Chen 2b88482701 Implement JavaOnlyArray#getType
Reviewed By: AaaChiuuu

Differential Revision: D3504601

fbshipit-source-id: 37dbbcdd8cc0523cb8f1673047995c4410e8f7be
2016-06-30 19:43:28 -07:00
Marc Horowitz ff31128200 Display JS exceptions and stacks in a red box
Reviewed By: frantic

Differential Revision: D3428952

fbshipit-source-id: e2b77487d54a3d89039661943061a0137f8410c0
2016-06-30 19:13:26 -07:00
Chris Hopman e19225aa64 assert that ShadowNodeRegistry is only accessed from one thread
Reviewed By: astreet

Differential Revision: D3461859

fbshipit-source-id: 790e831d2ca239110e00a5723be40e870ceab020
2016-06-30 15:13:39 -07:00
Chris Hopman c1f7aa3824 Change gradle ndk build inputs back to what they were
Reviewed By: bestander

Differential Revision: D3442666

fbshipit-source-id: 735cb7e908670fa9b1ec58a533a2c59008ccc154
2016-06-30 14:28:23 -07:00