Commit Graph

761 Commits

Author SHA1 Message Date
Siqi Liu 1e88c1261c Disable the double R shortcut to reload JS in iOS
Summary: Disable double R shortcut temporarily to fix a bug.

Reviewed By: majak

Differential Revision: D3428043

fbshipit-source-id: 23795b72433230e49d5ab559c0cb828bce8196ea
2016-06-14 05:30:30 -07:00
Nathan Azaria 8c29a52c54 Implemented automatic IP detection for iOS
Summary:
Implemented automatic IP detection for iOS, based on #6345 and #6362.
As the previous pull requests did, this works by writing the IP address of the host to a file.
Closes https://github.com/facebook/react-native/pull/8091

Differential Revision: D3427657

Pulled By: javache

fbshipit-source-id: 3f534c9b32c4d6fb9615fc2e2c3c3aef421454c5
2016-06-13 15:58:36 -07:00
Pieter De Baets d7fc58f32c Add RCT_PROFILE define
Reviewed By: tadeuzagallo

Differential Revision: D3423593

fbshipit-source-id: cc04add1bee16fbb4c2491bd229f23244fe3e7bd
2016-06-13 04:28:38 -07:00
Yinan Na 14d0b5c0f1 Fix react word wrapping crash
Differential Revision: D3419011

fbshipit-source-id: ac205ea746c03cab946059fc55749f4abbab8d41
2016-06-10 14:29:17 -07:00
Sokovikov c03b166854 line break mode for ios
Summary:
What do you think is ```lineBreakMode``` a good name? For android it is called ```ellipsize```.

<img src="https://cloud.githubusercontent.com/assets/1488195/15628555/7372f8d0-250c-11e6-8919-722f28a38d60.png"" width="300" />
Closes https://github.com/facebook/react-native/pull/7819

Differential Revision: D3417256

fbshipit-source-id: 189441a23ff554bf7f6d67fa8510959351e9e5cc
2016-06-10 04:28:37 -07:00
Fabian Eichinger d43e0db81e Add support for reverse flex directions on Android and iOS
Summary:
This PR adds support for both 'row-reverse' and 'column-reverse' for Android and iOS and is based on the changes in #6683 that looked like it's all but abandoned.
It also adds examples for the new directions to the "Layout - Flexbox" section of UIExplorer as well as some rad new colors to the section to make the difference between "row-reverse" and "flex-end" more apparent.

**Test plan (required)**
Tested inside of UIExplorer

Android
<img width="571" alt="screen shot 2016-06-05 at 7 42 14 pm" src="https://cloud.githubusercontent.com/assets/4332237/15807140/cf8e05de-2b55-11e6-9366-a2e3194cabf8.png">

iOS
<img width="578" alt="screen shot 2016-06-05 at 7 41 35 pm" src="https://cloud.githubusercontent.com/assets/4332237/15807143/dee8e9b8-2b55-11e6-8777-c30329fa54e8.png">
Closes https://github.com/facebook/react-native/pull/7938

Differential Revision: D3417182

fbshipit-source-id: e8c9f5976ca95b2d2069a5b31a20f6d6309eb3cc
2016-06-10 03:28:45 -07:00
Nathan Azaria 5ef3b47ede Replaced CTLSettings with RCTBundleURLProvider internally
Reviewed By: javache

Differential Revision: D3398803

fbshipit-source-id: 1c5610a1e59f3fad4c57b0b280559f2ff2acf05a
2016-06-09 07:28:19 -07:00
Alex Kotliarskyi f3fab5184e Remove SourceCode.getScriptText
Summary:
After cleaning up JS SourceMap code, these native methods are not needed anymore.

On iOS it saves another 30+ Mb during development.

Reviewed By: javache, astreet

Differential Revision: D3348975

fbshipit-source-id: a68ae9b00b4dbaa374b421029ae676fc69ae5a75
2016-06-07 11:13:32 -07:00
Nick Lockwood 46c02b6ae5 Refactored subview management
Summary:
This diff refactors the view update process into two stages:

1. The `reactSubviews` array is set, whose order matches the order of the JS components and shadowView components, as specified by the UIManager.
2. The `didUpdateReactSubviews` method is called, which actually inserts the reactSubviews into the view hierarchy.

This simplifies a lot of the hacks we had for special-case treatment of subviews: In many cases we don't want to actually insert `reactSubviews` into the parentView, and we had a bunch of component-specific solutions for that (typically overriding all of the reactSubviews methods to store views in an array). Now, we can simply override the `didUpdateReactSubviews` method for those views to do nothing, or do something different.

Reviewed By: wwjholmes

Differential Revision: D3396594

fbshipit-source-id: 92fc56fd31db0cfc66aac3d1634a4d4ae3903085
2016-06-07 00:14:39 -07:00
Nick Lockwood 93c7a93de9 Reverted commit D3392214
Reviewed By: javache

Differential Revision: D3392214

fbshipit-source-id: 4136c8b0eb160f4b245df2e4b5d67d00efd7b1a7
2016-06-06 16:28:21 -07:00
Nick Lockwood 44c9cf3a91 Refactored subview management
Reviewed By: javache

Differential Revision: D3392214

fbshipit-source-id: 6f16841df5cf866dda5ac27dd244e266ec85a86e
2016-06-06 10:28:33 -07:00
Siqi Liu 61046c3195 Fix the bug where key shortcuts are invoked in TextInputs in iOS
Summary:
This is a followup for "Add Shortcut "Double R" to Reload JS in iOS".
Please see the previous two revisions:[[ D3371536 | D3371536 ]], [[ D3343907 | D3343907 ]]

In previous revisions, we only tested with the iOS UIExplorer app, without testing in the iOS Catalyst app, where the key shortcuts we added are always invoked in TextInput components. It's due to a bug with the `UIApplicationDelegate`. Just fix this bug in this revision and successfully tested in the Catalyst app.

Reviewed By: mkonicek

Differential Revision: D3391045

fbshipit-source-id: 8b76fbfe7592218b02dd22502d25eebbc59f3cbc
2016-06-06 09:43:17 -07:00
Nick Lockwood 72b363d7fc Replaced isMainThread checks with a proper test for main queue
Summary:
As per https://twitter.com/olebegemann/status/738656134731599872, our use of "main thread" to mean "main queue" seems to be unsafe.

This diff replaces the `NSThread.isMainQueue` checks with dispatch_get_specific(), which is the recommended approach.

I've also replaced all use of "MainThread" terminology with "MainQueue", and taken the opportunity to deprecate the "sync" param of `RCTExecuteOnMainThread()`, which, while we do still use it in a few places, is incredibly unsafe and shouldn't be encouraged.

Reviewed By: javache

Differential Revision: D3384910

fbshipit-source-id: ea7c216013372267b82eb25a38db5eb4cd46a089
2016-06-06 07:58:36 -07:00
Adam Comella ee8496f364 iOS: Support HTTP headers for source prop on <Image> components
Summary:
Allows developers to specify headers to include in the HTTP request
when fetching a remote image. For example, one might leverage this
when fetching an image from an endpoint that requires authentication:

```
<Image
  style={styles.logo}
  source={{
    uri: 'http://facebook.github.io/react/img/logo_og.png',
    headers: {
      Authorization: 'someAuthToken'
    }
  }}
/>
```

Note that the header values must be strings.

Works on iOS and Android.

**Test plan (required)**

- Ran a small example like the one above on iOS and Android and ensured the headers were sent to the server.
- Ran a small example to ensure that \<Image\> components without headers still work.
- Currently using this code in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/7338

Reviewed By: javache

Differential Revision: D3371458

Pulled By: nicklockwood

fbshipit-source-id: cdb24fe2572c3ae3ba82c86ad383af6d85157e20
2016-06-01 10:43:28 -07:00
Siqi Liu 0cc0aaecbb Followup for Add Shortcut "Double R" to Reload JS in iOS
Summary: Change nit codes in comments.

Reviewed By: mkonicek

Differential Revision: D3371536

fbshipit-source-id: 4133af88568f15410ff90c945695f82ffd94eb95
2016-06-01 08:43:29 -07:00
Siqi Liu 2d32a6df27 Add Shortcut "Double R" to Reload JS in iOS
Summary:
Enable double tap R on iOS, consistent with Android.
Keep the existing Cmd+R on iOS because people are already used to it.
Make Cmd+Key and Double Key both invalid when focus is in textview or textfield.
Also try to add Cmd+R in Android, but seems no good.

Reviewed By: nicklockwood

Differential Revision: D3343907

fbshipit-source-id: 68f7e3b0393711c137e1d932db33e1b6a2a19e09
2016-06-01 03:43:27 -07:00
Alexey Lang abe0b349bc Implement RCTJSCWrapper
Reviewed By: tadeuzagallo

Differential Revision: D3258713

fbshipit-source-id: 418eb9d350bf3541c976b631bd9799a1c578f5e5
2016-05-31 12:58:25 -07:00
Li Jie eb69d036d5 Log image url when image size doesn't match.
Summary:
Sometimes I got error message about image size doesn't match, but I don't know which image is wrong.

Before:
<img width="376" alt="2016-05-31 11 03 58" src="https://cloud.githubusercontent.com/assets/8459/15662148/aa4e1d7e-2720-11e6-863a-aa7dd662460b.png">

After this PR:
<img width="377" alt="2016-05-31 10 59 21" src="https://cloud.githubusercontent.com/assets/8459/15662153/b5b1fd2a-2720-11e6-9807-c7e4aa314c4b.png">

**Test plan (required)**

```
<Image source={require('image!test')} />
```
And don't add this image into project, it would report errors when run it.
Closes https://github.com/facebook/react-native/pull/7840

Differential Revision: D3365467

Pulled By: nicklockwood

fbshipit-source-id: de3d5989ef0a3c443cce557901486c4770d4e906
2016-05-31 05:28:31 -07:00
Nathan Azaria 3ccd99fb53 Added RCTBundleURLProvider
Reviewed By: javache

Differential Revision: D3352568

fbshipit-source-id: fbba6771a1c581e2676bd0f81d3da62dbf21916b
2016-05-31 04:59:56 -07:00
Anoop Chaurasiya 1586a32fa7 add support to provide fallback-sourceURL: in case primary-sourceURL fails to load
Reviewed By: javache

Differential Revision: D3339692

fbshipit-source-id: 93fa1821bf4abca878832d4f75c6b9968d8d0460
2016-05-25 10:28:27 -07:00
Martin Kralik 2c8abebccc improved description for RCTTouchEvent
Summary: This will make error messages more helpful.

Reviewed By: javache

Differential Revision: D3292400

fbshipit-source-id: d1e0bb24593058b75422824c0d351ede1320029e
2016-05-24 05:13:27 -07:00
Anoop Chaurasiya be38ae1169 provide verbose error-message on bundle-load-failure
Reviewed By: fkgozali

Differential Revision: D3329107

fbshipit-source-id: 33c02ff066ec9ad415a5cc4639347ebdef67c604
2016-05-23 11:13:24 -07:00
Nick Lockwood d9737571c4 Updated AppState module to use new emitter system
Summary: AppState now subclasses NativeEventEmitter instead of using global RCTDeviceEventEmitter.

Reviewed By: javache

Differential Revision: D3310488

fbshipit-source-id: f0116599223f4411307385c0dab683659d8d63b6
2016-05-23 09:13:37 -07:00
Mike Grabowski 4446e31b5d ActionSheetIOS - support share sheet on modals
Summary:
Fixes #6913 - follow up to this commit 43dcdaffe2 to support this in the 2nd method as well.
Closes https://github.com/facebook/react-native/pull/7244

Differential Revision: D3330843

fbshipit-source-id: 0923440550a7635202158b4afaba87e12f1c1d54
2016-05-20 17:13:21 -07:00
Marc Horowitz 3a2d024514 avoid waiting on the main thread just to send a notification
Reviewed By: nicklockwood

Differential Revision: D3234837

fbshipit-source-id: 587a68df7d08999d4357583ba3160b315bd85239
2016-05-13 17:29:00 -07:00
Marc Horowitz 267264f1ec Add a bunch more systrace logging
Reviewed By: tadeuzagallo

Differential Revision: D3234831

fbshipit-source-id: 177f9b987e938c59d50fc07bce01fb5c912652e7
2016-05-13 17:29:00 -07:00
Marc Horowitz 86e18ace94 make RCTFBSystrace actually work
Reviewed By: tadeuzagallo

Differential Revision: D3234824

fbshipit-source-id: 9f2f7efd6877fe7b9096dedecb311d226eae7bc8
2016-05-13 17:29:00 -07:00
Martin Kralik 44bf85a041 different coalescing key for `touchCancel` events
Summary:
On iPad we may get two touch cancel events in direct succession. They would have the same coalescing key, which would result in unsuccesful attempt to coalesce them.
This diff fixes it by making sure two cancel events cannot have the same coalescing key.

(An alternative fix would be implementing coalescing logic for cancel events, but that sounds more complicated. It would be neccessary if there is a legit scenario where big number of cancel events are emitted in succesion.)

Reviewed By: javache

Differential Revision: D3292405

fbshipit-source-id: 1f269771dc81fdd637cf6ac3ee4725e5e2fec679
2016-05-12 08:11:24 -07:00
Ben Roth 36b085422d Correctly test for HMR parameter in the bundle URL
Summary: Closes https://github.com/facebook/react-native/pull/7525

Differential Revision: D3292314

Pulled By: javache

fbshipit-source-id: 04090f7f1253e055278a6774f7e135833ae3d6f6
2016-05-12 03:30:23 -07:00
Nick Lockwood 9ee1f37bad Added native event emitter
Summary:
This is a solution for the problem I raised in https://www.facebook.com/groups/react.native.community/permalink/768218933313687/

I've added a new native base class, `RCTEventEmitter` as well as an equivalent JS class/module `NativeEventEmitter` (RCTEventEmitter.js and EventEmitter.js were taken already).

Instead of arbitrary modules sending events via `bridge.eventDispatcher`, the idea is that any module that sends events should now subclass `RCTEventEmitter`, and provide an equivalent JS module that subclasses `NativeEventEmitter`.

JS code that wants to observe the events should now observe it via the specific JS module rather than via `RCTDeviceEventEmitter` directly. e.g. to observer a keyboard event, instead of writing:

    const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
    RCTDeviceEventEmitter.addListener('keyboardWillShow', (event) => { ... });

