Summary:
@public
When the profile is initialized, it automatically hooks into every method of
the bridge modules, that was causing `+initialize` to be called twice.
Also add a popup to notify the user that the profile has been created.
Test Plan:
Run the UIExplorer, start the profiler, try to rage shake to open the dev menu
again. It should now work, and show an alertview with some information once the
profile is stopped.
Summary:
Live reload is disabled when an error has occurred. This requires the developer to fix the error and then switch to the simulator to reload the device manually; impacting developer flow and increasing alt tabbing. This pull request fixes that by allowing live reload to work even on errors.
This fixes issue: #1343.
Closes https://github.com/facebook/react-native/pull/1549
Github Author: Ruben Niculcea <ruben.niculcea@gmail.com>
Test Plan: Imported from GitHub, without a `Test Plan:` line.
Summary:
@public
That was eventually being released before all the queues had been cleared.
Update it so the each modules' queue is immediately invalidated after sending
the `-invalidate` message to it, and introduce an intentional retain cycle so
the bridge is only released together with all modules, when all the messages
have been dispatched.
Test Plan: Launch the UIExplorer, and reload it, like, a lot.
Summary:
@public
Add PerformanceLogger to keep track of JS download, initial script execution and
full TTI.
Test Plan:
The Native side currently calls `addTimespans` when it's finish initializing
with the six values (start and end for the three events), so I just checked it
with a `PerformanceLogger.logTimespans()` at the end of the function.
```
2015-06-18 16:47:19.096 [info][tid:com.facebook.React.JavaScript] "ScriptDownload: 48ms"
2015-06-18 16:47:19.096 [info][tid:com.facebook.React.JavaScript] "ScriptExecution: 106ms"
2015-06-18 16:47:19.096 [info][tid:com.facebook.React.JavaScript] "TTI: 293ms"
```
Summary:
@public
I was using UIKeyCommand as a key in a dictionary, but it seems iOS wasn't treating identical commands as equal, so it was possible to register the same key command twice, resulting in the command triggering the action multiple times.
I've now created a container object for the key commands, and not relying on undocumented hashing behavior of UIKeyCommand for deduplication any more.
Test Plan: Reload bridge multiple times, then check that the number of registered keys in the command set inside RCTKeyCommands doesn't keep increasing.
Summary:
@public
There was an iVar being directly referenced from inside a block on RCTDevMenu
that was causing a retain cycle and the dev menu wasn't being released.
Test Plan: Put a break point on dealloc, it should be called now.
Summary:
@public
Add marker to show JavaScript download duration + flow arrows to show the origin
of the UI blocks being flushed.
Also fixed the condition on `RCTPerfStats`, UI and JS graphs were being created
at startup time, now they're just created on the first time they're shown.
Test Plan:
The markers:
{F22577660}
To check the FPS graph, enable it on the DevMenu, and it should appear initially
empty, instead of previously filled as before.
Summary:
@public
The current implementation of `MessageQueue` is huge, over-complicated and spread
across `MethodQueue`, `MethodQueueMixin`, `BatchedBridge` and `BatchedBridgeFactory`
Refactored in a simpler way, were it's just a `MessageQueue` class and `BatchedBridge`
is only an instance of it.
Test Plan:
I had to make some updates to the tests, but no real update to the native side.
There's also tests covering the `remoteAsync` methods, and more integration tests for UIExplorer.
Verified whats being used by Android, and it should be safe, also tests Android tests have been pretty reliable.
Manually testing: Create a big hierarchy, like `<ListView>` example. Use the `TimerMixin` example to generate multiple calls.
Test the failure callback on the `Geolocation` example.
All the calls go through this entry point, so it's hard to miss if it's broken.
Summary:
@public
Add missing `RCT_EXTERN` to the constants in `RCTProfile`'s header
Test Plan:
Move the the import on `RCTBridge` to the header, build no longer fails due to
duplicate symbols.
Summary:
@public
This removes the last piece of data that was still stored on the DATA section,
`RCT_IMPORT_METHOD`. JS calls now dynamically populate a lookup table simultaneously
on JS and Native, instead of creating a mapping at load time.
Test Plan: Everything still runs, tests are green.
Summary:
@public
I've increased the warning levels in the OSS frameworks, which caught a bunch of minor issues. I also fixed some new errors in Xcode 7 relating to designated initializers and TLS security.
Test Plan:
* Test the sample apps and make sure they still work.
* Run tests.
Summary:
@public
Include `js_name` and `__LINE__` on exported methods' generated names + use the
method implementation instead of `objc_msgSend` on the bridge, so it still works
in case of clashing.
Test Plan: Everything still working, otherwise it'd crash at startup.
Summary:
@public
Include stack traces in native redboxes (e.g. from RCTLogError). It's not trivial to get the file names and line numbers for every frame of the stack, but we can get the first one which is nice.
Test Plan: {F22548418}
Summary:
@public
This probably needs more thought - might want to differentiate between console.error and reportError.
Test Plan: console.error and reportError no longer redbox. invariant and RCTLogError still do.
Summary:
@public
The information we required about the exported methods were previously stored
on the binary's DATA section, which didn't allow to access methods on different
static libraries, or in any dynamic library at all. Instead of fetching information
from all the DATA segments, this diff changes the macro in order to create a
new method, that returns the required information about the original method. The
module itself is registered at load time, and on the bridge initialization all
the auto-generated methods are called to gather the methods' information.
Test Plan:
UIExplorer previously had a dependency on `RCTTest`, because it had a `TestModule`
that had to be on the same library. `RCTTest` is now a dependency of
`UIExplorerIntegrationTests`. So the tests themselves running should test it.
Summary:
@public
This is the first of a few diffs that change the way the executors are handled
by the bridge.
For they are just promoted to modules, so they are automatically loaded by the bridge.
Test Plan:
Tested on UIExplorer, Catalyst and MAdMan.
Tested all the 3 executors, everything looks fine.
Summary:
@public
There have been multiple instances of confusion about whether a redbox means the
developer did something they shouldn't but things will keep working, or if
something went horribly wrong and the app will crash in prod. This diff
introduces an orange background color to the redbox for `console.error` and
`RCTLogError` to indicate that something bad happened, but that the app will
continue working.
Test Plan:
see orange error for geo permissions:
{F22541375}
Summary:
@public
`[Bridge] Add support for JS async functions to RCT_EXPORT_METHOD` was imported but broke some internal code, reverting the `MessageQueue` that caused the issues and add a test, since the method is not used yet.
Test Plan: Run the test o/
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.
Summary:
@public
This is a refactor of @philikon's original diff that decouples the dependencies between the Network and Image modules, and replaces RCTDataQueryExecutor with a more useful abstraction.
I've introduced the RCTURLRequestHandler protocol, which is a new type of bridge module used for loading data using an NSURLRequest. RCTURLRequestHandlers can be registered using RCT_EXPORT_MODULE() and are then available at runtime for use by the RCTDataManager, which will automatically select the appropriate handler for a given request based on the handler's self-reported capabilities.
The currently implemented handlers are:
- RCTHTTPRequestHandler - the standard open source HTTP request handler that uses NSURLSession
- RKHTTPRequestHandler - the internal FB HTTP request handler that uses FBNetworking
- RCTImageRequestHandler - a handler for loading local images from the iOS asset-library
Depends on D2108193
Test Plan:
- Internal apps still work
- OSS port still compiles, Movies app and a sample Parse app still work
- uploading image to Parse using the above code snippet works
- tested `FormData` with string and image parameters using http://www.posttestserver.com/
Summary:
@public
For every call that comes from JS to Native we'd call dispatch_async so the
method would be cllead on the queue/thread it's expecting. This diff
buckets the calls by target queue, dispatches only once to that queue, and then
call all the methods for it inside the same dispatch.
Test Plan: {F22510090}
Summary:
@public
`RCTDispatchEvent` and `RCTTiming` weren't being paused when there wasn't any
work left to be done.
Test Plan:
Run the timers example - check everything still works as expected
Test the ListView paging example - check scroll events are still fired as expected
Launch UIExplorer, let it idle, and put a break point on `-[RCTBridge dispatchBlock:moduleID:]`,
it should never fire.
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
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}
Summary:
This bug was causing a redbox when touching rapidly because multiple touches had the same identifier. This code was meant to ensure that a unique ID is found, but it was checking against the wrong property in the react touch array.
I don't think this was really affecting prod, because the invariant is guarded by a __DEV__ check
@public
Test Plan:
- Start several touches at once (or just rapidly jam fingers on your device), and you won't see a redbox
- Also verify that single touches, touch moves, and multi touches work as before
Summary:
The idea behind this change it to couple together menu item title
and handler. The code becomes simpler and easier to maintain, but
also makes it possible to extend dev menu in the future.
@public
Test Plan:
All menu items works as before.
Changed websocket executor class name and made sure that when the class
is missing we get nice error message.
Summary:
These two arrays aren't used. The code is easier to read without them
@public
Test Plan: Tap around UIExplorer and verify multi-touch and responder system behavior works the same
Summary:
@public
Right now the profiler shows how long the executor took on JS but doesn't show
how long each of the batched calls took, this adds a *very* high level view of JS
execution (still doesn't show properly calls dispatched with setImmediate)
Also added a global property on JS to avoid trips to Native when profiling is
disabled.
Test Plan:
Run the Profiler on any app
{F22491690}
Summary:
@public
On D2099270 event coalescing was implemented and the event key on the RCTSparseArray
is an uint64_t, but it was declared as NSUInteger. On a 32 bits architecture
it'll be clipped to 4 bits, meaning that just `reactTag` will be taken into
account, e.g. different types of events can coalesce with each other if they target the same view
Switching to use an NSMutableDictionary instead of RCTSparseArray and NSNumber
as keys instead of uint64_t
Test Plan: Fixed the previous tests and added a new test to RCTEventDispatcherTests
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.
Summary:
@public
This fixes an issue with the containerBackgroundColor property of `<Text>` nodes, where containerBackgroundColor was being overridden by the backgroundColor. I also fixed up the example so that it demonstrates the feature more clearly.
Test Plan:
* Check UIExplorer text example
* Run Catalyst snapshot tests and check MAdMan, Groups
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`
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`
Summary:
This adds new development feature to React Native that provides information
about selected element (see the demo in Test Plan).
This is how it works:
App's root component is rendered to a container that also has a hidden layer called
`<InspectorOverlay/>`. When activated, it shows full screen view and captures all
touches. On every touch we ask UIManager to find a view for given {x,y} coordinates.
Then, we use React's internals to find corresponding React component. `setRootInstance`
is used to remember the top level component to start search from, lmk if you have a
better idea how to do this. Given a component, we can climb up its owners tree
to provice more context on how/where the component is used.
In future we could use the `hierarchy` array to inspect and print their props/state.
Known bugs and limitations:
* InspectorOverlay sometimes receives touches with incorrect coordinates (wtf)
* Not integrated with React Chrome Devtools (maybe in followup diffs)
* Doesn't work with popovers (maybe put the element inspector into an `<Overlay/>`?)
@public
Test Plan:
https://www.facebook.com/pxlcld/mn5k
Works nicely with scrollviews
Summary:
@public
Add `RCTAssertThread` to `RCTAssert.h` for convenience when checking the current/queue,
it accepts either a `NSString *`, `NSThread *` or `dispatch_queue_t` as the object to be checked
Also add a check to `-[RCTUIManager addUIBlock:]` - There was a discussion on github (https://github.com/facebook/react-native/issues/1365)
due to the weird behavior caused by calling it from a different thread/queue (it might be added after `batchDidComplete` has been called
and will just be dispatched on the next call from JS to objc)
Test Plan:
Change `-[RCTAnimationExperimentalManager methodQueue]` to return `dispatch_get_main_queue()` and run the 2048 example,
it should dispatch with a helpful message (screenshot on the comments)
Summary:
@public
Our background color propagation mechanism is designed to make rendering of translucent content more efficient by pre-blending against an opaque background. Currently this only works for text however, because images are not composited into their background even if the background color is opaque.
This diff precomposites network images with their background color when the background is opaque, allowing them to take advantage of this performance optimization.
I've also added some logic to correctly crop the downloaded image when the resizeMode is "cover" or "contain" - previously it was only correct for "stretch".
Before:{F22437859}
After:{F22437862}
Test Plan: Run the UIExplorer "<ListView> - Paging" example with "color blended layers" enabled and observe that the images appear in green now, instead of red as they did before.
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.
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.
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.
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.
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.
Summary:
Apparently British spelling is "cancelled", American is "canceled"? Picking "cancelled" for consistency with UIKit.
@public
Test Plan: landcastle
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.
Summary:
When touches end or cancel, update self.state in
RCTTouchHandler to let iOS know that we are in an ended/canceled state.
This way we won't eat other touches because it still thinks we're in a
began/changed state.
@public
Test Plan:
Scrolling in the back swipe area no longer busts gesture
recognition in Wilde.
Summary:
@nicklockwood - Could I get a review of this?
Just took `RCTTextField` and ported it from `UITextField` to `UITextView` as you mentioned in another discussion, and removed any `UITextField` specific attributes.
- How do you think this should behave when there are subviews?
- Do you know how we can respond to the `UIControlEventEditingDidEndOnExit` event to respond to submit? Because `UITextView` isn't a `UIControl` we can't just use `addTarget` with `UIControlEventEditingDidEndOnExit`.
- Any other feedback?
Still going to look over the `UITextView` docs in more detail and make sure we expose all important options, and add it to the UIExplorer example, just putting this out here for feedback.
![multiline](https://cloud.githubusercontent.com/assets/90494/7310854/32174d6a-e9e8-11e4-919e-71e54cf3c739.gif)
Closes https://github.com/facebook/react-native/pull/991
Github Author: Brent Vatne <brent.vatne@madriska.com>
Test Plan: Imported from GitHub, without a `Test Plan:` line.
Summary:
External modules are any Objective-C class in which the implementation is private. This currently will be most useful for Swift classes but also has potential to allow exposing methods on 3rd party libraries to the bridge.
Closes https://github.com/facebook/react-native/pull/982
Github Author: Robert Payne <robertpayne@me.com>
Test Plan: Imported from GitHub, without a `Test Plan:` line.
Summary:
The root view's content was being rendered at the wrong offset when it was not positioned at (0, 0) exactly, because the shadow view's frame was set to the root view's frame when it should have been set to the root view's bounds instead.
Closes https://github.com/facebook/react-native/pull/963
Github Author: James Ide <ide@jameside.com>
Test Plan: Render a root view positioned at (0, 100) and see that its content is positioned where the root view is, not at (0, 200).
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.
Summary:
If we make a request that contains a pipe character, URLWithString will return null. This fix escapes these and other characters before creating the NSURL.
Closes https://github.com/facebook/react-native/pull/786
Github Author: Blair Vanderhoof <blairv@gmail.com>
Test Plan: Imported from GitHub, without a `Test Plan:` line.
- Implemented response headers when using `XMLHttpRequest` | Nick Lockwood
- [ReactNative] Don't redbox on flow config errors | Spencer Ahrens
- [ReactNative] Fix suggestions in TextInput when setting value prop | Spencer Ahrens
- Link LinkingIOS in SampleApp | Nick Lockwood
- unify use of password and secureTextEntry for TextInput | Nick Lockwood
- Added random js queue+execution time sampling in react native | Bryce Redd
- [react_native] JS files from D1980312: [react_native] Fix webview | Andrei Coman
- [react-packager] Correct module extension regexp | Amjad Masad
- [react-packager] Implement the browser field package.json spec | Amjad Masad
- [ReactNative] Bring back crash reporting | Alex Kotliarskyi
- Remove duplicate word | Nick Lockwood
- NavigatorIOS navigationBarHidden property support | Nick Lockwood
- [Scroll] Include content insets in scroll events | Nick Lockwood
Summary:
I think perhaps these were left out by mistake?
Closes https://github.com/facebook/react-native/pull/382
Github Author: Mike Driver <mikedriver@gmail.com>
Test Plan: Imported from GitHub, without a `Test Plan:` line.
Summary:
When calculating how far the user has scrolled, it is necessary to know the content insets where:
number of pixels scrolled = content offset + leading content inset for the scroll axis
This diff adds the contentInset field to native scroll events.
Closes https://github.com/facebook/react-native/pull/737
Github Author: James Ide <ide@jameside.com>
Test Plan: Imported from GitHub, without a `Test Plan:` line.
- [React Native] Fix RCTText crashes | Alex Akers
- Ensure that NSLocationWhenInUseUsageDescription is set, throw error if not | Alex Kotliarskyi
- [ReactNative] fix exception handler method name | Spencer Ahrens
- [ReactNative] Re-configure horizontal swipe animations | Eric Vicenti
- [ReactNative] <Text>: apply the fontWeight correctly if fontFamily style is also present | Kevin Gozali
- [MAdMan] Dimensions.get('window') considered harmful | Philipp von Weitershausen
- Navigator: Changed transitioner background color to 'transparent' | Eric Vicenti
- [react-native] Listen on all IPv6 interfaces | Ben Alpert
- [react-packager] Don't depend on error.stack being available | Amjad Masad
- [ReactNative] fixup AnimationExperimental a bit | Spencer Ahrens
- [react-packager] Implement new style asset packaging (with dimensions) | Amjad Masad
- [React Native] RCT_EXPORT lvl.2 | Alex Akers
- [react_native] Implement TextInput end editing | Andrei Coman
- [react_native] Make TextInput focus, blur, dismiss and show keyboard work | Andrei Coman
- Added non-class-scanning-based approach fror registering js methods | Nick Lockwood
- [ReactNative] Update package.json | Christopher Chedeau
- [ReactNative] Do flow check when running packager | Spencer Ahrens
- [ReactNative] Fix typo/bug in Navigator._completeTransition | Eric Vicenti
- [ReactNative] Fix Navigator exception when touching during transition | Eric Vicenti
- [ReactNative] Remove bridge retaining cycles | Tadeu Zagallo
- [ReactNative] Fix and re-add WebView executor | Tadeu Zagallo