Commit Graph

164 Commits

Author SHA1 Message Date
Tadeu Zagallo 1c9e957d22 [ReactNative] Invalidate modules on their own queues
Summary:
@public

Bridge modules were being invalidate on the main thread, what could lead to
racing conditions, move the calls to invalidate on happen to the module's
methodQueue

Test Plan: Run the tests
2015-06-06 14:13:32 -08:00
Nick Lockwood 45d8fb0ef6 Removed deprecated RCT_EXPORT + code paths 2015-06-05 09:58:25 -08:00
Tadeu Zagallo 7009f0a47b [ReactNative] Add profiling hooks to bridge modules at runtime
Summary:
@public

Add `RCT_DEV`-only profiling hooks to every method in every bridge modules to
add a little bit more detail to the timeline profile.

Test Plan: {F22522834}
2015-06-05 04:22:57 -08:00
Tadeu Zagallo 158d8b64ff [ReactNative] Track bridge events' flow (timers fixed)
Summary:
@public

Use trace-viewer's flow events to link the bridge calls

Test Plan: {F22498582}
2015-06-03 05:37:10 -08:00
Chace Liang 4d4f2dfe09 Revert "[ReactNative] Track bridge events' flow" 2015-06-02 10:36:32 -08:00
Tadeu Zagallo 2dfa3b34a1 [ReactNative] Track bridge events' flow
Summary:
@public

Use trace-viewer's flow events to link the bridge calls

Test Plan: {F22498582}
2015-06-02 06:19:16 -08:00
John Harper 570597c4ac [react-native] dispatch perf updates to main thread 2015-06-02 01:44:55 -08:00
Chace Liang 1ed2542b46 Revert "[Bridge] Add support for JS async functions to RCT_EXPORT_METHOD" 2015-06-01 20:26:37 -08:00
James Ide d548c85da6 [Bridge] Add support for JS async functions to RCT_EXPORT_METHOD
Summary:
Adds support for JS async methods and helps guide people writing native modules w.r.t. the callbacks. With this diff, on the native side you write:

```objc
RCT_EXPORT_METHOD(getValueAsync:(NSString *)key
                       resolver:(RCTPromiseResolver)resolve
                       rejecter:(RCTPromiseRejecter)reject)
{
  NSError *error = nil;
  id value = [_nativeDataStore valueForKey:key error:&error];

  // "resolve" and "reject" are automatically defined blocks that take
  // any object (nil is OK) and an NSError, respectively
  if (!error) {
    resolve(value);
  } else {
    reject(error);
  }
}
```

On the JS side, you can write:

