Commit Graph

646 Commits

Author SHA1 Message Date
Nick Lockwood 807e0d9310 Fixed Xcode warnings
Summary:
public

Fixed some Xcode warnings, and added some missing UIResponder methods to make the behavior of RCTTextView more self-consistent.

Reviewed By: javache

Differential Revision: D2712250

fb-gh-sync-id: d30038500194d7a5262d9e77d516c65d836a4420
2015-12-02 08:03:26 -08:00
Justin Spahr-Summers c25c98c00c Flush UI blocks as soon as they're accumulated
Summary:
public

Currently, we wait to invoke `-flushUIBlocks` until the JavaScript batch to native has completed. This means we may be waiting an unnecessarily long time to perform view hierarchy changes and prop changes.

By instead invoking this after each chunk of enqueued UI blocks, we can perform some updates more eagerly, increasing our utilization of the main thread while splitting up the amount of time we spend running upon it.

This shouldn't affect layout, which is still tied to `-batchDidComplete`, so any visual inconsistencies should be limited to prop changes, which seems acceptable for the dramatic improvement in performance.

Reviewed By: javache

Differential Revision: D2658552

fb-gh-sync-id: 6d4560e21d7da1b02d2f30d1860d60735f11c4b5
2015-12-02 06:03:27 -08:00
David Aurelio a26b89f8bd Add property mapping for `borderStyle` from JS to `RCTView` (iOS)
Reviewed By: nicklockwood

Differential Revision: D2540321

fb-gh-sync-id: 57316f7b8dc734ee784179dbfde83e6034827819
2015-12-01 09:00:28 -08:00
Tadeu Zagallo 8ec052a727 Expose JS hooks to profile async events
Summary: public

Expose JS hooks to add async events to Systrace from JS.

Reviewed By: mikearmstrong001

Differential Revision: D2702739

fb-gh-sync-id: 906849d3819a914c521b9315e396c75946c9211d
2015-12-01 05:58:31 -08:00
Christopher Dro f025049b6c Add secure and login-password types to AlertIOS.
Summary: Request from issue #3893

* Added support for `secure-text` and `login-password` types to AlertIOS.
* Fixed and extended the cancel button highlighting functionality, which was broken at some point
* Added localization for default `OK` and `Cancel` labels when using UIAlertController

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

Reviewed By: javache

Differential Revision: D2702052

Pulled By: nicklockwood

fb-gh-sync-id: cce312d7fec949f5fd2a7c656e65c657c4832c8f
2015-11-30 19:51:41 -08:00
Nick Lockwood c63de5e2a5 Fixed MapView crash on iOS 8 and earlier
Summary: public

[MKPinAnnotationView redPinColor] is only supported on iOS 9 and later. This caused React Native to crash on iOS 8 and earlier.

This fixes the crash by providing a forked implementation for different OS versions.

Reviewed By: tadeuzagallo, javache

Differential Revision: D2702737

fb-gh-sync-id: cd8984f1f3d42989001f3c571e325f1b4ba09ac8
2015-11-30 05:10:26 -08:00
Frédéric Sagnes 599a130c9a Add perf tests to avoid decoding the bundle completely
Reviewed By: jspahrsummers

Differential Revision: D2574965

fb-gh-sync-id: 7bea6b3af04ba7e15471cc94a324a6c4a1d3614d
2015-11-27 09:21:29 -08:00
Martin Kralik be285c43d1 use didSetProps instead of updateLayout
Summary: There is no point in using `updateLayout` when we have `didSetProps`.
The only a bit risky part is calling `dirtyLayout` in `setFrame:forView:` instead of `updateLayout`,
but since setting frame shouldn't really change border/margin/padding it should be ok.

Depends on D2699512.

public

Reviewed By: nicklockwood

Differential Revision: D2700012

fb-gh-sync-id: a7c33b3b4e3ddc195bebebb8b03934131af016fb
2015-11-27 04:03:48 -08:00
Martin Kralik f86691a449 added `didSetProps` for views and shadow views
Summary: Views and shadow views might want to configure themself once all of their props were set.
So far there was no way to do it without writing some synchronization code.

This diff adds a `didSetProps` call on both uiviews and shadow views, passing names of all props that were set for convenience.

public

Reviewed By: nicklockwood

Differential Revision: D2699512

fb-gh-sync-id: 65f76e7bcbf5751d5b550261a953c463ed2f4e8a
2015-11-27 04:03:42 -08:00
Tim Park 8911b72d9e Add Polyline support to MapView
Summary: Per issue #1925, add support for Polyline to MapView.