You'd now write:

    const Keyboard = require('Keyboard');
    Keyboard.addListener('keyboardWillShow', (event) => { ... });

Within a component, you can also use the `Subscribable.Mixin` as you would previously, but instead of:

     this.addListenerOn(RCTDeviceEventEmitter, 'keyboardWillShow', ...);

Write:

    this.addListenerOn(Keyboard, 'keyboardWillShow', ...);

This approach allows the native `RCTKeyboardObserver` module to be created lazily the first time a listener is added, and to stop sending events when the last listener is removed. It also allows us to validate that the event strings being observed and omitted match the supported events for that module.

As a proof-of-concept, I've converted the `RCTStatusBarManager` and `RCTKeyboardObserver` modules to use the new system. I'll convert the rest in a follow up diff.

For now, the new `NativeEventEmitter` JS module wraps the `RCTDeviceEventEmitter` JS module, and just uses the native `RCTEventEmitter` module for bookkeeping. This allows for full backwards compatibility (code that is observing the event via `RCTDeviceEventEmitter` instead of the specific module will still work as expected, albeit with a warning). Once all legacy calls have been removed, this could be refactored to something more elegant internally, whilst maintaining the same public interface.

Note: currently, all device events still share a single global namespace, since they're really all registered on the same emitter instance internally. We should move away from that as soon as possible because it's not intuitive and will likely lead to strange bugs if people add generic events such as "onChange" or "onError" to their modules (which is common practice for components, where it's not a problem).

Reviewed By: javache

Differential Revision: D3269966

fbshipit-source-id: 1412daba850cd373020e1086673ba38ef9193050
2016-05-11 06:27:29 -07:00
David Aurelio 0c90ab493f Add Random Access Module file names to stack traces
Reviewed By: javache

Differential Revision: D3269450

fb-gh-sync-id: 41b2013d4422c2bcafa7628321d4626fd40aac5d
fbshipit-source-id: 41b2013d4422c2bcafa7628321d4626fd40aac5d
2016-05-06 05:54:23 -07:00
Nick Lockwood e72163f0f2 Added explicit init to observer modules
Summary:
Modules which call JS methods directly, or use `sendDeviceEventWithName:`, can trigger effects in JS without ever being referenced from the JS code. This breaks some assumptions in my earlier diff about when modules can be lazily loaded.

Pending a better solution, I've put explicit `init` methods in these modules to ensure they are eagerly initialized (the downside to this is that they'll still be initialized even if they are never used).

Reviewed By: javache

Differential Revision: D3258232

fb-gh-sync-id: f925bc2e5339c1fbfcc244d4613062c5ab848fc2
fbshipit-source-id: f925bc2e5339c1fbfcc244d4613062c5ab848fc2
2016-05-04 07:07:24 -07:00
Pieter De Baets a9a90aa2f0 Fix RCTProfileHookModules instantiating all modules
Reviewed By: tadeuzagallo

Differential Revision: D3235048

fb-gh-sync-id: bdcd72fb241c5136e884c1705e027f178939970b
fbshipit-source-id: bdcd72fb241c5136e884c1705e027f178939970b
2016-05-04 06:55:30 -07:00
Nick Lockwood 34ec6a91a9 Move setBridge: off main thread
Summary:
Previously, if a module implemented `setBridge:` we assumed that it needs to be initialised on the main thread. This assumption was not really warranted however, and it was a barrier to deferring module initialization.

This diff tweaks the rules so that only modules that override `init` or `constantsToExport**` are assumed to require main thread initialization, and others can be created lazily when they are first used.

WARNING: this will be a breaking change to any 3rd party modules that are assuming `setBridge:` is called on the main thread. Those modules should be rewritten to move any code that requires the main thread into `init` or `constantsToExport` instead.

`**` We will also be examining whether `constantsToExport` can be done lazily, but for now any module that uses it will still be created eagerly when the bridge starts up.

Reviewed By: javache

Differential Revision: D3240682

fb-gh-sync-id: 48f309e3158bbccb52141032baf70def3e609371
fbshipit-source-id: 48f309e3158bbccb52141032baf70def3e609371
2016-05-03 09:09:21 -07:00
Nick Lockwood 8cfa6b6ea6 Deprecated customDirectEventTypes, and removed from RCTScrollViewManager
Summary: Using customDirectEventTypes or customBubblingEventTypes causes a viewmanager to be initialized at app start. This diff deprecates those methods and removes their usage from RCTScrollViewManager.

Reviewed By: majak

Differential Revision: D3218973

fb-gh-sync-id: 295bef3be9623b49b0cdcbf8a56e10d9b28126d9
fbshipit-source-id: 295bef3be9623b49b0cdcbf8a56e10d9b28126d9
2016-04-28 07:44:19 -07:00
Pieter De Baets feda8ce2ee Clean up RCTEventDispatcher code
Reviewed By: majak

Differential Revision: D3175583

fb-gh-sync-id: c751c9dc79edfd9cb6073a2ff5dd743a03334bc4
fbshipit-source-id: c751c9dc79edfd9cb6073a2ff5dd743a03334bc4
2016-04-28 05:48:21 -07:00
Nick Lockwood 9547a98a68 Fixed deadlock during app startup
Summary:
Now that we support initializing the bridge off the main thread, some of the assumptions in the bridge setup process are no longer safe.

In particular we were assuming that the JS executor and injected modules could always be synchronously initialized within bridge init, but that is only safe if those modules don't need to be set up on the main thread.

The setup for those modules was sync-dispatching to the main thread if bridge init happened on a background thread, and this lead to a deadlock under certain circumstances.

Reviewed By: javache

Differential Revision: D3224162

fb-gh-sync-id: 7319b70f541a46ef932cfe4f776e7e192f3ce1e8
fbshipit-source-id: 7319b70f541a46ef932cfe4f776e7e192f3ce1e8
2016-04-27 09:09:23 -07:00
Martin Kralik eff673572e pass flexiblity to shadowrootview on its creation
Reviewed By: javache

Differential Revision: D3177404

fb-gh-sync-id: 2116628461e37e9f1d1b3cbc6d6560675cadee7e
fbshipit-source-id: 2116628461e37e9f1d1b3cbc6d6560675cadee7e
2016-04-20 10:53:21 -07:00
Pieter De Baets 5cdfe0f4b1 Report JSC errors as JS exceptions
Summary:When JSC throws an error on startup (e.g. a SyntaxError) or when invoking a method that is not caught by RCTExceptionsManager, we previously just reported is a native error, with a (useless) native stack trace in the redbox. This changes that behaviour to report a JS stacktrace.

The same issue was previously reported here: https://github.com/facebook/react-native/pull/5677

Reviewed By: majak

Differential Revision: D3037387

fb-gh-sync-id: 06f8333e0eb50dcef0b26284754262301b8a5f08
fbshipit-source-id: 06f8333e0eb50dcef0b26284754262301b8a5f08
2016-04-20 09:13:29 -07:00
Oleg Lokhvitsky e02d400f53 Set autoresizingMask to redraw root when resizing RN window
Reviewed By: javache

Differential Revision: D3177081

fb-gh-sync-id: 987167033329413cd0a4b296ca849758ec87368c
fbshipit-source-id: 987167033329413cd0a4b296ca849758ec87368c
2016-04-14 14:27:23 -07:00
Pieter De Baets a8f4159fc7 Don't instantiate all native modules on invalidate
Reviewed By: majak

Differential Revision: D3175599

fb-gh-sync-id: 86b60a8bd757765d35cce6248a613c8167400bd9
fbshipit-source-id: 86b60a8bd757765d35cce6248a613c8167400bd9
2016-04-13 18:28:21 -07:00
Justin Zeus b2eecdc90d Parse _Nonnull and _Nullable attributes in RCTParseMethodSignature
Differential Revision: D3171305

fb-gh-sync-id: 687b030e13e762110f9ea9b750b0bc09457229a5
fbshipit-source-id: 687b030e13e762110f9ea9b750b0bc09457229a5
2016-04-12 17:45:25 -07:00
Martin Kralik 3874c01292 make `RCTEventDispatcher` dispatch events in incoming order
Reviewed By: javache

Differential Revision: D3138215

fb-gh-sync-id: 430b57d7bb8e3f0f90877b627bfd6a842719ba5d
fbshipit-source-id: 430b57d7bb8e3f0f90877b627bfd6a842719ba5d
2016-04-05 09:17:28 -07:00
Martin Kralik 8efc098646 fixed coalescing key generation for RCTTouchEvent
Summary:Turns our using the same coalescing key until a person removes all fingers off screen is not ideal.
It doesn't work in a case where the first finger starts moving on screen and then a second finger joins it later (almost any pinch gesture),
since we would try to coalesce move events from the start when only one finger was touching screen with events where two fingers were moving on screen.
That doesn't work and results in a crash.

I've changed the logic for generating the coalescing key in order to prevent this.
We no longer have a single key for a single gesture, but we change the key each time amount of fingers increases ("touchStart") or decreases ("touchEnd").

Reviewed By: javache

Differential Revision: D3138275

fb-gh-sync-id: c32230ba401819fe3a70d1752b286d849520be89
fbshipit-source-id: c32230ba401819fe3a70d1752b286d849520be89
2016-04-05 09:10:27 -07:00
Martin Kralik 02b6e38bee better event emitting II: no deadlocks
Summary:D3092867 / 1d3db4c5dc caused deadlock when chrome debugging was turned on, so it was reverted as D3128586 / 144dc30661.
The reason: I was calling `[_bridge dispatchBlock:^{ [self flushEventsQueue]; } queue:RCTJSThread];` from main thread and expecting it will `dispatch_async` to another,
since a held lock was being accessed the dispatched block and was released after the dispatch.
Turns out `RCTWebSocketExecutor` (which is used when chrome debugger is turned on) executes all blocks dispatched this way to `RCTJSThread` synchronously on the main thread.
This resulted in a deadlock. The "dispatched" block was trying to acquired lock which held by the same thread in the dispatching phase.

A fix for this is pretty simple. We will release the lock before dispatching the block.

