Commit Graph

547 Commits

Author SHA1 Message Date
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