Briefly, if you have a MapView declared as:

    <MapView
      annotations={this.state.annotations}
      overlays={this.state.overlays}
      style={styles.map}
      region={this.state.region}
      ref="mapView"
    />

then setting

    this.state.overlays = [{
      coordinates: [
        { latitude: 35.5, longitude: -5.5 },
        { latitude: 35.6, longitude: -5.6 },
        ...
      ],
      strokeColor: 'rgba(255, 0, 0, 0.5)',
      lineWidth: 3,
    }];

will draw a red line between the points in locations with a width of 3 and equally blended with the background.
Closes https://github.com/facebook/react-native/pull/4153

Reviewed By: svcscm

Differential Revision: D2697347

Pulled By: nicklockwood

fb-gh-sync-id: a436e4ed8d4e43f2872b39b4694fad7c02de8fe5
2015-11-26 08:54:16 -08:00
Tadeu Zagallo a7e2059c15 Fix class pair register on reload
Summary: public

It was possible after reload to detach from the new instance, removing the markers.

Reviewed By: jspahrsummers

Differential Revision: D2696208

fb-gh-sync-id: ad8f5d449f51c7c74a20ae7c0cafc4fc786ea390
2015-11-26 07:27:27 -08:00
Pieter De Baets bf0934a531 Delete RCTRootView's deprecated 'initialProperties' property
Reviewed By: majak

Differential Revision: D2597411

fb-gh-sync-id: 547837cac8e22e7fe78db6213741634b87bcf571
2015-11-26 05:10:28 -08:00
Tadeu Zagallo ea96a7edb8 Avoid dispatch_async on RCTProfile when not profiling
Summary: public

Fixes #3953

Bail out soon when the profiler is not running + move string formating into the macro so that it happens in a background queue.

Reviewed By: jspahrsummers

Differential Revision: D2696167

fb-gh-sync-id: a1b91ee4459078ab9a4c0be62bd23362ec05e208
2015-11-26 04:11:28 -08:00
Nick Lockwood 5b5b55027b Added support for custom color and image for map annotations
Summary: public

This diff extends RCTMap annotations with an `image` and `tintColor` property, which can be used to render completely custom pin graphics.

The tintColor applies to both regular pins and custom pin images, allowing you to provide varied pin colors without needing multiple graphic assets.

Reviewed By: fredliu

Differential Revision: D2685581

fb-gh-sync-id: c7cf0af5c90fd8d1e9b3fec4b89206440b47ba8f
2015-11-26 03:07:28 -08:00
Milen Dzhumerov 638fd11c5c Revert 3770f061c832 for further investigation
Reviewed By: idevelop

Differential Revision: D2695659

fb-gh-sync-id: b1ba529c648681faef5d4f07273722764722fbe1
2015-11-25 05:24:28 -08:00
Nick Lockwood 060664fd3d Refactored module access to allow for lazy loading
Summary: public

The `bridge.modules` dictionary provides access to all native modules, but this API requires that every module is initialized in advance so that any module can be accessed.