However it's not super straightforward to see this won't introduce some race condition in a case with two threads where we would end up with events not being processed.
My thinking why that shouldn't happen goes like this: We could get in a bad state if `flushEventsQueue` would run on JS thread while `sendEvent:` is running on MT.
(I don't have a specific example how, maybe it's not possible. However when I show this case is safe we know we are good.)
The way how locking is setup in this diff the only possible scenario where these two threads would execute in these methods concurrently is JS holding the lock and MT going to enqueue another block on JS thread (since that's outside of "locked" zone).
But this scenarion can never happen, since if MT is about to enqueue the block on JS thread it means there cannot be a not yet fully executed block on JS thread.
Therefore nothing bad can happen.

So this diff brings back the reverted diff and adds to it the fix for the deadlock.

Reviewed By: javache

Differential Revision: D3130375

fb-gh-sync-id: 885a166f2f808551d7cd4e4eb98634d26afe6a11
fbshipit-source-id: 885a166f2f808551d7cd4e4eb98634d26afe6a11
2016-04-02 23:31:25 -07:00
Alex Kotliarskyi 144dc30661 Revert [RN][iOS] better event emitting
Reviewed By: sahrens

Differential Revision: D3128586

fb-gh-sync-id: 5c3c79fa983f6c1c43319a6c14049f99e0dfee8a
fbshipit-source-id: 5c3c79fa983f6c1c43319a6c14049f99e0dfee8a
2016-04-01 14:26:20 -07:00
Alexey Lang b57d90a479 Append D3126321
Reviewed By: javache

Differential Revision: D3126614

fb-gh-sync-id: b36bb5eaa306823dce4bd7276f2dd63a2e5cb759
fbshipit-source-id: b36bb5eaa306823dce4bd7276f2dd63a2e5cb759
2016-04-01 11:09:22 -07:00
Alexey Lang ef8ad82a62 Add more performance logs and Systrace events for RAM and bridge startup
Summary: Add more performance logs and Systrace events for RAM and bridge startup.

Reviewed By: javache

Differential Revision: D3126321

fb-gh-sync-id: bb059f1f0302b751c6bf97bbe6bdbaf0aba27e21
fbshipit-source-id: bb059f1f0302b751c6bf97bbe6bdbaf0aba27e21
2016-04-01 07:25:38 -07:00
Pieter De Baets b00c77af80 Increase RN devtools retry timeout
Summary:The 200ms timeout was causing resource issues and causing a lot of overhead when you're not running the devtools, since it will basically create a new socket every 200ms.

Also clean up the way we do logging so it's completely compiled out in prod, and standardize all the names we use for threading to lowercase react.

Reviewed By: frantic

Differential Revision: D3115975

fb-gh-sync-id: e6e51c0621d8e9fc4eadb864acd678b8b5d322a1
fbshipit-source-id: e6e51c0621d8e9fc4eadb864acd678b8b5d322a1
2016-04-01 07:02:25 -07:00
Martin Kralik 1d3db4c5dc better event emitting
Summary:Previously, (mostly touch and scroll) event handling on iOS worked in a hybrid way:
* All incoming coalesce-able events would be pooled and retrieved by js thread in the beginning of its frame (all of this happens on js thread)
* Any non-coalesce-able event would be immediately dispatched on a js thread (triggered from main thread), and if there would be pooled coalesce-able events they would be immediately dispatched at first too.

This behavior has a subtle race condition, where two events are produced (on MT) in one order and received in js in different order.
See https://github.com/facebook/react-native/issues/5246#issuecomment-198326673 for further explanation of this case.

The new event handling is (afaik) what Android already does. When an event comes we add it into a pool of events and dispatch a block on js thread to inform js there are events to be processed. We keep track of whether we did so, so there is at most one of these blocks waiting to be processed. When the block is executed js will process all events that are in pool at that time (NOT at time of enqueuing the block).
This creates a single way of processing events and makes it impossible to process them in different order in js.

The tricky part was making sure we don't coalesce events across gestures/different scrolls. Before this was achieved by knowing that gestures and scrolls start/end with  non-coalesce-able event, so the pool never contained events that shouldn't be coalesced together. That "assumption" doesn't hold now.
I've re-added `coalescingKey` and made touch and scroll events use it to prevent coalescing events of the same type that should remain separate in previous diffs (see dependencies).

On top of it it decreases latency in events processing in case where we get only coalesce-able events. Previously these would be processed at begging of the next js frame, even when js would be free and could process them sooner. This delay is done, since they would get processed as soon as the enqueued block would run.

To illustrate this improvement let's look at these two systraces.
Before: https://cloud.githubusercontent.com/assets/713625/14021417/47b35b7a-f1d3-11e5-93dd-4363edfa1923.png
After: https://cloud.githubusercontent.com/assets/713625/14021415/4798582a-f1d3-11e5-8715-425596e0781c.png

Reviewed By: javache

Differential Revision: D3092867

fb-gh-sync-id: 29071780f00fcddb0b1886a46caabdb3da1d5d84
fbshipit-source-id: 29071780f00fcddb0b1886a46caabdb3da1d5d84
2016-04-01 06:54:50 -07:00
Martin Kralik b1b53aad8b coalescingKeys for RCTTouchEvent
Reviewed By: javache

Differential Revision: D3092864

fb-gh-sync-id: b703dca92578e05195eac9171b5b6eee83976cc9
fbshipit-source-id: b703dca92578e05195eac9171b5b6eee83976cc9
2016-04-01 06:54:50 -07:00
Martin Kralik 7c2b397b00 RCTTouchEvent's init takes coalescing key
Reviewed By: javache

Differential Revision: D3092861

fb-gh-sync-id: 69beb58c0a2ca3fe33712a57098c8b7300ad49f4
fbshipit-source-id: 69beb58c0a2ca3fe33712a57098c8b7300ad49f4
2016-04-01 06:54:49 -07:00
Martin Kralik a496baa68c reintroduced coalescing key for events
Summary: This was previously removed in D2884587, but we will need it going forward. See D3092867 for reasons why it's necessary again.

Reviewed By: javache

Differential Revision: D3092848

fb-gh-sync-id: 0d10dbac4148fcc8e035d32d8eab50f876d99e88
fbshipit-source-id: 0d10dbac4148fcc8e035d32d8eab50f876d99e88
2016-04-01 06:54:49 -07:00
Martin Kralik 8f07b01ac8 move `RCTBatchedBridge` interface to a private header
Summary:Interface to `RCTBatchedBridge` was being declared in two different implementation files. This is suboptimal, since it makes it hard to mock that class in a test.
So I've merged and moved these two definitions in `RCTBridge+Private.h`, so it's still obvious it's a private class, but can be included if you really need it.

Reviewed By: javache

Differential Revision: D3126135

fb-gh-sync-id: 173e4c5c2925be387b92deb7f99952ca7bf28588
fbshipit-source-id: 173e4c5c2925be387b92deb7f99952ca7bf28588
2016-04-01 06:54:49 -07:00
Tadeu Zagallo 2be42abbc2 Fix flowIDMap being accessed from multiple threads simultaneously
Summary:`flowIDMap` lives on the bridge to map from the IDs used for the flow events in
JS and the ones generated by `RCTProfile` in the native side.

It was being accessed from multiple threads (the various modules' queues in the
bridge and the JS thread), so we lock before touching it.

Reviewed By: javache

Differential Revision: D3102745

fb-gh-sync-id: 93d012d124e8b5d1a390c10a98ef5e3a068ccf63
fbshipit-source-id: 93d012d124e8b5d1a390c10a98ef5e3a068ccf63
2016-03-30 08:08:18 -07:00
Pieter De Baets 5bbf88be5a Fix OSS project configuration
Reviewed By: bestander

Differential Revision: D3114557

fb-gh-sync-id: 7e519f6304efc4ce17e5751ef65c5b4fac2baf5f
fbshipit-source-id: 7e519f6304efc4ce17e5751ef65c5b4fac2baf5f
2016-03-30 03:12:27 -07:00
Marc Horowitz 2115664456 Pull CADisplayLink into a separate file
Reviewed By: javache

Differential Revision: D3107921

fb-gh-sync-id: 2982043280f925d390e4bebf3884d4762ac62cc6
fbshipit-source-id: 2982043280f925d390e4bebf3884d4762ac62cc6
2016-03-29 19:53:20 -07:00
Adam Ernst a16771c5dc Remove unused RCTBridgeModuleClassIsRegistered
Reviewed By: nicklockwood

Differential Revision: D3088367

fb-gh-sync-id: e91a8905bb361bcb430d3efc0dd56ab53321572e
shipit-source-id: e91a8905bb361bcb430d3efc0dd56ab53321572e
2016-03-23 17:23:20 -07:00
Alexey Lang 030e34959e Don't schedule script execution on the main thread
Reviewed By: martinbigio

Differential Revision: D3069375

fb-gh-sync-id: baa9e4217957c82eb0bba05a8e93527476084a3b
shipit-source-id: baa9e4217957c82eb0bba05a8e93527476084a3b
2016-03-22 09:33:28 -07:00
Nick Lockwood d033c45f93 Extracted rootview-specific shadowview logic into new class
Summary:It was hard to understand which parts of the shadowview API are designed to be called only on the root view, and which were applicable to any view.

This diff extracts rootview-specific logic out into a new RCTRootShadowView class.

Reviewed By: majak

Differential Revision: D3063905

fb-gh-sync-id: ef890cddfd7625fbd4bf5454314b441acdb03ac8
shipit-source-id: ef890cddfd7625fbd4bf5454314b441acdb03ac8
2016-03-21 03:21:27 -07:00
Michelle Hwang 14555063bb backout (and remove) props.lineBreakMode from Text
Reviewed By: jingc

Differential Revision: D3063164

fb-gh-sync-id: 81776866c09bb06411b9660f1f4833ba515e046a
shipit-source-id: 81776866c09bb06411b9660f1f4833ba515e046a
2016-03-17 11:48:24 -07:00
Martín Bigio dd2415df73 seek & read RAM Bundle
Summary: For RAM bundling we don't want to hold the entire bundle in memory as that approach doesn't scale. Instead we want to seek and read individual sections as they're required. This rev does that by detecting the type of bundle we're dealing with by reading the first 4 bytes of it. If we're dealing with a RAM Bundle we bail loading.

Reviewed By: javache

Differential Revision: D3026205

fb-gh-sync-id: dc4c745d6f00aa7241203899e5ba136915efa6fe
shipit-source-id: dc4c745d6f00aa7241203899e5ba136915efa6fe
2016-03-17 10:35:28 -07:00
Alexey Lang 24f7d88c98 Fix showing RCTPerformanceLogger data
Reviewed By: nicklockwood

Differential Revision: D3064023

fb-gh-sync-id: df9358dddfcc79e12a65a8b9c182615be64fc468
shipit-source-id: df9358dddfcc79e12a65a8b9c182615be64fc468
2016-03-17 07:27:27 -07:00
Alexey Lang 26d9417f2b Track native modules which use the main thread for initialization or gathering constants
Reviewed By: majak

Differential Revision: D3054146

fb-gh-sync-id: fd4f4c0dff3144d22357ea798d3131aee578d509
shipit-source-id: fd4f4c0dff3144d22357ea798d3131aee578d509
2016-03-16 09:48:42 -07:00
Alexey Lang f6853b8eac Add more performance logs and improve Systrace support
Reviewed By: tadeuzagallo

Differential Revision: D3040998

fb-gh-sync-id: c5ab4e5bcc073f94a2d309bfa7698919cf7e8856
shipit-source-id: c5ab4e5bcc073f94a2d309bfa7698919cf7e8856
2016-03-15 05:41:28 -07:00
aleclarsoniv 64a09feaf7 Add 'props.lineBreakMode' to Text
Summary:I've tested this manually, but I'm not sure how to write a test for this. Hopefully someone can help out there. The least I could do is provide a starting point for a PR to be accepted.

Additionally, I've renamed the existing `NSLineBreakMode` enum converter (inside `RCTConvert`) to use dashes in the names instead of camelcase (eg: `word-wrapping` instead of `wordWrapping`).

Fixes #6338
Closes https://github.com/facebook/react-native/pull/6339

Differential Revision: D3052391

Pulled By: nicklockwood

fb-gh-sync-id: 1536dfc139d7995095e9ee9d5f13ca86f90783c5
shipit-source-id: 1536dfc139d7995095e9ee9d5f13ca86f90783c5
2016-03-15 04:16:30 -07:00
Marc Horowitz 225899dcf0 Declare RCTPerformanceLogger functions RCT_EXTERN
Reviewed By: nicklockwood

Differential Revision: D3035404

fb-gh-sync-id: 0b733a95b57aa79659c7feee961c92bd3f25c03f
shipit-source-id: 0b733a95b57aa79659c7feee961c92bd3f25c03f
2016-03-11 03:18:21 -08:00
Mike Grabowski 2bb2522f1e Don't lose NSError code in RCTJSErrorFromNSError()
Summary:Fixes #6171

Send original error code back to JS - this reverts old functionality according to https://github.com/facebook/react-native/issues/6171#issuecomment-189332649, that is 3c541ca540/React/Base/RCTUtils.m (L299)
Closes https://github.com/facebook/react-native/pull/6201

Differential Revision: D2988618

Pulled By: javache

fb-gh-sync-id: 85a280b76e557bffc4d952ed7f39eeb8a88b66ba
shipit-source-id: 85a280b76e557bffc4d952ed7f39eeb8a88b66ba
2016-03-11 02:55:22 -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
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
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
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
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 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
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
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
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
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
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 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
Martin Kralik 4d83cfbc50 added RCTTouchEvent (5/7)
Summary:
This diff adds an implementation of `RCTEvent` protocol which represents touch events.
It's basically a copy of this code: c14cc123d5/React/Base/RCTTouchHandler.m (L194-L196)
which is replaced using `RCTTouchEvent` in the next diff (D2884593).

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: D2884592

fb-gh-sync-id: e35addcf15a7012f89644200a08f5856c7f57299
2016-02-03 05:24:02 -08:00
Martin Kralik 91e5829419 flush events queue when an event cannot be coalesced (4/7)
Summary:
Currently only scroll events are send through `sendEvent`, and all of them are can be coalesced. In future (further in the stack) touch events will go through there as well, but they won't support coalescing.
In order to ensure js processes touch and scroll events in the same order as they were created, we will flush the coalesced events when we encounter one that cannot be coalesced.

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: D2884591

fb-gh-sync-id: a3d0e916843265ec57f16aad2f016a79764dcce8
2016-02-03 05:23:55 -08:00
Martin Kralik 7f2b72528e RCTEvent protocol changes (3/7)
Summary:
I want to use the `RCTEvent` protocol for touch events as well. That's why I'm removing not very well defined `body` property and replacing it with `arguments` method, which will return an array that will be passed directly to the js call.
I think this makes sense because there is no unified arguments format for all events and and the called  js method (`moduleDotMethod`) is already event specific.
This way touch events and scroll events can result in calling a completely different js function with a completely different arguments (what they indeed currently do).

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: D2884590

fb-gh-sync-id: 2c1885c3414e255d8572c0fbbbfe62a23d94dd06
2016-02-03 05:23:50 -08:00
Martin Kralik 3e89c3ea3b removed `coalescingKey` from events (2/7)
Summary:
This property was never used, so I'm removing it.

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

Reviewed By: javache

Differential Revision: D2884587

fb-gh-sync-id: acd5e576cd13a02e77225f3b308232f8331d3b61
2016-02-03 05:23:43 -08:00
Martin Kralik ee533037f6 removed unused RCTBaseEvent (1/7)
Summary:
`RCTBaseEvent` was never used. This diff removes it.

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

Reviewed By: javache

Differential Revision: D2884585

fb-gh-sync-id: 66a6afcda3b5baec7f768682da215570f6d33bb1
2016-02-03 05:23:36 -08:00
Nick Lockwood 46106f756a Ported `source` prop over to iOS WebView
Summary:
public
https://github.com/facebook/react-native/pull/5494 added a new `source` property to WebView on Android that provides a better API, as well as allowing for request headers to be set.

This diff ports that functionality over to iOS, so we can have a consistent API cross-platform.

I've also extended the API to include `method` (GET or POST) and `body` when setting the WebView content with a URI, and `baseUrl` when setting static HTML.

Reviewed By: javache

Differential Revision: D2884643

fb-gh-sync-id: 83f24494bdbb4e1408aa8f3b7428fee33888ae3a
2016-02-01 18:01:35 -08:00
Nick Lockwood f685878938 Improved 3D touch implementation, and added example
Summary:
public
This diff improves the implementation of 3D touch by adding a `forceTouchAvailable` constant to View that can be used to check if the feature is supported.

I've also added an example of how you can use the `force` property of the touch event to measure touch pressure in React Native.

Reviewed By: vjeux

Differential Revision: D2864926

fb-gh-sync-id: 754c54989212ce4e4863716ceaba59673f0bb29d
2016-01-27 09:05:36 -08:00
Matt Apperson fff5dc3943 Add 3dTouch props to touch events
Summary:
This adds the first of the three 3dTouch API types, that found on the touch event.

It adds the `force` prop to touch events when running on iOS 9 devices:
Closes https://github.com/facebook/react-native/pull/3055

Reviewed By: svcscm

Differential Revision: D2860540

Pulled By: nicklockwood

fb-gh-sync-id: 95a3eb433837c844f755b3ed4a3dfcb28452c284
2016-01-27 07:14:34 -08:00
Nick Lockwood 7419a82bd7 Handle bad JSON data without crashing
Summary:
public
NSJSONSerialization throws an exception when it encounters bad JSON data, including NaN values, which may not be a programming error.

This diff adds code to catch those exceptions and convert to an error. Also, if no error handling is in place, RCTJSONStringify will now display a redbox, and attempt to recover by sanitizing the JSON data and retrying.

Reviewed By: javache

Differential Revision: D2854778

fb-gh-sync-id: 18e6990af0d91083496d6a0b75c31a94ed9454a5
2016-01-26 06:13:29 -08:00
Nick Lockwood cd2eed0d36 RCTGzipData() acceps nil input, but was not marked as returning nullable output
Reviewed By: milend

Differential Revision: D2854721

fb-gh-sync-id: 336b3261f1694bcc173f267582561c0314c0cea0
2016-01-22 08:40:29 -08:00
Nick Lockwood 36e0dd2d48 Fixed screen size bug on iPhone6+
Summary:
public

This diff fixes a bug in RCTScreenScale() on iPhone6+. The issue was due to the fact that the iPhone6+'s virtual screen resolution of 414x736 points 3x resolution (1242x2208 pixels) does not match its actual screen resolution, which is 1080p (1080x1920 pixels).

I did not realize that `[UIScreen mainScreen].nativeBounds` reports the *actual* resolution, not the virtual resolution, and was dividing by the virtual scale (3.0) instead of the actual native scale factor (2.6).

This only affects iPhone6+, because for all other iOS devices, the virtual resolution matches the native resolution.

Reviewed By: milend

Differential Revision: D2854663

fb-gh-sync-id: bce8965a151e2f005a02a5f6b54f259d01b9ab12
2016-01-22 08:19:36 -08:00
Martin Kralik c14cc123d5 API for cancelling RCTTouchHandler
Reviewed By: spicyj

Differential Revision: D2846573

fb-gh-sync-id: 652864c773d03c24f0d68dd8335401eb052fc1bf
2016-01-21 13:46:52 -08:00
Nick Lockwood 34d5fa2695 RCTUtils Obj-C nullability annotations
Summary:
Add Objective-C nullability annotations to RCTUtils

public

Reviewed By: javache

Differential Revision: D2797331

fb-gh-sync-id: b918179625865760edc8c6fcc189ad78f819f3e3
2016-01-21 07:50:43 -08:00
Nick Lockwood 21fcbbc32c Generalized image decoding and resizing logic
Summary:
public

Standardises the image decoding logic for all image sources, meaning we get the benefits of efficient downscaling of images from all sources, not just ALAssets.

Reviewed By: javache

Differential Revision: D2647083

fb-gh-sync-id: e41456f838e4c6ab709b1c1523f651a86ff6e623
2016-01-20 11:11:13 -08:00
Pieter De Baets 1dffd056bf Fix default logger's loglevel, improve default error handler
Reviewed By: majak

Differential Revision: D2834267

fb-gh-sync-id: c89ce5160f03f57409497cc802690c8360d88a4d
2016-01-20 10:28:38 -08:00
Pieter De Baets 8ea9a1bc94 Invalidate JS executor when loading fails
Summary:
This solves https://github.com/facebook/react-native/issues/5090. Since 5b4e873c68 we had better reporting for when calls from native to JS fail. When trying to load an invalid bundle, this would now cause a stackoverflow, since RCTFatal would schedule a JS call to log, which would RCTFatal, which would ...

By invalidating the jsExecutor immediately after loading fails, we prevent any more attempts to log. We can't invalidate the whole bridge at this point since we still need the redbox module to actually display the error.

public

Reviewed By: majak

Differential Revision: D2834251

fb-gh-sync-id: a3e2ad425e40560beae4d3eacb93f66ace5341bf
2016-01-19 14:35:33 -08:00
Dave Miller 0c5f279c9d Standardize Error objects for Promises
Summary:
public

Promises are coming.  And as part of it, we are standardizing the error objects that will be returned.  This puts the code in place on the Android side to always send the proper error format.

It will be an error object like this
  {
    code : "E_SOME_ERROR_CODE_DEFINED_BY_MODULE", // Meant to be machine parseable
    message : "Human readable message",
    nativeError : {} // Some representation of the underlying error (Exception or NSError) , still figuring out exactly, but hopefully something with stack info
  }

Reviewed By: nicklockwood

Differential Revision: D2840128

fb-gh-sync-id: 174d620e2beb53e1fc14161a10fd0479218d98a6
2016-01-19 12:20:37 -08:00
Pieter De Baets c8355d377f Don't register classes only found at runtime
Summary:
This caused issues for me when I tried to provide a native module on init that was also KVO'd (and dynamically subclassed)

On closer inspection, it also seems highly inconsistent to register these classes in DEBUG mode but have them fail silently in production. Reducing the difference between debug and release seems like a safer option.

public

Reviewed By: nicklockwood

Differential Revision: D2819838

fb-gh-sync-id: 79ab72b1152c89eae38c965ff7724aba59a00949
2016-01-19 11:10:32 -08:00
Pieter De Baets 0fa1f8d94f Fix extra native modules missing bridge after reload
Summary:
public

Since we don't actually recreate our native modules every time (will fix in follow-up), we'd never update the reference after reloading the bridge, and all navigation would fail.

Reviewed By: majak

Differential Revision: D2811406

fb-gh-sync-id: 4f4fd73bbdecfe510e1e1554668b2354181f22a8
2016-01-07 12:03:28 -08:00
Nick Lockwood 571e646543 Improved null url handling
Summary:
public
Attempting to load an undefined URL via XMLHttpRequest produced a confusing error deep within the network layer. This diff improves the networking stack to catch such errors earlier, and also adds a helpful error in the JS layer.

Fixes https://github.com/facebook/react-native/issues/4558

Reviewed By: javache

Differential Revision: D2811080

fb-gh-sync-id: 1837427e1080a0308f2c4f9a8a42bce2e041fb48
2016-01-07 04:00:38 -08:00
Nick Lockwood 23cd9febbc Fixed deadlock in RCTModuleData
Summary:
public
Fixed a potential deadlock issue if code attempted to access a module via [bridge moduleForName/Class:] while it was being initialized.

Reviewed By: lry

Differential Revision: D2807827

fb-gh-sync-id: 58cafe9b92c094dde632d17245fb9b342a0fe9e0
2016-01-07 01:30:30 -08:00
Martín Bigio 0f9c88514c Remove `hot` query string attribut when HL is disabled
Summary:
public

By doing this we fix 2 problems:

1. We use the same url, both the first time the simulator starts with Hot Loading disabled (no `hot` attribute), and after HL has been enabled and then disabled ('hot=false'). By doing so, the packager will rebuild more than one bundle as file changes. We could have ignored this attribute on the packager but I'd rather not contaminate the server with it and instead make the clients send only 2 types of URLs.

2. The code on `RCTBatchedBridge.m` that decides whether or not to enable HMR does so by looking at presence of the query string parameter `hot`. If the parameter is present, even when it's false, it will try to enable HL, which is wrong.

Reviewed By: nicklockwood

Differential Revision: D2807512

fb-gh-sync-id: 728b680c2383c328d8967d34c10e7a6288e455ac
2016-01-06 11:55:33 -08:00
Pieter De Baets 435efadbba Re-enable testUnderlyingBridgeIsDeallocated
Reviewed By: jspahrsummers

Differential Revision: D2803543

fb-gh-sync-id: d62b68b1e23fad2a0b3d4e490459b1f38ca2dca1
2016-01-06 09:03:33 -08:00
Nick Lockwood 17df595e32 Implement Android's dispatchViewManagerCommand interface on iOS
Summary:
public
Android implement ViewManager methods via a dispatch method on UIManager, whereas iOS implements them by exposing the methods on the view manager modules directly.

This diff polyfills Android's implementation on top of the iOS implementation, allowing the same JS API to be used for both.

Reviewed By: javache

Differential Revision: D2803020

fb-gh-sync-id: 0da0544e593dc936467d16ce957a77f7ca41355b
2016-01-06 05:58:37 -08:00
Nick Lockwood 180fc06b7a Fixed iOS 7 support for URL query functions
Summary:
public
Unfortunately, it turns out that NSURLComponents.queryItems only works on iOS 8 and above. This diff re-implements the RCTGetURLQueryParam and RCTURLByReplacingQueryParam functions using functionality available in iOS 7.

Reviewed By: javache

Differential Revision: D2803679

fb-gh-sync-id: 56f10bef4894d16197975b6023b7aa5ab106d8cb
2016-01-05 12:57:44 -08:00
Nick Lockwood fc98956b65 Fix race conditions in RCTModuleData
Summary:
public
The logic inside RCTBatchedBridge contained some race conditions that would occasionally cause an error if modules were loaded in the wrong order. This improves that logic and makes it safer by adding a lock to prevent concurrency.

Reviewed By: jspahrsummers

Differential Revision: D2802930

fb-gh-sync-id: d1ad25fa578649363dcaac029cb24dc3a453ae67
2016-01-05 09:04:31 -08:00
Justin Spahr-Summers a5d82c2823 Add context executor API for sync hooks
Summary:
public

This exposes a proper API for adding synchronous callbacks to JS, as an optional feature of the executor.

This is based on nicklockwood's work in D2764492, but avoids refactoring bridge/executor interactions for the time being, since we agree on this API and can move the actual callsites around later.

Reviewed By: nicklockwood

Differential Revision: D2799506

fb-gh-sync-id: af209d9a0be927f3404205feb16e59745cc37aec
2016-01-05 08:00:38 -08:00
Fada Chen 18cdead76b revert D2773664
Reviewed By: dwitte

Differential Revision: D2802582

fb-gh-sync-id: 39d59be297f0f23e6a4e40175ad30284766349cb
2016-01-04 23:52:51 -08:00
Tadeu Zagallo 89ae0e040d 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: D2773664

fb-gh-sync-id: 4a8854b17b4741b882f5f2cc425e4237a5e4b3eb
2016-01-04 11:11:48 -08:00
Nick Lockwood ed4478a4ff Refactor hot loading implementation on iOS
Reviewed By: milend

Differential Revision: D2795580

fb-gh-sync-id: ad33ba152e40b622b10bfa0122afd6edc28a11bf
2016-01-04 10:40:32 -08:00
Nick Lockwood 64edddadcc Fixed race condition in RCTModuleData.methodQueue
Summary:
public
The implementation of the `methodQueue` lazy initializer in `RCTModuleData` could result in the queue being set twice, because calling `methodQueue` for a module that hasn't been instantiated would call `RCTModuleData.instance` to create the module, which itself calls `methodQueue`.

It's not clear if this was causing a bug, but it may be related to an occasional bug where the `RCTViewManager.methodQueue` returns nil.

Reviewed By: majak

Differential Revision: D2783320

fb-gh-sync-id: 9194da0fd7392f63825da1f5c450363dd300b635
2016-01-04 06:24:28 -08:00
Mike Armstrong e42c6d4446 Flows between RN Threads
Reviewed By: tadeuzagallo

Differential Revision: D2743733

fb-gh-sync-id: df4ae69a3501a37e08286857a8d4be3cd27c0ac3
2016-01-04 02:16:31 -08:00
Martín Bigio e43e2146d9 Gate Hot Loading
Summary:
public

Until we support this fature on OSS, don't show the menu option.

Reviewed By: vjeux

Differential Revision: D2791198

fb-gh-sync-id: 11b66d467c1ab784bbf549b893d0a3abd69e2741
2015-12-28 16:45:07 -08:00
Martín Bigio 4ffb241647 Hot Loading E2E basic flow
Summary:
public

Implement all the necessary glue code for several diffs submitted before to get Hot Loading work end to end:

- Simplify `HMRClient`: we don't need to make it stateful allowing to enable and disable it because both when we enable and disable the interface we need to reload the bundle.
- On the native side we introduced a singleton to process the bundle URL. This new class might alter the url to include the `hot` attribute. I'm not 100% sure this is the best way to implement this but we cannot use `CTLSettings` for this as it's are not available on oss and I didn't want to contaminate `RCTBridge` with something specific to hot loading. Also, we could potentially use this processor for other things in the future. Please let me know if you don't like this approach or you have a better idea :).
- Use this processor to alter the default bundle URL and request a `hot` bundle when hot loading is enabled. Also make sure to enable the HMR interface when the client activates it on the dev menu.
- Add packager `hot` option.
- Include gaeron's `react-transform` on Facebook's JS transformer.