```js
var {DemoDataStore} = require('react-native').NativeModules;
DemoDataStore.getValueAsync('sample-key').then((value) => {
  console.log('Got:', value);
}, (error) => {
  console.error(error);
  // "error" is an Error object whose message is the NSError's description.
  // The NSError's code and domain are also set, and the native trace i
Closes https://github.com/facebook/react-native/pull/1232
Github Author: James Ide <ide@jameside.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-06-01 10:50:06 -08:00
Jason Prado 656c5e4e27 Revert "[ReactNative] Add completionBlock to -[RCTBridge enqueueJSCall:args:]"
Test plan: broke catalyst apps

Summary: This reverts commit 9fba6a360dc5f8bf.

fbobjc/Tools/revert

Reverter: jprado

@build-break

commit 9fba6a360dc5f8bf014f3d3c584c545b16da5100
Author:     Tadeu Zagallo <tadeuzagallo@fb.com>
AuthorDate: Thu May 28 08:29:19 2015 -0700
Commit:     Service User <svcscm@fb.com>
CommitDate: Thu May 28 09:53:53 2015 -0700

    [ReactNative] Add completionBlock to -[RCTBridge enqueueJSCall:args:]

    Summary:
    @public

    Allow to pass an optional completion block to the bridge JS calls.

    The block will be called from the JS thread, after the javascript has finished
    running and the returned calls have been processed/dispatched to the native modules.

    Test Plan: Added `testCallbackIsCalledOnTheRightTime` to `RKBatchedBridgeTests`
2015-05-28 09:30:51 -08:00
Tadeu Zagallo 3b24f52a20 [ReactNative] Add completionBlock to -[RCTBridge enqueueJSCall:args:]
Summary:
@public

Allow to pass an optional completion block to the bridge JS calls.

The block will be called from the JS thread, after the javascript has finished
running and the returned calls have been processed/dispatched to the native modules.

Test Plan: Added `testCallbackIsCalledOnTheRightTime` to `RKBatchedBridgeTests`
2015-05-28 08:53:53 -08:00
Tadeu Zagallo 4fc15dbf17 [ReactNative] Implement proper event coalescing 2015-05-27 20:41:20 -08:00
Tadeu Zagallo 08844e3ddc [ReactNative] Add fps monitor
Summary:
@public

Add basic JS and UI thread FPS monitor

Test Plan: Launch the UIExplorer, open the Dev Menu with cmd+D, and select `Show FPS Monitor`
2015-05-20 18:26:36 -08:00
Tadeu Zagallo a4e89d71a3 [ReactNative] Fix RCTBatchedBridge main thread invalidation
Summary:
D2052669 introduced a block for objects that had to be invalidated on the main
thread, but after the JS thread objects, but the block was being dispatched on
the JS thread.

@public

Test Plan:
I added `RCTAssertMainThread()` to the `mainThreadInvalidate` block, it was
crashing on reload, but now it should work as expected.
2015-05-17 18:27:20 -08:00
Christopher Chedeau 723e988416 [ReactNative] Redbox if JSC syntax errors 2015-05-15 15:33:17 -08:00
James Ide 2497c02e38 [RCTBridge] Have RCTBridge.loading return RCTBatchedBridge.loading
Summary:
The parent RCTBridge no longer tracks the JS loading since that has been handed off to the RCTBatchedBridge. To make the `loading` property accurate again, just expose the batch bridge's loading property from the parent bridge (note: I didn't make it KVO-compliant).

Fixes #1199
Closes https://github.com/facebook/react-native/pull/1200
Github Author: James Ide <ide@jameside.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-14 16:00:18 -08:00
James Ide f40a7b4609 [Bridge] Make RCTJavaScriptDidFailToLoadNotification match DidLoad notif
Summary:
Add the RCTBatchedBridge object to the notification's userInfo for consistency with RCTJavaScriptDidLoadNotification, and set the target object to `_parentBridge`.

cc @nicklockwood @tadeuzagallo
Closes https://github.com/facebook/react-native/pull/1243
Github Author: James Ide <ide@jameside.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-13 13:24:37 -07:00
James Ide ba9ef00ab9 [RCTBridge] Clean up reload notification observer
Summary:
After the RCTBatchedBridge refactor, the `-[NSNotificationCenter addObserver]` and `[removeObserver]` calls got divided between RCTBridge and RCTBatchedBridge. This diff does two things:

 - Moved `removeObserver` out of RTCBatchedBridge and into `-[RCTBridge invalidate]`
 - Moved `addObserver` from `bindKeys` to `setUp`. This is so that `-[RCTBridge reload]` will re-add the observer after invalidating and removing the observer

cc @tadeuzagallo
Closes https://github.com/facebook/react-native/pull/1212
Github Author: James Ide <ide@jameside.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-13 13:24:37 -07:00
Tadeu Zagallo d230629e61 [ReactNative] Add test to check RootContentView and BatchedBridge are deallocated 2015-05-13 13:24:36 -07:00
Tadeu Zagallo 92d7324f15 [ReactNative] Fix RootContentView release when the top-level bridge is held
Summary:
The RCTRootView creates a underlying RCTRootContentView that was deallocated when
the bridge modules were deallocated. That doesn't work when the bridge is held.

@public

Test Plan:
Launch Groups, put a breakpoint on `-[RCTRootContentView dealloc]`, enter and
leave a group page. It should be called now.
2015-05-13 13:24:36 -07:00
Tadeu Zagallo ec9015d005 [ReactNative] Disable event deduping 2015-05-07 19:49:03 -08:00
Tadeu Zagallo 6b38fad219 [ReactNative] Fix ref to eventDispatcher on RCTBridge 2015-05-07 09:05:29 -08:00
James Ide b8bf4d0957 [Loader] Post a notification when the JS fails to load
Summary:
This provides a way to get notified when a bridge fails to load JS, allowing apps to handle the error.

Closes https://github.com/facebook/react-native/pull/1085
Github Author: James Ide <ide@jameside.com>

Test Plan: run the UIExplorer app with the packager server not running, and verify that the notification is posted.
2015-05-07 04:26:24 -08:00
Nick Lockwood 205c22b915 Fixed dev menu loop 2015-05-07 03:55:43 -08:00
Nick Lockwood 47164baaec Fixed redbox error loop when camera access is disabled 2015-05-06 17:21:10 -08:00
Tadeu Zagallo 65a3da3003 [ReactNative] Fix chrome debugger 2015-05-05 05:36:05 -08:00
Tadeu Zagallo d713a711c4 [ReactNative] Fix packager assets 2015-05-05 02:54:51 -08:00
Tadeu Zagallo 132a9170f1 [ReactNative] Create private underlying bridge to prevent retain cycles 2015-05-04 10:36:20 -08:00
Nick Lockwood d29a0c6768 Fix for nil array crash 2015-05-02 18:40:04 -08:00
Tadeu Zagallo 09460cf21b [ReactNative] Use explicit doubles on RCTLocationOptions to avoid NSInvocation bug 2015-05-02 14:19:56 -08:00
Tadeu Zagallo 17262db5a9 [ReactNative] Fix JS calls being lost 2015-05-02 13:14:19 -08:00
Nick Lockwood ba501a1bf5 Upgraded dev menu 2015-05-01 06:36:49 -08:00
Nick Lockwood eb0476074f Improved debug and fixed macros 2015-04-30 09:59:16 -08:00
Tadeu Zagallo 2f4430cf51 [ReactNative] Fix bridge event dedupe 2015-04-28 07:58:35 -08:00
Nick Lockwood bc24be8584 Fixed nil object insertion crash due to incorrectly encoded HTTP response body data 2015-04-28 04:48:32 -08:00
Tadeu Zagallo 136431cc2f [ReactNative] Fix struct args on exported methods 2015-04-27 04:01:37 -08:00
Tadeu Zagallo dd6bce78e1 [ReactNative] Allow bridge modules to run on the JavaScript thread 2015-04-25 19:29:00 -08:00
Nick Lockwood fc6e209223 Fixed broken struct arguments 2015-04-22 13:25:53 -08:00
Tadeu Zagallo 3595b79ec3 [ReactNative] Move VSync bound events to JS thread 2015-04-22 07:01:48 -08:00
Nick Lockwood ee898c24c7 Removed debug code from release builds 2015-04-21 09:47:21 -08:00
Nick Lockwood 8e15a0d5e7 Added RCT_DEBUG 2015-04-21 05:24:10 -08:00
Nick Lockwood 5ce9fa4dda Changed default method queue to a background queue. 2015-04-20 12:02:04 -08:00
Tadeu Zagallo fb1fa12e89 [ReactNative] Better profiling API + Fix overlaping events 2015-04-20 04:57:28 -08:00
Tadeu Zagallo 0e67e33534 [ReactNative] Ensure JS calls scheduled by a deallocated context don't fire 2015-04-20 02:03:22 -08:00
Nick Lockwood ead0f2e020 Implemented thread control for exported methods 2015-04-18 11:13:39 -08:00
Tadeu Zagallo 1883ba535c [ReactNative] Send batched calls from objc to js every frame + add bridge profiling 2015-04-17 04:01:02 -08:00
Tadeu Zagallo 75e4e124fa [ReactNative] Use a single DisplayLink held by the bridge 2015-04-15 07:07:48 -08:00
James Ide e193a13ef7 [Bridge] `RCT_REMAP_METHOD(js_name, selector)`
Summary:
cc @a2 @nicklockwood

This diff introduces a new macro called `RCT_EXPORT_NAMED_METHOD`, which is like `RCT_EXPORT_METHOD` but lets you choose the name of the method in JS. This diff is backwards compatible with the `RCT_EXPORT_METHOD` and legacy `RCT_EXPORT` macros.

The entries in the data segment now contain `__func__`, the Obj-C selector signature, and the JS name. If the JS name is `NULL`, we take the legacy `RCT_EXPORT` code path. If the JS name is an empty string, we use the Obj-C selector's name up to the first colon (that is, the behavior of `RCT_EXPORT_METHOD`).

Since there are three values in each data segment entry, the macros now specify 1-byte alignment. Without the byte alignment, the compiler defaults to 2-byte alignment meaning that each entry takes up 4 bytes instead of 3. The extra byte isn't a concern but being explicit about the alignment should reduce compiler surprises.
Closes https://github.com/facebook/react-native/pull/802
Github Author: James Ide <ide@jameside.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-04-14 12:55:19 -08:00
Nick Lockwood 26fd24dc50 Cleanup 2015-04-11 14:19:49 -08:00
Tadeu Zagallo f5f80da80c [ReactNative] Remove bridge retaining cycles 2015-04-10 07:20:37 -08:00
Bryce Redd c29c595126 Added random js queue+execution time sampling in react native 2015-04-09 17:04:26 -08:00
Alex Kotliarskyi bbddd0262d [ReactNative] Bring back crash reporting 2015-04-09 10:44:26 -08:00
Alex Akers 8a57c4e980 [React Native] RCT_EXPORT lvl.2 2015-04-08 08:34:10 -08:00
Nick Lockwood bf4868edda Added non-class-scanning-based approach fror registering js methods 2015-04-08 05:45:20 -08:00
Spencer Ahrens a1ec752019 [ReactNative] Do flow check when running packager 2015-04-07 21:40:05 -08:00
Ben Hiller 220e116dce [fbobjc] revert rFBOBJCdba3daf9a595f452d069f2a74a9a11f251999b2e 2015-04-07 20:44:11 -08:00
Tadeu Zagallo 6854da9b86 [ReactNative] Remove bridge retaining cycles 2015-04-07 19:42:46 -08:00
Tadeu Zagallo 72390239be [ReactNative] Fix and re-add WebView executor 2015-04-07 18:25:38 -08:00
Nick Lockwood 80cd687e95 Refactored RCTLog and added facility to prepend extra data to the log message 2015-04-07 07:35:57 -08:00
Christopher Chedeau df851b38fc [ReactNative] Workaround double cmd+r bug 2015-04-02 16:44:04 -08:00
Tadeu Zagallo 5be7fae286 [ReactNative] Allow recover from debugger error 2015-04-02 13:43:09 -08:00
Tadeu Zagallo f370f9cbc4 [ReactNative] Unfork RKRootView 2015-04-02 07:12:42 -08:00
Alex Akers 7a97043a3e [React Kit] Remove embarrassing TODOs 2015-03-26 10:33:05 -08:00
Tadeu Zagallo 20291a02df [ReactNative] s/ReactKit/React/g 2015-03-26 02:42:24 -08:00