This diff introduces a better API that will allow modules to be initialized lazily as they are needed, and deprecates `bridge.modules` (modules that use it will still work, but should be rewritten to use `bridge.moduleClasses` or `-[bridge moduleForName/Class:` instead.

The rules are now as follows:

* Any module that overrides `init` or `setBridge:` will be initialized on the main thread when the bridge is created
* Any module that implements `constantsToExport:` will be initialized later when the config is exported (the module itself will be initialized on a background queue, but  `constantsToExport:` will still be called on the main thread.
* All other modules will be initialized lazily when a method is first called on them.

These rules may seem slightly arcane, but they have the advantage of not violating any assumptions that may have been made by existing code - any module written under the original assumption that it would be initialized synchronously on the main thread when the bridge is created should still function exactly the same, but modules that avoid overriding `init` or `setBridge:` will now be loaded lazily.

I've rewritten most of the standard modules to take advantage of this new lazy loading, with the following results:

Out of the 65 modules included in UIExplorer:

* 16 are initialized on the main thread when the bridge is created
* A further 8 are initialized when the config is exported to JS
* The remaining 41 will be initialized lazily on-demand

Reviewed By: jspahrsummers

Differential Revision: D2677695

fb-gh-sync-id: 507ae7e9fd6b563e89292c7371767c978e928f33
2015-11-25 04:49:45 -08:00
Pieter De Baets 38db6fa465 Remove scrollview support from UIManager, remove mainScrollView(delegate)
Reviewed By: nicklockwood

Differential Revision: D2692749

fb-gh-sync-id: 48975d2f09f3b2902dfa2e56ff9d34257b2395bc
2015-11-25 04:12:34 -08:00
Milen Dzhumerov fc5a8678d3 Implement efficient DiskCache.clear()
Summary: public

Ability to efficiently remove all keys with a particular prefix

Reviewed By: tadeuzagallo

Differential Revision: D2658741

fb-gh-sync-id: 3770f061c83288efe645162ae84a9fd9194d2fd6
2015-11-25 03:23:36 -08:00
Manuel Nakamurakare 9fc3991615 added method to set thumb image
Summary: this change will allow the slider to have different thumb images .

Sets an image for the thumb. It only supports static images
Closes https://github.com/facebook/react-native/pull/3849

Reviewed By: svcscm

Differential Revision: D2665699

Pulled By: nicklockwood

fb-gh-sync-id: 3a767e43170074e2419067d5c8eae61668ebb5e9
2015-11-24 16:10:04 -08:00
Martin Kralik 510f001390 put exception message in front of error log
Summary: Exception message was the last part of the whole shown error. This is not optimal in case where there are deeply nested objects as parameters, which used to be displayed before the message.
This diff moves the exception message to the front.

public

Reviewed By: javache

Differential Revision: D2691426

fb-gh-sync-id: c6c9ad3ac4681a8102ea2c580f24382640b7246c
2015-11-24 12:12:26 -08:00
Tadeu Zagallo 789b5708ec Fix arch macro on profiler
Summary: public

Bad typo in `RCTProfile.m`, was using `__x86__` instead of the right one `__i386__`.

Reviewed By: jspahrsummers

Differential Revision: D2690557

fb-gh-sync-id: 537eb0502f5df22cd93665cabfddeead12cad9db
2015-11-24 06:50:10 -08:00
Martin Kralik c324286fb7 truncate redbox error
Summary: If a redbox error is too long it's not shown at all:
{F24443416}
This diff truncates it to its first 10000 chars, which should be good enough:
{F24443417}

The reason is a limitation of UILabel which backs text property on the used UITableViewCell.
Ideally we would use a custom cell with UITextView, but I don't feel there is any value in displaying super long error messages in a redbox.

public

Reviewed By: jspahrsummers, nicklockwood

Differential Revision: D2690638

fb-gh-sync-id: d9b3fcecd2602e8c2618afe1bb97221c2e506605
2015-11-24 06:29:29 -08:00
Pieter De Baets b40631d0db Add exception description to exception name
Reviewed By: fkgozali

Differential Revision: D2687906

fb-gh-sync-id: f1bbc7c3deb9068877add37619faee730cdec743
2015-11-23 16:19:29 -08:00
Tadeu Zagallo 659cc005ad Restore VSYNC markers on RCTProfile
Summary: public

The VSYNC markers got lost at some point when refactoring RCTBatchedBridge, restore it, but keep it in RCTProfile.

Reviewed By: jspahrsummers

Differential Revision: D2685805

fb-gh-sync-id: 1acad330de7baf004a83b41f90ba4b6532605de6
2015-11-23 09:50:30 -08:00
Nick Lockwood 0fe074acbd Removed all calls to [UIImage imageWithData:] on a background thread
Summary: public

I had previously assumed (based on past experience and common wisdom) that `[UIImage imageWithData:]` was safe to call concurrently and/or off the main thread, but it seems that may not be the case (see https://github.com/AFNetworking/AFNetworking/pull/2815).

This diff replaces `[UIImage imageWithData:]` with ImageIO-based decoding wherever possible, and ensures that it is called on the main thread wherever that's not possible/convenient.

I've also serialized access to the `NSURLCache` inside `RCTImageLoader`, which was causing a separate-but-similar crash when loading images.

Reviewed By: fkgozali

Differential Revision: D2678369

fb-gh-sync-id: 74d033dafcf6c412556e4c96f5ac5d3432298b18
2015-11-20 05:17:33 -08:00
EwanThomas 2faf8632d3 UIRefreshControl added to scroll view
Summary: **What:**

adds `onRefreshStart` property to `ScrollView.js` for displaying and activating pull to refresh.

**Why:**

Javascript implementations seemed a little flakey and inconsistent.  As you can see in the issues below:

https://github.com/facebook/react-native/issues/2356
https://github.com/facebook/react-native/issues/745

So this is an attempt a completely native implementation.

What do you think?

![Image of dog](http://i.imgur.com/HcTQnzJ.gif)
Closes https://github.com/facebook/react-native/pull/4205

Reviewed By: svcscm

Differential Revision: D2674945

Pulled By: nicklockwood

fb-gh-sync-id: 65113a5db9785df5a95c68323c2cdf19f3b217b1
2015-11-19 11:15:48 -08:00
Quentin Valmori 7da42e3950 add allowsInlineMediaPlayback prop to play inline html5 video
Summary: Allow an html5 video to be played inline. (see #3112)
Closes https://github.com/facebook/react-native/pull/3137

Reviewed By: svcscm

Differential Revision: D2674318

Pulled By: nicklockwood

fb-gh-sync-id: cf71e4039c7027f1468370ae3ddef6eb3e2d2d4f
2015-11-19 07:11:29 -08:00
gilchenzion a3d9f5ba84 Add showsCompass to MapView props
Summary: Was trying to remove the compass from the map and thought I would contribute to the project for everyone.
Closes https://github.com/facebook/react-native/pull/4225

Reviewed By: svcscm

Differential Revision: D2674060

Pulled By: nicklockwood

fb-gh-sync-id: 66f069dfc53fdeae8aaab76980146296cea1140f
2015-11-19 02:22:29 -08:00
Nick Lockwood ca20d710fc Removed duplicate UIManager constants
Summary: public

We were calling constantsToExport twice for every ViewManager, and including two copies of the values in __fbBatchedBridgeConfig. This diff removes the copy from UIManager and then puts it back on the JS side.

Reviewed By: tadeuzagallo

Differential Revision: D2665625

fb-gh-sync-id: 147ec4bfb404835e3875964476ba233d619c28aa
2015-11-18 04:47:27 -08:00
Nick Lockwood 26cb6bef15 Open sourced RCTPasteboard
Summary: public

RCTPasteboard is a very basic API for writing strings to the pasteboard. Useful for implementing "copy to clipboard" functionality.

Reviewed By: astreet

Differential Revision: D2663875

fb-gh-sync-id: 8d0ecd824c3e9fe135b02201d21d0dab1907c329
2015-11-17 15:20:32 -08:00
rocman 2244a86eea enable the minWidth/maxWidth/minHeight/maxHeight features
Summary: Closes https://github.com/facebook/react-native/pull/4183

Reviewed By: svcscm

Differential Revision: D2663931

Pulled By: nicklockwood

fb-gh-sync-id: 53d699fbb6041e3623eb78f1045cac28821efde8
2015-11-17 10:58:32 -08:00
Justin Spahr-Summers 0491142702 Invoke -reactBridgeDidFinishTransaction per-batch, not per-flush
Reviewed By: tadeuzagallo, majak

Differential Revision: D2663382

fb-gh-sync-id: f3bd77e0ec8fd4129657fc1c23cc542cf7f0c223
2015-11-17 10:22:26 -08:00
Manuel Nakamurakare 2f23b30624 added a property to set a track image to slider ios
Summary: this change will allow the slider to have different track images.

Sets an image for the sliderIOS's track. It only supports images that are included as assets.
Closes https://github.com/facebook/react-native/pull/3850

Reviewed By: svcscm

Differential Revision: D2659680

Pulled By: nicklockwood

fb-gh-sync-id: faf6ddea1077b081c1fc05f8f110b669cef9902c
2015-11-17 08:45:30 -08:00
Nick Lockwood 5b796cec34 Reduced work done on main thread by RCTImageLoader
Summary: public

Removed redundant calls to [RCTNetwork canHandleRequest] in release mode when loading images, and improved perf for handler lookups when running in debug mode.

Reviewed By: tadeuzagallo

Differential Revision: D2663307

fb-gh-sync-id: 13285154c1c3773b32dba7894d86d14992e2fd7d
2015-11-17 07:21:29 -08:00
Pieter De Baets c043c68e7e Return viewsWithNewFrame instead of passing it around
Reviewed By: nicklockwood

Differential Revision: D2663281

fb-gh-sync-id: 6218c2ff68f7e4d8132ef1f95fb22f5007434319
2015-11-17 06:37:31 -08:00
Tadeu Zagallo 0b46a0c13b Add a naive WPO implementation
Summary: public

RFC: The minifier haven't been stripping dead-code, and it also can't kill unused
modules, so as a temporary solution this inlines `__DEV__`, kill dead branches
and kill dead modules. For now I'm just white-listing the dev variable, but we
could definitely do better than that, but as a temporary fix this should be
helpful.

I also intend to kill some dead variables, so we can kill unused requires,
although inline-requires can also fix it.

Reviewed By: vjeux

Differential Revision: D2605454

fb-gh-sync-id: 50acb9dcbded07a43080b93ac826a5ceda695936
2015-11-17 03:39:28 -08:00
Nick Lockwood 8b81bb7be5 Fixed issue with alert not being presented when modal window is hidden
Reviewed By: ryanolsonk

Differential Revision: D2658537

fb-gh-sync-id: 94bb311142005cfacc7b7612c17309835eeb980a
2015-11-16 10:24:23 -08:00
Nick Lockwood b7f5062128 Fixed nil insert crash in shadowViewRegistry
Summary: public

In iOS < 9, inserting a nil object into NSMutableDictionary crashes. It is valid for come components to return a nil shadowView (e.g. ART nodes), and this was crashing on iOS 8.

Reviewed By: jspahrsummers

Differential Revision: D2658309

fb-gh-sync-id: 7abf9273708cc03c3b6307b69ba11c016b471fbe
2015-11-16 09:19:24 -08:00
Tadeu Zagallo 905a8a4ce0 Reenable JS profiler after reload
Summary: public

Call `nativeProfilerStart` after reloading the bridge.

Reviewed By: jspahrsummers

Differential Revision: D2656507

fb-gh-sync-id: 651ff078ae289cb9701663f5f8ef164db1b42d74
2015-11-16 03:35:27 -08:00
Nick Lockwood 6dd171b8c2 RCTImagePicker now uses main thread
Summary: public

RCTImagePicker (aka ImagePickerIOS) was previously displaying UI from a random thread, which is unsafe. This diff forces it to execute on the main thread instead.

Reviewed By: jspahrsummers

Differential Revision: D2657465

fb-gh-sync-id: 3c0fa6935061ccaa3e6ce649b4e3e8ad8c701384
2015-11-16 03:17:29 -08:00
Nick Lockwood fa0b45c58b Replaced RCTSparseArray with NSDictionary
Reviewed By: jspahrsummers

Differential Revision: D2651920

fb-gh-sync-id: 953e2ea33abfc7a3a553da95b13e9ab2bccc5a1c
2015-11-14 10:28:28 -08:00
Nick Lockwood 397791fcea Added in-memory cache for AsyncLocalStorage
Reviewed By: tadeuzagallo

Differential Revision: D2641705

fb-gh-sync-id: 40b96b3084b82779e16f8845f9faeb0e3638d189
2015-11-14 09:20:30 -08:00
Pawel Sienkowski 760a2fc79a Prevent RCTRootView delegate call
Reviewed By: javache

Differential Revision: D2631582

fb-gh-sync-id: 409d439eb1dc8c7723892477dfaf58aa85c664b5
2015-11-13 08:28:28 -08:00
Grant Paul ca1f023c8d Fix casting in QoS setter.
Reviewed By: jasonprado

Differential Revision: D2649914

fb-gh-sync-id: 064381bcc81a6a50ffa894d4a07823bb28a587e3
2015-11-12 17:02:42 -08:00
Justin Spahr-Summers 0276dde612 Increase priority of UIManager's shadowQueue
Summary: This queue processes layout and user interface updates, so it should have as high a quality-of-service/priority as possible.

public

Reviewed By: javache

Differential Revision: D2641837

fb-gh-sync-id: 934686f7969b43101af183148d67ff7be4bdf660
2015-11-12 07:05:19 -08:00
Justin Spahr-Summers a1d8ea2ac1 Increase QoS of JavaScript thread on iOS 8+
Summary: This thread is effectively the "main thread" for JavaScript code in React Native applications, so it should have as high a quality-of-service as possible.

public

Reviewed By: javache, nicklockwood

Differential Revision: D2641878

fb-gh-sync-id: 3c60c1abeeab9e7405d6fc9602e0d4ccfab1ea1b
2015-11-12 07:05:13 -08:00
Pawel Sienkowski bdd0b4796a Prevent runApplication from being called with uninitialized content view
Reviewed By: javache

Differential Revision: D2639111

fb-gh-sync-id: ff9733ee7be1131584d2542f04cf953c63300f95
2015-11-11 12:05:28 -08:00
Ryan Olson 51a5b60a1a Fix showing alerts when modals are presented
Reviewed By: nicklockwood

Differential Revision: D2638505

fb-gh-sync-id: ebecc82baa46be4302fc8d3231f859de572eda10
2015-11-11 09:30:31 -08:00
Nick Lockwood 5931089677 Improved AsyncStorage merge function
Reviewed By: tadeuzagallo

Differential Revision: D2641817

fb-gh-sync-id: 0ba526ce21039ccdb979ac75c44d41c522c910ca
2015-11-11 09:03:05 -08:00
Pieter De Baets be9cd6c9cf Don't traverse view trees that are not managed by react-native-github
Reviewed By: tadeuzagallo

Differential Revision: D2641753

fb-gh-sync-id: 924df6c4142ad4a467003d0039a0d7f843d9b63c
2015-11-11 08:15:35 -08:00