The current implementation couples a bit React Native to this feature because `react-transform-hmr` is required on `InitializeJavaScriptAppEngine`. Ideally, the packager should accept an additional list of requires and include them on the bundle among all their dependencies. Note this is not the same as the option `runBeforeMainModule` as that one only adds a require to the provided module but doesn't include all the dependencies that module amy have that the entry point doesn't. I'll address this in a follow up task to enable asap hot loading (9536142)

I had to remove 2 `.babelrc` files from `react-proxy` and `react-deep-force-update`. There's an internal task for fixing the underlaying issue to avoid doing this horrible hack (t9515889).

Reviewed By: vjeux

Differential Revision: D2790806

fb-gh-sync-id: d4b78a2acfa071d6b3accc2e6716ef5611ad4fda
2015-12-28 16:44:59 -08:00
Pieter De Baets 4fde511f5c Remove warnings in RCTBridgeTests
Reviewed By: majak

Differential Revision: D2771228

fb-gh-sync-id: dd935094ceeff196c272565bf7efea5112059a1a
2015-12-23 14:42:31 -08:00
Pieter De Baets 0cfe76399c Improve red boxes coming from RCTWebSocketExecutor
Reviewed By: tadeuzagallo

Differential Revision: D2775452

fb-gh-sync-id: b709e0e725ab76468700466b804237eed9158bfd
2015-12-23 13:32:28 -08:00
Ryan Gomba 4472bb54c9 Use font name for weight if no weight property available
Summary:
Some custom fonts don't return a UIFontWeightTrait that is representative of their actual weight. For example, "AktivGrotesk-Light" and "AktivGrotesk-Medium" both return UIFontWeightTrait 0. While this is of course an issue with the font files themselves, licensing issues can make it difficult to modify them directly. When using these fonts, specifying weights in JS has no effect. I propose that if no weight information is available, we inspect the name of the font for weighting.
Closes https://github.com/facebook/react-native/pull/2113

Reviewed By: svcscm

Differential Revision: D2783383

Pulled By: nicklockwood

fb-gh-sync-id: 2a9caf99b6af74b7013ecc85417322b56c2dea20
2015-12-23 10:07:17 -08:00
Gaëtan Renaudeau f940e7c4a6 iOS: Fix Image source={{ uri: null }} to crash
Summary:
this is a recent regression because the error appeared in my app (from 0.16 to 0.17).

```
<Image source={{ uri: null }} />
```

will make an error:

```
[RCTConvert.m:55] Error setting property 'source' of RCTImageView with tag #317: JSON value '<null>' of type NSNull cannot be converted to NSString
```

The solution attached is to check that uri is a NSString and return nil if not (the same way nil is returned in case of invalid url).
Closes https://github.com/facebook/react-native/pull/4902

Reviewed By: svcscm

Differential Revision: D2779789

Pulled By: nicklockwood

fb-gh-sync-id: cfe429ec5e53e63b7b368c06e693424ca8aaa11e
2015-12-21 10:04:31 -08:00
Nick Lockwood ae9aaf81fb Switched over to OSS RCTTextView by default
Reviewed By: javache

Differential Revision: D2697267

fb-gh-sync-id: 275dded8425e2a81598a6055d830bc80b28177ad
2015-12-18 15:52:32 -08:00
Pieter De Baets b40631b3cc Remove unused RKAnalyticsCPULogger
Reviewed By: bryceredd

Differential Revision: D2766801

fb-gh-sync-id: c5088c01bbae6a10b17317cc5ec2adcf157f415e
2015-12-16 16:16:28 -08:00
Tadeu Zagallo 809627379b Rename RCTContextExecutor to RCTJSCExecutor
Summary:
public

Rename the executor to so it actually says something about the implementation.

Reviewed By: jspahrsummers, nicklockwood

Differential Revision: D2759688

fb-gh-sync-id: 5b1ac447e75109fbbc2ee71c804710d9926785aa
2015-12-16 02:51:28 -08:00
Tadeu Zagallo f8c125c64b Remove redundant profile events
Summary:
public

Remove some of the manual markers from the bridge since they will already be added dinamically.

Reviewed By: jspahrsummers

Differential Revision: D2761748

fb-gh-sync-id: 0c726373f9105258feb8230d30453559ed1e6a65
2015-12-16 02:31:29 -08:00
Nick Lockwood d03d28684a Simplified session management
Reviewed By: javache

Differential Revision: D2355911

fb-gh-sync-id: 57748dd6e5fe2ab6954c23526c2f5e8b46fd526b
2015-12-15 10:51:33 -08:00
Nick Lockwood f7edcda5d7 Deprecated RCTDidCreateNativeModules notification
Summary:
public

Thanks to the new lazy initialization system for modules, `RCTDidCreateNativeModules` no longer does what the name implies.

Previously, `RCTDidCreateNativeModules` was fired after all native modules had been initialized. Now, it simply fires each time the bridge is reloaded. Modules are created on demand when they are needed, so most of the assumptions about when `RCTDidCreateNativeModules` will fire are now incorrect.

This diff deprecates `RCTDidCreateNativeModules`, and adds a new notification, `RCTDidInitializeModuleNotification`, which fires each time a module a new module is instantiated.

If you need to access a module at any time you can just call `-[bridge moduleForClass:]` and the module will be instantiated on demand. If you want to access a module *only* after it has already been instantiated, you can use the `RCTDidInitializeModuleNotification` notification.

Reviewed By: tadeuzagallo

Differential Revision: D2755036

fb-gh-sync-id: 25bab6d5eb6fcd35d43125ac45908035eea01487
2015-12-15 05:43:33 -08:00
Tadeu Zagallo 2d61dfd9c1 Replace private bridge categories with private header
Summary:
public

A lot of the core modules have to use private methods in the bridge, specially
since the `RCTBatchedBridge` interface is never exposed. That was leading to a
lot of different private bridge categories spread across different modules,
which makes harder to identify which modules are affected by private API changes.

Replace all the categories with a single private header.

Reviewed By: nicklockwood

Differential Revision: D2757564

fb-gh-sync-id: 793158b9082d542b74a6094ed0db4d5dc3a88f78
2015-12-15 05:40:27 -08:00
Martin Kralik a86171a482 exposed a way to trigger layout on the uimanager
Summary:
A component can be backed by native "node" that can change its internal state, which would result in a new UI after the next layout. Since js has no way of knowing that this has happened it wouldn't trigger a layout if nothing in js world has changed. Therefore we need a way how to trigger layout from native code.

This diff does it by adding methods `layoutIfNeeded` on the uimanager and `isBatchActive` on the bridge.
When `layoutIfNeeded` is called it checks whether a batch is in progress. If it is we do nothing, since at it's end layout happens. If a batch is not in progress we immidiately do layout.

I went with the easiest way how to implement this - `isBatchActive` is a public method on the bridge. It's not ideal, but consistent with other methods for modules.
public

Reviewed By: jspahrsummers, nicklockwood

Differential Revision: D2748896

fb-gh-sync-id: f3664c4af980d40a463b538e069b26c9ebad6300
2015-12-11 06:59:30 -08:00
Justin Spahr-Summers 44cbec28bd Work around race condition in bridge deallocation
Reviewed By: tadeuzagallo, nicklockwood

Differential Revision: D2748820

fb-gh-sync-id: 40084ab4bcc606ccbde8b71c2389e602c4dd8e22
2015-12-11 01:45:29 -08:00
Nick Lockwood 88ac40666c Replaced RegExp method parser with recursive descent
Summary:
public

This diff replaces the RegEx module method parser with a handwritten recursive descent parser that's faster and easier to maintain.

The new parser is ~8 times faster when tested on the UIManager.managerChildren() method, and uses ~1/10 as much RAM.

The new parser also supports lightweight generics, and is more tolerant of white space.

(This means that you now can – and should – use types like `NSArray<NSString *> *` for your exported properties and method arguments, instead of `NSStringArray`).

Reviewed By: jspahrsummers

Differential Revision: D2736636

fb-gh-sync-id: f6a11431935fa8acc8ac36f3471032ec9a1c8490
2015-12-10 10:12:29 -08:00
Nick Lockwood d138403c2e Added deferred module loading feature
Reviewed By: javache

Differential Revision: D2717687

fb-gh-sync-id: 4c03c721c794a2e7ac67a0b20474129fde7f0a0d
2015-12-10 04:31:30 -08:00
Tadeu Zagallo cd4574498d Use actual CADisplayLink timestamp for VSYNC
Summary:
public

Use the actual timestamp provided through `CADisplayLink` instead of the time
the handler is called.

Reviewed By: jspahrsummers

Differential Revision: D2739121

fb-gh-sync-id: 1da28190bb25351dc3dd94efaff21d49279a570f
2015-12-09 09:56:27 -08:00
Sebastian Markbage 8d397b4cbc Decouple Module System from Native Calls
Summary:
The JavaScript ecosystem doesn't have the notion of a built-in native module loader. Even Node is decoupled from its module loader. The module loader system is just JS that runs on top of the global `process` object which has all the built-in goodies.

Additionally there is no such thing as a global require. That is something unique to our providesModule system. In other module systems such as node, every require is contextual. Even registered npm names are localized by version.

The only global namespace that is accessible to the host environment is the global object. Normally module systems attaches itself onto the hooks provided by the host environment on the global object.

Currently, we have two forms of dispatch that reaches directly into the module system. executeJSCall which reaches directly into require. Everything now calls through the BatchedBridge module (except one RCTLog edge case that I will fix). I propose that the executors calls directly onto `BatchedBridge` through an instance on the global so that everything is guaranteed to go through it. It becomes the main communication hub.

I also propose that we drop the dynamic requires inside of MessageQueue/BatchBridge and instead have the modules register themselves with the bridge.

executeJSCall was originally modeled after the XHP equivalent. The XHP equivalent was designed that way because the act of doing the call was the thing that defined a dependency on the module from the page. However, that is not how React Native works.

The JS side is driving the dependencies by virtue of requiring new modules and frameworks and the existence of dependencies is driven by the JS side, so this design doesn't make as much sense.

The main driver for this is to be able to introduce a new module system like Prepack's module system. However, it also unlocks the possibility to do dead module elimination even in our current module system. It is currently not possible because we don't know which module might be called from native.

Since the module system now becomes decoupled we could publish all our providesModule modules as npm/CommonJS modules using a rewrite script. That's what React Core does.

That way people could use any CommonJS bundler such as Webpack, Closure Compiler, Rollup or some new innovation to create a JS bundle.

This diff expands the executeJSCalls to the BatchedBridge's three individual pieces to make them first class instead of being dynamic. This removes one layer of abstraction. Hopefully we can also remove more of the things that register themselves with the BatchedBridge (various EventEmitters) and instead have everything go through the public protocol. ReactMethod/RCT_EXPORT_METHOD.

public

Reviewed By: vjeux

Differential Revision: D2717535

fb-gh-sync-id: 70114f05483124f5ac5c4570422bb91a60a727f6
2015-12-08 16:03:37 -08:00
Nick Lockwood b672294858 Added RCTImageSource
Summary:
public

The +[RCTConvert UIImage:] function, while convenient, is inherently limited by being synchronous, which means that it cannot be used to load remote images, and may not be efficient for local images either. It's also unable to access the bridge, which means that it cannot take advantage of the modular image-loading pipeline.

This diff introduces a new RCTImageSource class which can be used to pass image source objects over the bridge and defer loading until later.

I've also added automatic application of the `resolveAssetSource()` function based on prop type, and fixed up the image logic in NavigatorIOS and TabBarIOS.

Reviewed By: javache

Differential Revision: D2631541

fb-gh-sync-id: 6604635e8bb5394425102487f1ee7cd729321877
2015-12-08 03:32:30 -08:00
Pieter De Baets 1a748f5ed6 Fix profile build
Reviewed By: jspahrsummers

Differential Revision: D2717604

fb-gh-sync-id: 9817bf743de0d6b5bd22f12ae50a8e1f99c1c0c3
2015-12-03 04:25:28 -08:00
Justin Spahr-Summers 8e55858397 Precompute whether modules respond to batch notification methods
Summary:
public

Looping through every `RCTModuleData` to check whether the module responds to `-batchDidComplete` or `-partialBatchDidFlush` is unnecessarily expensive. We can cache the answer at the time that the module instance is actually initialized.

Reviewed By: tadeuzagallo

Differential Revision: D2717594

fb-gh-sync-id: 274a59ec2d6014ce18c93404ce6b9940c1dc9c32
2015-12-03 04:20:27 -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
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
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
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
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
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
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
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
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
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 fa0b45c58b Replaced RCTSparseArray with NSDictionary
Reviewed By: jspahrsummers

Differential Revision: D2651920

fb-gh-sync-id: 953e2ea33abfc7a3a553da95b13e9ab2bccc5a1c
2015-11-14 10:28:28 -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
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
Pieter De Baets 215872c2eb Provide log source to handler
Reviewed By: majak

Differential Revision: D2615567

fb-gh-sync-id: a245813220436f2d83ae2ae28bde916cecb3f416
2015-11-11 06:44:30 -08:00
Christopher Dro f407211131 Add keyboardAppearance prop to TextInput component.
Summary: Resolves #3649.
Closes https://github.com/facebook/react-native/pull/4012

Reviewed By: javache

Differential Revision: D2636538

Pulled By: nicklockwood

fb-gh-sync-id: 022e79d8f8fa684cad43af1a51f728d60ac652a8
2015-11-11 05:38:35 -08:00
Tadeu Zagallo 0764e4ef29 Kill RCTWebViewExecutor
Summary: public

The WebView executor has no benefits compared to the JSC executor (slower, no extra debugging tools...),
and it's pretty hacky (since it injects the code in a script tag we have to check for tags in the comments and etc...).

Reviewed By: nicklockwood, javache

Differential Revision: D2636465

fb-gh-sync-id: 0d0f8a59e2c12fe7905b02060b3938c894d2802b
2015-11-10 05:25:28 -08:00
Pieter De Baets a377f81b4e Fix check for rethrowing RCTFatal exceptions
Summary: I changed the format slightly of the exception being generated in RCTFatal, so we we're catching and rethrowing it, which left some useful information of the error stack.

public

Reviewed By: majak

Differential Revision: D2631341

fb-gh-sync-id: feb4939f58014171a55cd74f20f57bcd6dfddc1e
2015-11-10 04:30:37 -08:00
Tadeu Zagallo e5b843834d Rename RCTProfile(Begin|End)Event
Summary: public

Rename it to `RCT_PROFILE_(BEGIN|END)_EVENT` to make it clearer that it's a macro,
since it has special behaviours.

Reviewed By: jspahrsummers

Differential Revision: D2631542

fb-gh-sync-id: 629c139462c4aa3582f719b14482017d13676e33
2015-11-09 08:43:29 -08:00
Tadeu Zagallo e1fa325569 Change async events' cookie to NSUInteger
Summary: public

As jspahrsumemrs pointed out, `int` could overflow pretty easy, since it was static,
change it to an NSUInteger and downcast it when need to interop.

Reviewed By: jspahrsummers

Differential Revision: D2625902

fb-gh-sync-id: 2052be47a7b0ed81484da004fa18d6ef5baf26f7
2015-11-08 10:20:29 -08:00
Tadeu Zagallo 8dac41b7f0 Rename variable to unbreak the build
Reviewed By: javache

Differential Revision: D2625963

fb-gh-sync-id: 136013d7fa3b8eea322eea4ec45901376c30881d
2015-11-06 07:23:25 -08:00
Tadeu Zagallo de1c0169fc Clean up unnecessary profile events
Summary: public

There were some old markers that are now automatically inject and now are no longer necessary (+ one that was missing an end call :( ))

Reviewed By: javache

Differential Revision: D2625901

fb-gh-sync-id: 4c4c9d6b4e8e2b4bdb9c64fde01000b0ca2e9f47
2015-11-06 06:55:30 -08:00
Pieter De Baets c1ae4780ce Fix crash in RCTLog
Reviewed By: tadeuzagallo

Differential Revision: D2625795

fb-gh-sync-id: 6983a2dc9259fa1777c05011c2752e9520aa26cd
2015-11-06 06:36:29 -08:00
Nick Lockwood faa584c3bd Added headerdoc for RCTBridgeDelegate
Reviewed By: javache

Differential Revision: D2622807

fb-gh-sync-id: 68d1e8cfd3beceafd07f041fa2976ac2552600f7
2015-11-06 05:28:33 -08:00
Pieter De Baets d9b4c57e12 Remove log level 'log' from JS
Summary: Log level 'log' from JS should be equivalent to 'info'. Also added knowledge of 'trace' log level in RCTLog.

public

Reviewed By: vjeux

Differential Revision: D2615500

fb-gh-sync-id: 7a02f49bf7953c1a075741c21e984470c44b5551
2015-11-05 12:51:41 -08:00
Pieter De Baets 824858c6b2 Add convenience function for formatting NSError for reporting
Reviewed By: nicklockwood

Differential Revision: D2620933

fb-gh-sync-id: c5c40b78b19f12c9a3b1564b1e21f1acb12309ab
2015-11-05 12:51:34 -08:00
Pieter De Baets 31b5b0ac01 Create RCTFatal for reporting fatal React events
Summary: public

Add RCTFatal for reporting fatal runtime conditions. This centralizes failure handling to one function and allows you to customize how they should be handled. RCTFatal will be logged to the console and as a redbox and will also be triggered by fatal exceptions coming from RCTExceptionsManager.

Note that there is no RCTLogFatal, since just logging the fatal condition does not allow us to handle it consistently.

Reviewed By: nicklockwood

Differential Revision: D2615490

fb-gh-sync-id: 7d8e134419e10a8fb549297054ad955db3f6bee0
2015-11-05 12:51:27 -08:00
Mark Miyashita f8df38424e Use mainBundle in RCTConvert to resolve asset paths
Summary: See #3888 for why this is necessary. Essentially, `[NSBundle mainBundle]` loads the file path for the target app which is the only way to reference images.

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

Reviewed By: svcscm

Differential Revision: D2615580

Pulled By: nicklockwood

fb-gh-sync-id: d06ce0987dde666b06bb5a7edf609ed45f325d2c
2015-11-05 09:30:36 -08:00
Nick Lockwood 11df4cb08c Fixed display of alerts on top of modal window
Reviewed By: javache

Differential Revision: D2616170

fb-gh-sync-id: f72f728008099fff6fc966d7a2ce4c0d27a4fefd
2015-11-05 03:54:31 -08:00
Tadeu Zagallo 0c74804427 Use dispatch_async instead of lock
Summary: public

The initial implementation used a lock to manage the stored profile information,
blocking the caller thread for longer than it should. Replace it with a private
queue, since the only thing we need to from the caller is to record the immediate
call time and the caller thread/queue, all the rest has absolutely no priority.

Use macros to also defer work done when generate the name of the events.

Reviewed By: nicklockwood

Differential Revision: D2603120

fb-gh-sync-id: e3e36160c893e7ae9ed3558f07c854ea76396661
2015-11-04 09:03:01 -08:00
Nick Lockwood c5b990f65f Added lightweight generic annotations
Summary: public

Added lightweight genarics annotations to make the code more readable and help the compiler catch bugs.

Fixed some type bugs and improved bridge validation in a few places.

Reviewed By: javache

Differential Revision: D2600189

fb-gh-sync-id: f81e22f2cdc107bf8d0b15deec6d5b83aacc5b56
2015-11-03 14:49:30 -08:00
Pawel Sienkowski d0371165c3 Fix the way the Storyline native module is updated
Reviewed By: javache

Differential Revision: D2609706

fb-gh-sync-id: dcacd9085243d04f4e0dfa8d4a4c5df594ef31ec
2015-11-03 08:58:28 -08:00
Tadeu Zagallo 27be386c2e Fix trace name for native module calls received from JS
Summary: public

At some point the profile call was changed to only pass `@"invoke callback"`
rather than the module name, which makes most entries pretty much useless.
Change it back to be the module name.

Reviewed By: javache

Differential Revision: D2602222

fb-gh-sync-id: c4e8e3f559f66725620293cc575baf5ede48df31
2015-11-03 03:51:27 -08:00
Dave Sibiski 6c7c845145 Implements `onKeyPress`
Summary: - When a key is pressed, it's `key value` is passed as an argument to the callback handler.
 - For `Enter` and `Backspace` keys, I'm using their `key value` as defined [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key#Key_values). As per JonasJonny & brentvatne's [suggestion](https://github.com/facebook/react-native/issues/1882#issuecomment-123485883).

- Example
```javascript
 _handleKeyPress: function(e) {
      console.log(e.nativeEvent.key);
  },

  render: function() {
    return (
      <View style={styles.container}>
        <TextInput
            style={{width: 150, height: 25, borderWidth: 0.5}}
            onKeyPress={this._handleKeyPress}
        />
        <TextInput
            style={{width: 150, height: 100, borderWidth: 0.5}}
            onKeyPress={this._handleKeyPress}
            multiline={true}
        />
      </View>
    );
  }
```
- Implements [shouldChangeCharactersInRange](https://developer.apple.com/library/prerelease/ios/documentat
Closes https://github.com/facebook/react-native/pull/2082

Reviewed By: javache

Differential Revision: D2280460

Pulled By: nicklockwood

fb-gh-sync-id: 1f824f80649043dc2520c089e2531d428d799405
2015-11-02 09:15:31 -08:00
Nick Lockwood 6539b26810 Fixed whitespace bug with RCTModuleMethod parsing
Summary: public

White space between the end of the first part of the method selector and the first colon was being included in the JS method name.

(See: https://github.com/facebook/react-native/issues/3804)

Reviewed By: javache

Differential Revision: D2605713

fb-gh-sync-id: b4402c9ede5eb31dd38021c902f046a4e0557814
2015-11-02 08:53:29 -08:00
Tadeu Zagallo ccd90e25c1 Convert remaining uses of alloc] init] to new]
Summary: public

We moved to using `new` instead of `alloc] init` but there was still some calls
left.

Reviewed By: javache

Differential Revision: D2604679

fb-gh-sync-id: ff7300ecbedb55dd5e93873592598810c9b87808
2015-11-02 08:03:17 -08:00
Tadeu Zagallo 287e0e3c49 Add RCTPerformanceLogger data to PerfMonitor
Summary: public

Add information the times recorded by RCTPerformanceLogger to RCTPerfMonitor,
tap the monitor to show a table view with the data.

Reviewed By: jspahrsummers

Differential Revision: D2595372

fb-gh-sync-id: dc3b73af71b6d7f258e4e5991116bbc6cedc21fb
2015-10-30 16:57:30 -07:00
Pawel Sienkowski db71dde10a Props setter for RCTRootView
Reviewed By: javache

Differential Revision: D2587673

fb-gh-sync-id: 79fff15b625ed9f4856ec75246ecafd1f7ef95f1
2015-10-30 09:28:27 -07:00
Nick Lockwood 9f4da92195 Fixed UIExplorer tests + async methods
Summary: public

UIExplorer tests were broken due to a refactor that didn't update the RCTShadowViewTests + an off-by-one error in the logic for exporting async methods.

Reviewed By: javache

Differential Revision: D2595810

fb-gh-sync-id: c25a8b8956bff1ef2754bba4a8f10d72a16e2954
2015-10-29 15:57:29 -07:00
Nick Lockwood e9c7ebfd9a Ensure bad JS does not crash the app
Summary: public

We have code in place to ensure that a red box is displayed when bad arguments are sent to exported methods, however the methods were still being called with nil values for those arguments, resulting in crashes if the method wasn't set up to handle nil gracefully.

This diff ensures that methods will not be called if any of the argument conversion functions log an error. It also explicitly checks for nil output for arguments that are marked as nonnull.

Reviewed By: javache, tadeuzagallo

Differential Revision: D2580658

fb-gh-sync-id: aad6be758ea19f9b4521f3f9f0407bf672c0a2dd
2015-10-29 05:15:30 -07:00
David Aurelio 40f513aa71 Bring back D2570057 (previously backed out) + fixes
Reviewed By: nicklockwood

Differential Revision: D2590604

fb-gh-sync-id: 63a0e0c6afda740f22aacb3f469d411f236fa16b
2015-10-28 18:44:26 -07:00
Pawel Sienkowski 84a0874f0d Delay delegate call until RN content is available
Reviewed By: javache

Differential Revision: D2557315

fb-gh-sync-id: 305350fa74821eec5537fbcf96896e46e929f28a
2015-10-28 08:48:27 -07:00
David Aurelio 4ac898fceb Backout D2570057
Reviewed By: kmagiera

Differential Revision: D2590341

fb-gh-sync-id: 8a6073de3ef2a6e87b785a2bb252468a37c081cf
2015-10-28 08:28:25 -07:00
Nick Lockwood 500ffa9b76 Fixed dev mode override to work with unminified JS
Summary: public

The dev mode override feature was built with the assumption that bunlded JS would be minified, and broke with unminified JS. This fixes that by using a more robust regex-based search.

Reviewed By: tadeuzagallo

Differential Revision: D2581240

fb-gh-sync-id: 4d4b45eb8573ceb956b7259550d80a9807f83d59
2015-10-27 04:14:29 -07:00
Mike Armstrong 385ac02aeb attributes for setting alignment in SGText
Reviewed By: kukulski

Differential Revision: D2483597

fb-gh-sync-id: 003592b55b98af7a350f4789f3199b4e6d5f2c22
2015-10-27 03:41:26 -07:00
Pawel Sienkowski 576f5d79af Introduction of RCTRootViewDelegate
Reviewed By: adamjernst

Differential Revision: D2532327

fb-gh-sync-id: 0d018a6c2842f8021718fb7387ee6acb5d894645
2015-10-26 15:41:36 -07:00
Pawel Sienkowski 46803f0617 Size flexibility modes for RCTRootView
Reviewed By: javache

Differential Revision: D2526355

fb-gh-sync-id: 095a43bc01f883fdfdad3a086a35682c20c05597
2015-10-26 15:41:29 -07:00
Tadeu Zagallo 9069bdf1c2 Introduce Perf Monitor
Summary: public

Kill `RCTPerfStats` and introduce the new `RCTPerfMonitor`, including memory
usage, JSC heap size, number of RN views in screen, FPS (both on UI and JS threads)
and more to come.

It removes all the previous traces that were previous spread across the bridge
and the dev menu and moves everything to be more contained, so the whole thing
can be safely striped in production.

Reviewed By: nicklockwood

Differential Revision: D2575158

fb-gh-sync-id: 6a6d0c4422adbddeeefddd32ec3409a7095ff2a9
2015-10-23 10:56:56 -07:00
Nick Lockwood cae4761006 Use arrays for module method data
Summary: public

Use arrays instead of dictionaries for encoding module method information.

This further reduces UIExplorer startup JSON from 16104 bytes to 14119 (12% reduction)

Reviewed By: javache

Differential Revision: D2570057

fb-gh-sync-id: 4a53a9ead4365a136e7caeb650375733e1c24c0e
2015-10-23 10:16:26 -07:00
Pieter De Baets 039dab078a Fix configuration for OSS UIExplorer tests
Reviewed By: nicklockwood

Differential Revision: D2575356

fb-gh-sync-id: 0ab5bd29aa3c17a8cb067a8a17abed3e178c5bcf
2015-10-23 09:35:25 -07:00
Nick Lockwood ae5de54f00 Reduced module config data
Summary: public

We're sending a lot of module config data when the app first starts, and much of this is redundant.

UIExplorer current sends 19061 bytes of module config JSON. This diff reduces that to 16104 (15% saving) by stripping modules that have no methods or constants, and removing method types unless method is async.

Reviewed By: tadeuzagallo, javache

Differential Revision: D2570010

fb-gh-sync-id: 8c0abbd1cdee3264b37a4f52e852008caaffb9c5
2015-10-22 05:53:26 -07:00
Tadeu Zagallo 71da2917e5 Remove retainArguments from RCTModuleMethod's invocation
Summary: public

Fixes #2527

We were re-using the same invocation for every module's method, but calling
`[NSInvocation retainArguments]`, so the arguments would never be released.

Reviewed By: nicklockwood

Differential Revision: D2559997

fb-gh-sync-id: eafa3b3517c7cab3539954e26e250f7f668eee50
2015-10-22 04:04:25 -07:00
Alexey Lang 8ad09987e5 Log bundle size.
Reviewed By: javache

Differential Revision: D2564757

fb-gh-sync-id: c4429b735482ee6405b936e2dcdf610e9c6ad35f
2015-10-21 10:55:25 -07:00
Tadeu Zagallo 89c1747c33 Implement asm trampoline rather forwardInvocation
Summary: public

The profiler overrides all the methods of all the BridgeModules, and in order to
`start` and `end` the profiler at the function invocation time it used `NSInvocation`,
which is slow.

Replace it with a simple assembly method based on `objc_msgSend`.

Reviewed By: jspahrsummers

Differential Revision: D2550807

fb-gh-sync-id: 88ca08f9d6bfcd3035bda9304c93566c8818b46f
2015-10-20 04:14:09 -07:00
Tadeu Zagallo 31f9a690f3 Flush queue every 5ms during JS execution
Summary: public

Implement the iOS side of the optmisation previously implemented in android
(D2485402)

Depends on D2540746

Reviewed By: javache

Differential Revision: D2541118

fb-gh-sync-id: f3590600a6defa2da75c5b7b2cced6ad8bfea6cb
2015-10-19 08:04:24 -07:00
Frédéric Sagnes 4a3857ef1d Use JSStringCreateWithUTF8CString and skip NSString decoding when loading the bundle
Summary: public

Benchmarking our startup path has shown we spend a lot of time decoding strings (iPhone 4S / iPhone 5):

* reading a 2MB JS bundle: 35ms / 15ms
* decoding is to an `NSString`: 186ms / 78ms
* transforming that to a `JSString`: 29ms / 10ms

Instead of going through an `NSString` transformation, we generate a null-terminated bundle (0.1ms / 0.05ms to copy the data) and use `JSStringCreateWithUTF8CString` (121ms / 53ms) to generate the string. That makes decoding 70% faster.

Reviewed By: javache

Differential Revision: D2541140

fb-gh-sync-id: 09a016b8edfd46a9b62682c76705564d2024e75e
2015-10-16 08:11:25 -07:00
Tadeu Zagallo 529687f923 Defer calls until bridge finishes loading
Summary: @​public

When de-batching the calls from native -> JS, some calls were being dispatched
before the bridge had finished loading, which would cause lost calls when running
on the `ContextExecutor` and redbox when running in the Chrome debugger

Reviewed By: @javache

Differential Revision: D2540746

fb-gh-sync-id: ece29406648d3cbcb42cef3b32b8774ff0c15fd8
2015-10-14 09:49:23 -07:00
Pieter De Baets 44c651037a Disable RCTLog completely in production
Reviewed By: @nicklockwood

Differential Revision: D2521718

fb-gh-sync-id: f06c9af3906ae8cebca0d318fc2b0e2d03671220
2015-10-13 07:31:25 -07:00
Alexey Lang aabdc9cc9f Improve RCTPerfomanceLogger
Reviewed By: @mikearmstrong001

Differential Revision: D2531397

fb-gh-sync-id: 3f6c1831c9a7b62f857deda7a535589970cf2052
2015-10-13 06:44:27 -07:00
Tadeu Zagallo baf5b7b4d5 De-batch native->js calls and react updates
Summary: @​public

Take a step back and de-batch the bridge calls so we can have better profiling data and a better starting point to work on future optimisations. Also gave a 10~15% win on first render.

Reviewed By: @javache

Differential Revision: D2493674

fb-gh-sync-id: 05165fdd00645bdf43e844bb0c4300a2f63e7038
2015-10-13 06:44:25 -07:00
Tadeu Zagallo f7065e5c0a Support start and stopping systrace from repl
Reviewed By: @jspahrsummers

Differential Revision: D2512911

fb-gh-sync-id: f5441219f9d7063b3602c55efac9f07407e33f56
2015-10-12 09:45:40 -07:00
Nick Lockwood 799168929c Unify XCAsset handling logic
Summary: @​public

This diff unifies the logic for detecting when images refer to XCAsset files into a single function (RCTXCAssetNameForURL) and uses it for both +[RCTConvert UIImage:] and RCTImageLoader.

I've also tightened the definition of XCAssets so that it only applies to images inside .car files, not any image inside the main bundle. This avoids using the +[UIImage imageNamed:] when not strictly necessary, which is desirable since that method is not thread-safe, and has undocumented caching behavior that is difficult to reason about.

Reviewed By: @javache

Differential Revision: D2526400

fb-gh-sync-id: 7199c2a44f1d55ff236d2c38a0a9368739b993d5
2015-10-12 04:15:27 -07:00
Pieter De Baets 903eaa863c Fix logic for loading images from asset catalogs in RCTConvert
Reviewed By: @nicklockwood

Differential Revision: D2526264

fb-gh-sync-id: 039b0438fbce7c3e752271adc8d5aa5d4fe915e5
2015-10-09 07:46:41 -07:00
Uri Baghin f52cd5dc1e Use path instead of resourceSpecifier so it unescapes.
Reviewed By: @nicklockwood

Differential Revision: D2526217

fb-gh-sync-id: c48af71402927b0aa4e9942e1825068af5334ab9
2015-10-09 06:39:43 -07:00
Nick Lockwood 7fe7a2a26b Improved JS bundle loading performance
Summary: @​public

RCTJavaScriptLoader was using an NSURLSessionDataTask to load local bundle.js files. While this works, it was non-optimal from a performance point of view.

Reviewed By: @tadeuzagallo

Differential Revision: D2522598

fb-gh-sync-id: b32981b3be4c336512d1462d3f4943b5aad34ae0
2015-10-08 12:39:52 -07:00
Alexey Lang e3e9be9efb Log time to prepare native config
Reviewed By: @jspahrsummers

Differential Revision: D2517033

fb-gh-sync-id: fd560304f163b0ab9be592024e2a9b793fb990bc
2015-10-08 08:46:25 -07:00
Pieter De Baets 6ca8f4836d Disable RCTAssert completely in production builds
Reviewed By: @tadeuzagallo, @jspahrsummers

Differential Revision: D2521700

fb-gh-sync-id: f769afd98bb662e8bbe773adb45990f2175cdfe4
2015-10-08 08:26:20 -07:00
Nick Lockwood 63a37be1dd Removed RCTCache
Reviewed By: @tadeuzagallo

Differential Revision: D2410542

fb-gh-sync-id: 98af1b51802e69e7ede9a31feda0df5a526a6db5
2015-10-08 05:37:29 -07:00
Pieter De Baets 706cf38931 Fix Xcode analyzer warning
Reviewed By: @nicklockwood

Differential Revision: D2517025

fb-gh-sync-id: 3948f6b4255bc9035b2e7441469d0cc31c8027f8
2015-10-08 05:37:23 -07:00
Robert Fleischmann 0de9e0104a Provide default loading view for React views in Wilde
Reviewed By: @javache

Differential Revision: D2496540

fb-gh-sync-id: 31488a6d1fc1f679ab4361d6a8d48f19b2347703
2015-10-06 10:39:28 -07:00
Alexey Lang 7b514c63df Log native modules init time and config inject time separately
Reviewed By: @jspahrsummers

Differential Revision: D2508010
2015-10-05 11:05:23 -07:00
Pieter De Baets 0fb2fb37cc Silence analyzer warning for nil-checking NSNumber
Reviewed By: @jspahrsummers

Differential Revision: D2503068
2015-10-02 12:36:30 -07:00
Abhishek Sood e08a507f75 This reverts D2502620
Differential Revision: D2503381
2015-10-02 11:33:23 -07:00
Alexey Lang 737e011f96 log native modules init time and config inject time separately
Reviewed By: @tadeuzagallo, @jspahrsummers

Differential Revision: D2502620
2015-10-02 09:55:21 -07:00
Tadeu Zagallo beab8d52d4 Fix racing conditions on the profiler
Summary: @​public

The flow event methods weren't properly synchronized and neither was the module
unhooking.

Reviewed By: @jspahrsummers

Differential Revision: D2498719
2015-10-02 04:18:21 -07:00
Tadeu Zagallo eee2fd1ca2 Fix RCTConvert analyser error
Summary: @​public

Fix analyser error on RCTConvert where a key used to subscript an
NSMutableDictionary could possibly be nil.

Reviewed By: @alexeylang, @jspahrsummers

Differential Revision: D2498988
2015-10-02 03:35:22 -07:00
Pieter De Baets 9076b71ac3 Use bundleForClass instead of mainBundle to find resources
Reviewed By: @jspahrsummers

Differential Revision: D2485109
2015-09-29 10:36:23 -07:00
Alexey Lang e727fc817b Pause JS DisplayLink if nothing to process.
Reviewed By: @jspahrsummers

Differential Revision: D2489107
2015-09-29 09:22:10 -07:00
Alex Kotliarskyi f07dd70051 Managed assets support for RCTConvert
Reviewed By: @nicklockwood

Differential Revision: D2443130
2015-09-29 09:21:39 -07:00
Justin Spahr-Summers 0ff3a421c9 Actually define RCTSetLogThreshold()
Summary: This function was declared, but never defined, so calling it would crash your application.

I also took this opportunity to ensure that the logging threshold is given a default value upon initialization, not just the first time `RCTGetLogThreshold()` is called.

@​public

Reviewed By: @tadeuzagallo

Differential Revision: D2475622
2015-09-28 04:23:26 -07:00
Pieter De Baets 8f13560fd5 End slider interaction when touches are cancelled
Reviewed By: @jingc

Differential Revision: D2479259
2015-09-25 11:42:32 -07:00
James Ide 7615d74d14 Check self.isValid in RCTBatchedBridge after initial script evaluation
Summary: I noticed that sometimes the batched bridge would be valid before `[self enqueueApplicationScript:url:onComplete:]` but then become invalid in the completion callback. This diff checks `self.isValid` inside of the callback.

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

Reviewed By: @​trunkagent, @jspahrsummers

Differential Revision: D2443438

Pulled By: @tadeuzagallo
2015-09-24 08:20:05 -07:00
Tadeu Zagallo 98378cab18 Add gluecode for systrace
Summary: @​public

Add gluecode to allow use to systrace as the backend of RCTProfile

Reviewed By: @jspahrsummers

Differential Revision: D2439181
2015-09-23 12:09:25 -07:00
Yusef Napora 2f9bd1f62f App Extension support
Summary: This adds workarounds for the code that was preventing React from compiling when linked against an iOS App Extension target.

Some iOS APIs are unavailable to App Extensions, and Xcode's static analysis will catch attempts to use methods that have been flagged as unavailable.

React currently uses two APIs that are off limits to extensions: `[UIApplication sharedApplication]` and `[UIAlertView initWith ...]`.

This commit adds a helper function to `RCTUtils.[hm]` called `RCTRunningInAppExtension()`, which returns `YES` if, at runtime, it can be determined that we're running in an app extension (by checking whether the path to `[NSBundle mainBundle]` has the `"appex"` path extension).

It also adds a `RCTSharedApplication()` function, which will return `nil` if running in an App Extension. If running in an App, `RCTSharedApplication()` calls `sharedApplication` by calling `performSelector:` on the `UIApplication` class.  This passes the static analysis check, and, in my opinion, obeys the "spirit of th
Closes https://github.com/facebook/react-native/pull/1895

Reviewed By: @​svcscm

Differential Revision: D2224128

Pulled By: @nicklockwood
2015-09-22 10:46:26 -07:00
Marc Horowitz a87ba4ab4c Prepare the bridge for C++
Reviewed By: @nicklockwood

Differential Revision: D2432291
2015-09-18 15:04:28 -07:00
Alexsander Akers 9a2d05d9b2 Move color processing to JS
Reviewed By: @vjeux

Differential Revision: D2346353
2015-09-17 17:20:45 -07:00
Param Aggarwal b998e5a7b7 Use getters and setters
Summary: As per discussion in #2423 - possible fix for crash. (cc: @​javache)

Please share feedback regarding the PR, we are going to be using this diff in production to see if it fixes the crashes we are seeing.

(fixes #2423)
Closes https://github.com/facebook/react-native/pull/2494

Reviewed By: @javache

Differential Revision: D2433515

Pulled By: @nicklockwood
2015-09-13 11:10:29 -07:00
Nick Lockwood 789a07c5a4 Added code to sync __DEV__ value to RCT_DEBUG
Summary: @​public

When using bundled JS the `__DEV__` flag is set to false by default, which can cause errors to be missed if used for testing. This diff adds logic to override the `__DEV__` value when running in RCT_DEBUG configuration, so that the JS debug checks are enabled.

Reviewed By: @tadeuzagallo

Differential Revision: D2429533
2015-09-11 07:15:27 -07:00
Tadeu Zagallo 20cd649553 Automatically save and convert JavaScript profile to chrome format
Summary: @​public

Migrate scripts to open source and add new route on the packager
to directly convert profiler outputs to a devtools compatible format.

Reviewed By: @jspahrsummers

Differential Revision: D2425740
2015-09-11 06:40:26 -07:00
James Ide 3f4c7e40c6 [Bridge] Consistently post "DidFailToLoad" notification when there's an error
Summary:
Previously the bridge sometimes never fired RCTJavaScriptDidLoadNotification or RCTJavaScriptDidFailToLoadNotification if there was an error (for example, if the source code loaded but we couldn't inject the JSON config). This diff moves the error handling into a method called `stopLoadingWithError` that the bridge can call whenever there is an error.

Also if the script failed to load, the BatchedBridge still called `executeSourceCode`. With this diff the `_loading` flag is set to NO when the script fails to load, and `executeSourceCode` returns immediately when `_loading` is false. This way the bridge does not try to execute JS when there is a loading error.
Closes https://github.com/facebook/react-native/pull/2520
Github Author: James Ide <ide@jameside.com>
2015-09-04 03:28:51 -08:00
Pieter De Baets 9b1f6c9e30 Make RCTTestRunner wait for JS context to deallocate 2015-09-04 03:24:16 -08:00
Nick Lockwood e0505fe43e Added missing init override to RCTRootView 2015-09-03 13:10:06 -08:00
Alex Akers e092c61bac Add KeyboardAvoidingView 2015-09-02 09:17:20 -08:00
futbalguy 3bef953f77 Added clarifying language to error for not finding development server
Summary:
Added additional check to make if seeing error message on not finding development server:
Node server URL is correctly set in AppDelegate.

Should make it easier for a developer that is not running on localhost for the first time.

Screenshot of updated error message:
![img_0015 1](https://cloud.githubusercontent.com/assets/7111607/9553286/d7081c30-4d72-11e5-8c24-e3e5c83281d0.PNG)

Closes https://github.com/facebook/react-native/pull/2484
Github Author: futbalguy <kyle.rokita@gmail.com>
2015-09-01 05:25:56 -08:00
Ted Suzman 2b3a4bd27d [ReactNative] Maintain order of bridge calls
Summary:
When bridge calls are made, they should be dispatched to their
destination GCD queue in the same order they were made. (It
looks like this invariant broke in 336e18d, which caused call
order to depend on the iteration of `NSMapTable` keys
whenever there are calls to multiple modules that share a queue)

Fixes #1941 (in which RCTUIManager createView addUIBlock
blocks were sometimes running after other blocks that depended
on them)

I'm a react-native/iOS/objc newbie, so please excuse any
ignorance this commit may well contain :)
Closes https://github.com/facebook/react-native/pull/2488
Github Author: Ted Suzman <ted@suzman.net>
2015-09-01 02:19:42 -08:00
Nick Lockwood 7bf157c92c Fix assertion when modules are accessed early on in bridge startup 2015-08-26 10:01:29 -08:00
Pieter De Baets 371aeceb72 Small perf improvement to RCTPerfStats and RCTBridgeModuleNameForClass 2015-08-25 04:48:39 -08:00
Alex Akers 9aefd6bd6e Add keyboard-observing notifications 2015-08-25 03:49:13 -08:00
Nick Lockwood 88e0bbc469 Ran Convert > To Modern Objective C Syntax 2015-08-25 01:08:49 -08:00
Pieter De Baets eab390aecb Cleanup bridge init, measure native module init time 2015-08-21 12:32:25 -07:00
Alex Kotliarskyi 8d07df4a22 [ReactNative] Unbreak debugger 2015-08-21 11:20:17 -07:00
Nick Lockwood 2cd02d94ff Converted RCTRedBox to a bridge module 2015-08-21 02:53:55 -07:00
Harrison Harnisch 46c6cde947 UI CPU and memory utilization graphs in Chrome debugging mode
Summary:
Chrome debugging UI is currently only showing connection state and logs in the console, leaving room for plenty of interesting information.

I've pushed the UI (using the same convention set by FPS -- UI/JS) CPU and memory utilization data over the debug Websocket and tapped into the existing stream of JS calls that get ran in V8.

The number of JS calls in a time interval is counted for all sub calls in a batch
https://github.com/hharnisc/react-native/blob/master/packager/debugger.html#L150

The last 5 batches of JS calls are displayed in a list format.

<img width="951" alt="screen shot 2015-07-19 at 7 34 00 pm" src="https://cloud.githubusercontent.com/assets/1388079/8769257/edc42f70-2e4d-11e5-8813-e86ef530a446.png">

Charts are created with [Chart.JS](https://github.com/nnnick/Chart.js) (MIT licensed).
Closes https://github.com/facebook/react-native/pull/2050
Github Author: Harrison Harnisch <hharnisc@gmail.com>
2015-08-21 02:11:45 -07:00
Christopher Chedeau 1ca1a44a07 [Logs] Remove already registered warning 2015-08-20 09:46:10 -07:00
Tadeu Zagallo 81fdf3e532 [ReactNative] Change RCTProfile API to be compatible with systrace 2015-08-20 00:47:23 -07:00
Jing Chen cc96962e3d [react-native] Revert D2346396 to bring back JS stack traces 2015-08-19 18:07:15 -07:00
Alex Kotliarskyi c5c25c15ea [RN] Show only file name in RedBox 2015-08-19 17:35:25 -07:00
Nick Lockwood 76a9baaf2f Fixed bug where method calls containing struct arguments would fail silently
Summary:
The arg block for handling structs did not return a value, which was being intepreted as failure. This diff returns YES for success, and also adds an error log for this case so future regressions won't fail silently.
2015-08-18 07:35:26 -07:00
Nick Lockwood 8d1e02b8bd Convert alloc/init to new to please linter 2015-08-17 08:46:00 -07:00
Pieter De Baets 261f9434e5 Avoid dispatch_async in RCTRootView when bridge has already started
Summary:
There's no good reason for initialProperties to be mutable after the RCTRootView has been created. Passing it in through the constructor means we can skip one dispatch_async.
2015-08-17 05:34:25 -07:00
Nick Lockwood decf35c271 Fixed log prefixes to provide more context for prop binding errors 2015-08-14 08:01:34 -08:00
Alexsander Akers 96277ca3f5 Add HSL/HSLA support 2015-08-14 04:48:20 -08:00
Pieter De Baets fa07736ee1 Remove isValid from RCTInvalidating
Summary:
We only actually use it on RCTBridge and RCTJavaScriptExecutor, so add it to these interfaces explicitly
2015-08-14 01:57:18 -08:00
Nick Lockwood 0487c55c25 Removed unnecessary overhead in RCTConvert functions 2015-08-13 04:08:17 -08:00
Nick Lockwood 1d072076db Reduce +[UIImage imageNamed:] overhead 2015-08-13 03:33:04 -08:00
Nick Lockwood a86e6b76fb Fixed fuzzer app and ensured that React does not crash when fuzzed 2015-08-12 06:14:36 -08:00
Nick Lockwood a5e9f83a0a Implemented lazy parsing of method signatures to improve TTI 2015-08-11 08:49:13 -08:00
Tadeu Zagallo e2d9ddce4c [ReactNative] Fix cast warning in RCTProfile
Summary:
Buck is more strict than our current xcodeproj configuration is keeps warning
about this implicit cast, it's quite annoying.
2015-08-11 06:49:39 -08:00
Nick Lockwood 48af214216 Simplified event registration
Summary:
Our events all follow a common pattern, so there's no good reason why the configuration should be so verbose. This diff eliminates that redundancy, and gives us the freedom to simplify the underlying mechanism in future without further churning the call sites.
2015-08-11 06:41:04 -08:00
Nick Lockwood b489c9aa43 Fixed perf issue due to use of regex in +[RCTConvert NSURL:] 2015-08-10 07:13:36 -08:00
Nick Lockwood 94caefa9c2 Converted RCTDevLoadingView to a module and fixed url display when using delegate 2015-08-08 03:31:49 -08:00
Nick Lockwood b82ac9bf07 Reverted to pre-init of queues to fix UIExplorer tests. 2015-08-08 01:47:43 -08:00
Tadeu Zagallo 331e4a96e9 [ReactNative] Preload ModuleData queue
Summary:
The module's methodQueue wasn't being created when accessing the modules directly
on the bridge, without going through JS. Preload the queue for now to fix internal
breakages, but I'll figure out a better way to keep it lazy afterwards.
2015-08-07 11:05:09 -08:00
Ben Alpert 2d66e10ec4 [ReactNative] Delay sending touches to JS until dependent (native) gesture recognizers fail
Summary:
Previously, JS touches were being interpreted simultaneously with native gesture recognizers.
2015-08-07 10:56:26 -08:00
Tadeu Zagallo 6cd0709bc0 [ReactNative] Parellelise bridge startup
Summary:
Parallelise the bridge startup so we don't keep waiting for the source to load.
2015-08-07 06:48:30 -08:00
Nick Lockwood 3cef3010e6 Fix RCTAssert logic 2015-08-07 06:11:49 -08:00
Tj c933087567 CMD+R should post a refresh notification.
Summary:
For the sake of consistency, `cmd+r` should just post a refresh notification. This way other tools can also observe and react to the refresh without ugly hacks.
Closes https://github.com/facebook/react-native/pull/2175
Github Author: Tj <tfallon@mail.depaul.edu>
2015-08-07 04:39:21 -08:00
Nick Lockwood deba13f698 Refactor RCTUIManager
Summary:
Moved the view creation & property binding logic out of RCTUIManager into a separate RCTComponentData class - this follows the pattern used with the bridge.

I've also updated the property  binding to use pre-allocated blocks for setting the values, which is more efficient than the previous system that re-contructed the selectors each time it was called. This should improve view update performance significantly.
2015-08-06 15:49:35 -08:00
Nick Lockwood f165bbaf4e Use +[RCTConvert NSURL:] everywhere instead of +[NSURL URLWithString:]
Summary:
RCTConvert's URL: method gracefully handles unescaped urls, local file urls, urls containing unicode, etc. URLWithString doesn't.
2015-08-04 16:26:16 -08:00
Nick Lockwood 6a4b83c16f Fixed retain cycle that caused RCTModuleMethods to leak
Summary:
Some of the log statements inside argument blocks in RCTModuleMethod were directly accessing ivars, thereby causing a retain cycle that retained the class. I've fixed this by making the access explicit via weakSelf.
2015-08-03 08:46:52 -08:00
=?UTF-8?q?=E9=9A=90=E9=A3=8E?= 44ce9194a2 Profiling will not work if the bundleURL has no port.
Summary:
If the bundleURL has no port(default 80) , the profile request URL will be `<scheme>://<host>:<null>/profile`, that will not work. So we should decide if the port exsits first.
Closes https://github.com/facebook/react-native/pull/2131
Github Author: =?UTF-8?q?=E9=9A=90=E9=A3=8E?= <yinfeng.fcx@alibaba-inc.com>
2015-08-03 07:51:33 -08:00
Nick Lockwood 1fb26d4319 Cleanup 2015-07-31 11:33:22 -08:00
Vladislav Alexeev 53fb5b6cee Dynamic Text Sizes for Text component
Summary:
Dynamic Text Sizes for Text component.
Text gains new prop - allowFontScaling (false by default).
There is also AccessibilityManager module that allows you to tune multipliers per each content size category.
2015-07-31 07:42:41 -08:00
Nick Lockwood 407eb4ce85 NSNumber arguments must now be nonnull
Summary:
The bridge implementation on React Android does not currently support boxed numeric/boolean types (the equivalent of NSNumber arguments on iOS), nor does Java support Objective-C's nil messaging system that transparently casts nil to zero, false, etc for primitive types.

To avoid platform incompatibilities, we now treat all primitive arguments as non-nullable rather than silently converting NSNull -> nil -> 0/false.

We also now enforce that NSNumber * objects must be explicitly marked as `nonnull` (this restriction may be lifted in future if/when Android supports boxed numbers).

Other object types are still assumed to be nullable unless specifically annotated with `nonnull`.
2015-07-31 06:57:08 -08:00
Tadeu Zagallo cf22111cee [ReactNative] Prevent RCTDevLoadingView from creating UIWindow on unit tests
Summary:
`RCTDevLoadingView` was being created from a constructor function and creating
a `UIWindow` when the bridge started loading. The `UIWindow` was crashing on
the unit tests since there's no host app.
2015-07-30 03:10:53 -08:00
Nick Lockwood 95b9dd3a88 Added support for method argument nullability
Summary:
This diff adds support for enforcing nullability in the arguments for exported methods.

We previously supported use of the nullable/nonnull attributes on method arguments, but didn't do anything to ensure that they were respected.

Now, if an argument is marked as nonnull, and a null value is sent for that argument, it will display a redbox.

In future, nonnull will be assumed by default, but for now we assume that un-annotated arguments can be null (to avoid breaking existing code).
2015-07-29 05:50:27 -08:00
Tadeu Zagallo 127f7095dc [ReactNative] Add RCTBridgeDelegate
Summary:
Add a new bridge delegate protocol to allow a more flexible bridge configuration.

For now it just support the pre-existent configurations + providing the JavaScript
source to the bridge, that should allow pre-loading sources.
2015-07-28 15:57:02 -08:00
Nick Lockwood b812b0ee2e Added unit tests for RCTModuleMethod parsing, and fixed some edge cases 2015-07-28 13:07:52 -08:00
Alex Kotliarskyi e964e741ef [RN] Add loading view for development mode
Summary:
It's very useful to know where the app is being loaded from and
can help debug various issues.
2015-07-28 11:17:06 -08:00
Alex Akers 7d19ff3dcb Add <Modal /> component
Summary:
Create Modal component that can be used to present content modally.
2015-07-28 07:21:50 -08:00
Tadeu Zagallo f53c95c743 [ReactNative] Proxy bundleURL on RCTBatchedBridge
Summary:
Fixes #2126

`RCTBatchedBridge` didn't implement `bundleURL`, that was available on the public
bridge interface, so it'd always be `nil`, and setting it would just be ignored.
2015-07-28 05:59:45 -08:00
Nick Lockwood 7996c32211 Unregistered modules will now only error when called, not on bridge init
Summary:
Occasionally people create RCTBridgeModule subclasses or base classes that are not intended to be accessed from JS, and so they don't export them. This was previously flagged as an error by the system. I've now downgraded this error to a warning at startup, and deferred the redbox error until the module is directly accessed by native or JS code.
2015-07-27 08:58:47 -08:00
Nick Lockwood f9abb5aae2 Fixed missing redbox at startup
Summary:
Fixed bug where redbox errors thrown during startup would be dismissed as soon as JS loaded, so they would never be seen.
2015-07-27 07:23:08 -08:00
Nick Lockwood aca76c75dd Fix gzip on iOS 9 2015-07-27 01:18:40 -08:00
Nick Lockwood 81dd9c27ea Optimized property setting and conversion 2015-07-24 09:37:28 -08:00
Tadeu Zagallo 4499f28c1d [ReactNative] Remove wrong lock from RCTProfile
Summary:
Remove sad lock from RCTProfileForwardInvocation that was locking concurrent
calls and messing with the profiler.
2015-07-24 09:14:46 -08:00
Nick Lockwood 9d19829742 Refactored networking logic out into RCTDownloadTask 2015-07-23 04:00:31 -08:00
Tadeu Zagallo 49b55804b1 [ReactNative] Fix crash when reload during profile (attempt #2)
Summary:
Fixes #1642

When reloading during profiling, the profile wouldn't unhook from the instance
being deallocated.
2015-07-22 11:02:32 -08:00
Spencer Ahrens 961c1eb429 [ReactNative] TextInput bug fixes and features
Summary:
This introduces event counts to make sure JS doesn't set out of date values on
native text inputs, which can cause dropped characters and can mess with
autocomplete, and obviates the need for the input buffering which added lag and
complexity to the component.  Made sure to test simulated super-slow JS text
event processing to make sure characters aren't dropped, as well as typing
obviously correctable words and making sure autocomplete works as expected.

TextInput is now a controlled input by default without causing any issues for
most cases, so I removed the `controlled` prop.

Fixes selection state jumping by restoring it after setting new text values, so
highlighting the middle of some text in the new ReWrite example and hitting
space will replace that selection with an underscore and keep the cursor at a
sensible position as expected, instead of jumping to the end.

Ads `maxLength` prop to support the most commonly needed syncronous behavior:
preventing the user from typing too many characters.  It can also be used to
prevent users from continuing to type after entering special characters by
changing it to the current length after a regex match.  Made sure to verify it
works well with pasted input (including in the middle of existing text),
truncating it and collapsing the selection the same way it does on the web.

Fixes bug in TextEventsExample where it wouldn't show the submit and end events,
even though there were firing correctly.
2015-07-21 12:45:07 -08:00
Philipp von Weitershausen 9c5fe3612d [React Native][iOS] XHR upload progress events 2015-07-20 22:48:55 -08:00
Nick Lockwood 5db42643cf Added JSONKit support
Summary:
React Native will now use JSONKit if it's already available in the project, otherwise it will fall back to using NSJSONSerialization as before. This provides a small performance boost to JSON parsing in some cases.
2015-07-20 09:52:31 -08:00
Tadeu Zagallo f2d65ea85b [ReactNative] Fix RCTJavaScriptContext deallocation (attempt #2)
Summary:
The context wasn't being explicitly released before, since it'd be immediately
released. Now that the executors are bridge modules, it was only being deallocated
when the modules were released, what caused the threads to not be released at all.
2015-07-20 02:40:05 -08:00
Eric Vicenti c4389c006f [ReactNative] Max RedBox windowLevel to always appear on top 2015-07-17 13:24:52 -08:00
DengYun 3c78aa6d25 [Bridge] remove unused semaphore
Summary:
dispatch_semaphore_wait with DISPATCH_TIME_NOW don't wait for the semaphore. It just test whether there's a signal and return the result.

So the line "dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW);" does nothing here. It seems like a bug, but each executing in js thread will be queued, so it's safe to remove the unused semaphore instead of wait for it.
Closes https://github.com/facebook/react-native/pull/1915
Github Author: DengYun <tdzl2003@gmail.com>
2015-07-17 10:01:26 -08:00
Nick Lockwood 82a774e92b Added unit tests for gzip functionality 2015-07-17 04:55:27 -08:00
Nick Lockwood 81ad713f5f Added Gzip support
Summary:
Added Gzip function to RCTUtils. This uses dlopen to load the zlib library at runtime so there's no need to link it into your project.

The main reason for this feature is to support gzipping of HTTP request bodies. Now, if you add 'Content-Encoding:gzip' to your request headers when using XMLHttpRequest, your request body will be automatically gzipped on the native side before sending.

(Note: Gzip decoding of *response* bodies is handled automatically by iOS, and was already available).
2015-07-16 09:38:20 -08:00
chirag04 04fa09afef [Style] added backface-visibility. fixes #1973
Summary:
default behavior remains same(backface visible).

cc @sahrens
Closes https://github.com/facebook/react-native/pull/1977
Github Author: chirag04 <jain_chirag04@yahoo.com>
2015-07-14 17:38:05 -08:00
Tadeu Zagallo d30ada61f0 [ReactNative] Remove unused executor context id
Summary:
Remove `RCTGetExecutorID` and `RCTSetExecutorID`, it wasn't used anymore since
the bridge was refactored into `RCTBridge` and `RCTBatchedBridge`.
2015-07-14 16:40:21 -08:00