Commit Graph

276 Commits

Author SHA1 Message Date
Pieter De Baets dba133a291 Merge AndroidConstants and IOSConstants into PlatformConstants
Reviewed By: AaaChiuuu

Differential Revision: D4597790

fbshipit-source-id: 0a54598d6e9cadb75efff4ac17c13899d6785f9b
2017-02-22 15:01:11 -08:00
Aaron Chiu 02daffbe9d print out Performance markers to console
Differential Revision: D4585709

fbshipit-source-id: fe1f1f6b146854aa426e6186baf73ac2cf1784c8
2017-02-21 22:15:42 -08:00
Aaron Chiu e81258a15b add Systrace to all PerformanceLogger.js markers
Reviewed By: alexeylang

Differential Revision: D4567843

fbshipit-source-id: 00cac36d2b73f827723546a04edd6b89267c26bb
2017-02-17 12:01:06 -08:00
Adam Comella 186f308aec BREAKING: Android: Correct value of Dimensions.get('screen').fontScale
Summary:
The PR description has been updated to reflect the new approach.

**Breaking Change Summary**

On Android, the following properties now return a different number:
  - `Dimensions.get('window').fontScale`
  - `Dimensions.get('screen').fontScale`
  - `PixelRatio.getFontScale()`

This is a breaking change to anyone who was using these properties because the meaning of these properties has now changed.

These properties used to return a value representing font scale times density ([`DisplayMetrics.scaledDensity`](https://developer.android.com/reference/android/util/DisplayMetrics.html#scaledDensity)). Now they return a value representing just font scale ([`Configuration.fontScale`](https://developer.android.com/reference/android/content/res/Configuration.html#fontScale)).

**PR Description**

This PR changes a few things:
  - Correctly exposes the font scale to JavaScript as `Dimensions.get('screen').fontScale`. UIManager was exporting `DisplayMetrics.scaledDensity` under the name `fontScale`. How
Closes https://github.com/facebook/react-native/pull/11008

Differential Revision: D4558207

Pulled By: astreet

fbshipit-source-id: 096ce7b28051325dfd45fdb2a14b5e9b7d3bc46f
2017-02-14 08:45:38 -08:00
Sebastian Markbage c3b25c9059 Patch up for future React Sync
Reviewed By: spicyj, bvaughn

Differential Revision: D4523259

fbshipit-source-id: 317a26ce3e9e48553a7f7c856dd6b48038b4b2ea
2017-02-08 14:50:43 -08:00
Alexey Kureev f30ab35e92 Add default option for Platform.select
Summary:
satya164 asked me to take over fixes for [this PR](https://github.com/facebook/react-native/pull/11608), so here we go!
Closes https://github.com/facebook/react-native/pull/12218

Differential Revision: D4515285

Pulled By: davidaurelio

fbshipit-source-id: 8987c518401fc67093dfe93bbbb63b934c20f6f9
2017-02-07 04:30:16 -08:00
Philipp von Weitershausen 16bb6e87ba XHR: support typed arrays for request payloads
Summary:
Support `xhr.send(data)` for typed arrays.

**Test plan:** run UIExplorer example on iOS and Android.
Closes https://github.com/facebook/react-native/pull/11904

Differential Revision: D4425551

fbshipit-source-id: 065ab5873407a406ca4a831068ab138606c3361b
2017-01-20 18:43:27 -08:00
Kevin Gozali 06956e83cd expose IS_TESTING for Platform module
Summary: Introduced IS_TESTING flag on Platform module for android as well. This is useful for testing environment.

Reviewed By: mmmulani

Differential Revision: D4429662

fbshipit-source-id: 33711d7fb5666f0bac8aee444b71261f7f12770f
2017-01-19 14:28:30 -08:00
Max Graey b850af7a39 fix skew transformation
Summary:
Motivation:
fix #11884 issue

I will try in short to explain what was wrong.
Let's look to transformation's matrix for **skewY** for example.
| cos(a) | sin(a) |    0   |   0   |
|:------:|:------:|:------:|:-----:|
|    0   |    1   |    0   |   0   |
|    0   |    0   |   1    |    0  |
|   tx   |   ty   |   tz   |   1   ||

Yes, this visually produce skewing transform but it slightly incorrect. This way affects horizontal scale as well. See [this](https://github.com/facebook/react-native/issues/11884)

|    1   | tan(a) |    0   |   0   |
|:------:|:------:|:------:|:-----:|
|    0   |    1   |    0   |   0   |
|    0   |    0   |   1    |   0   |
|   tx   |   ty   |   tz   |   1   ||

According to [www.w3.org/css-transforms](https://www.w3.org/TR/css-transforms-1/#SkewDefined)

Only one differance React Native use **row major matrix style**, so we change ```m[0][1]``` instead ```m[1][0]```.

sahrens vjeux
Closes https://github.com/facebook/react-native/pull/11992

Differential Revision: D4436470

Pulled By: vjeux

fbshipit-source-id: 1b433f04650bae7e06b5a93f521e49f11c70cce3
2017-01-19 11:28:36 -08:00
Mehdi Mulani 81c33b542d Switch out DISABLE_YELLOW_BOX for IS_TESTING
Summary: Switch to using IS_TESTING on the Platform module. While IS_TESTING has to be explicitly set in the test harness, this makes it more usable and stops people from relying on brittle variables in the (larger) environment.

Reviewed By: fkgozali

Differential Revision: D4423661

fbshipit-source-id: 27a80867778b9374bcba67b69f9c93d32c0a74b0
2017-01-18 12:28:42 -08:00
Max Sherman a6844bdf75 Break infinite loop that happens only in debug environments
Reviewed By: javache

Differential Revision: D4411870

fbshipit-source-id: 6b141e42206734368ed50f37c8e7df8e8fd006c0
2017-01-17 16:58:46 -08:00
Albert Brand d2de604721 Android: fix JSC crash in dev
Summary:
On Android with dev mode on, we're seeing a regular SIGSEGV when pushing a lot of animation declarations over the bridge. We tracked this down to being not specific to animations, but the crash is caused in `deepFreezeAndThrowOnMutationInDev`.

Specifically: the provided object to freeze is modified while looping, replacing the current key access to a getter/setter. After the modification, JSC crashes during retrieval of the next key - but only when there are a lot of events passing over the bridge.

We have a hunch that this is due to a bug in JSC object enumeration but did we not look into it further yet. Any help here is welcome. The JS code seems all right at first sight and shouldn't cause a segmentation crash.

The workaround in this PR is to retrieve the keys first from the object and then looping over that array. In our app and in a reduced app test case this fixes the crash.

If needed I can provide the reduced app test case. It's really tricky to make a test for this as it requires to be run
Closes https://github.com/facebook/react-native/pull/11804

Differential Revision: D4403483

Pulled By: davidaurelio

fbshipit-source-id: a31e5cff734e96bfec56e4a39dc1c6854798e245
2017-01-11 08:58:30 -08:00
Mehdi Mulani 199d64083c Stop throwing yellew boxes when we warn from native
Summary: This caused a bunch of stuff to break, reverting and will fix the problems before committing next time.

Reviewed By: fkgozali

Differential Revision: D4363398

fbshipit-source-id: 55146c9da998f6a3883307c36422a9d440ea7f52
2016-12-27 10:43:33 -08:00
Mehdi Mulani ac11eedfb0 Show yellowbox when we fail to load a local image
Reviewed By: achen1

Differential Revision: D4342295

fbshipit-source-id: 9411ffe9a376e1ed51fcadee718326d1d9443fff
2016-12-19 14:07:08 -08:00
Pieter De Baets c92ad5f6ae Apple TV support 4: support for input (tvOS focus engine)
Reviewed By: shergin

Differential Revision: D4333546

fbshipit-source-id: 8655070e81dbb62a80ab1f00a43ef6c2d9654618
2016-12-19 06:28:40 -08:00
Michał Gregorczyk d72c6fd500 Do not call `toString` on functions in buildStyleInterpolator
Reviewed By: vjeux

Differential Revision: D4292618

fbshipit-source-id: cd7cd1a88aeb2c800f2c2941c79855992613ec84
2016-12-07 11:58:28 -08:00
Jennifer Wang be5868dddb Workaround native module dependency in Jest environment
Reviewed By: josephsavona

Differential Revision: D4225750

fbshipit-source-id: 6ac5a5cc1869232861977ea214970804acd7e39d
2016-11-22 23:58:30 -08:00
Tim Yung 23331df5a4 RN: Cleanup OSS JS & Flow Declarations
Reviewed By: vjeux

Differential Revision: D4210763

fbshipit-source-id: 5abaa547100b8badd13bcf311ceffc5b4098d252
2016-11-20 17:58:29 -08:00
Kevin Han b4283ed844 FIX: Call all android back key handlers before invoking default
Summary:
Fixes issue #9736
Closes https://github.com/facebook/react-native/pull/9757

Differential Revision: D4164796

Pulled By: hramos

fbshipit-source-id: c5d966a9bbaa91f9929ea20a775f96c15aa9f482
2016-11-11 00:28:40 -08:00
Pieter De Baets 384ea330c8 Move Platform constants to RCTPlatform
Reviewed By: majak

Differential Revision: D4081849

fbshipit-source-id: bee08af2f68dcc1af424f382f960ff897ba11945
2016-10-27 04:29:00 -07:00
Pieter De Baets 292cc82d0e Reorganize core JS files
Reviewed By: lexs

Differential Revision: D3987463

fbshipit-source-id: fa8f1d1bea7ed699120b9705ddc1c83767fcf8e4
2016-10-11 10:14:28 -07:00
Satyajit Sahoo fa5ad85252 Remove deprecated APIs and modules
Summary:
We've deprecated these APIs for quite a few releases and we should be able to get rid of them now.

Remove following deprecated modules/components
 - AppStateIOS
 - ActivityIndicatorIOS
 - IntentAndroid
 - SliderIOS
 - SwitchAndroid
 - SwitchIOS
 - LinkingIOS

Update following modules to remove callback support
 - Clipboard
 - NetInfo

cc bestander
Closes https://github.com/facebook/react-native/pull/9891

Reviewed By: bestander

Differential Revision: D3974094

Pulled By: javache

fbshipit-source-id: 9abe32716bd85d0cea9933894f4447d53bdd5ee7
2016-10-11 07:43:52 -07:00
Aaron Chiu 1296cb29eb add flag to enable lazy view managers
Reviewed By: achen1

Differential Revision: D3981171

fbshipit-source-id: 2f6b8370064a5835e2e3636d4c1a7f42cc28ccaf
2016-10-07 05:43:45 -07:00
Pieter De Baets 76c54847bb Extract native module logic from BatchedBridge
Reviewed By: lexs

Differential Revision: D3901630

fbshipit-source-id: c119ffe54a4d1e716e6ae98895e5a3a48b16cf43
2016-09-23 11:14:11 -07:00
Pieter De Baets 31b158c9fe Export native modules without RCT or RK prefix
Reviewed By: mmmulani

Differential Revision: D3901600

fbshipit-source-id: 7d4a027f0f2478e2a9ac9916326b91279bec3cb3
2016-09-23 11:14:11 -07:00
Pieter De Baets ff79224d37 Simplify ModuleConfig array format
Reviewed By: lexs, mhorowitz

Differential Revision: D3901563

fbshipit-source-id: 70aea19db1b01170be57b74ccfa1a306dfa1f362
2016-09-23 11:14:10 -07:00
Pieter De Baets acdd08aef7 Add flow-typing to MessageQueue
Reviewed By: majak

Differential Revision: D3901545

fbshipit-source-id: a9ccc3d11794830e21c778df0ae7100d79f7ee73
2016-09-23 11:14:10 -07:00
Pieter De Baets 145109fc6d Remove additional JSON encoding for native->JS communication
Reviewed By: mhorowitz

Differential Revision: D3857323

fbshipit-source-id: 4386cc107b8a1425ecb7297b0f659f6c47f01a78
2016-09-19 04:44:12 -07:00
Pieter De Baets 95cce07baf Support invoking method that returns result and flushes call queue
Reviewed By: mhorowitz

Differential Revision: D3870879

fbshipit-source-id: bc8f70d9866dfc25468c9072c209cc6842b98575
2016-09-16 06:28:48 -07:00
Pieter De Baets 5f381fd357 Move buildStyleInterpolator-test to open-source, remove unused files
Reviewed By: bestander

Differential Revision: D3820939

fbshipit-source-id: 2ff114326642b522f162c6cce7853c8b3f0c138b
2016-09-09 10:58:59 -07:00
Pieter De Baets 99e0267c25 Cleanup and document native module configuration
Summary: Get rid of the old behaviour of JSON encoding in `nativeRequireModuleConfig` and consistently use the same names for function types "async/promise/sync"

Reviewed By: lexs

Differential Revision: D3819348

fbshipit-source-id: fc798a5abcaf6a3ef9d95bd8654afa7825c83967
2016-09-08 04:13:51 -07:00
Kevin Gozali 150fe7cb9c fixed polyfill for BackAndroid
Summary:
`BackAndroid.addEventListener()` returns a subscription object with a `remove()` function in android. Before this fix, the iOS equivalent doesn't return anything, which means, if there's a component doing something like this, it would redbox:

```
componentWillMount() {
  this._subscription = BackAndroid.addEventListener('hardwareBackPress', () => {...});
}

componentWillUnmount() {
  this._subscription.remove(); // --> redbox in iOS before this fix
}
```

Differential Revision: D3790480

fbshipit-source-id: 1e607171bf2892a6b64977c4fd052c5df0bc4a0d
2016-08-30 10:58:45 -07:00
Adam Comella 5d748b2eec Fix memory leak in MessageQueue
Summary:
The MessageQueue has a _debugInfo object where it stores debug information associated with each callback. The size of this structure is currently unbounded.

It looks like the code attempted to restrict _debugInfo to a fixed number of entries but due to a logic bug, it leaked around 30 entries for every 1 entry it cleaned up.

This change limits the _debugInfo object to around 30 entries.

**Test plan (required)**

This change is currently being used in my team's app.

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

Differential Revision: D3781875

fbshipit-source-id: 58c645c52c3e295fe571b7ca7e0d882169c301ef
2016-08-26 18:58:35 -07:00
Alexander Blom 61b21bcdd1 Remove legacy bridge config conversion
Reviewed By: javache

Differential Revision: D3741859

fbshipit-source-id: b678b3a2bbed4f7ed386e10db19553c8beef7366
2016-08-22 06:59:03 -07:00
Dan Abramov 1aef7e4629 Update hook event names
Summary:
This brings RN up to date with https://github.com/facebook/react/pull/7472 (scheduled for React 15.3.1).
If you use React 15.3.1 with RN without this patch, Systrace output will lack the reconciler events.

(Since it’s a niche feature it didn’t seem to me that full backward compat is necessary so I just removed old hooks. This won’t cause crashes—it’s just you won’t get events in Systrace if you use new React but old RN.)
Closes https://github.com/facebook/react-native/pull/9383

Differential Revision: D3738463

Pulled By: spicyj

fbshipit-source-id: 791cdbc5558666a101fa403f4e7852f700038fc9
2016-08-18 15:58:48 -07:00
Pieter De Baets e4ac66b0ee Unbreak UIManager.takeSnapshot
Reviewed By: majak

Differential Revision: D3729478

fbshipit-source-id: 35869e4327debae78f36638694d09f30c6478661
2016-08-17 10:28:36 -07:00
Pieter De Baets 4afaf5e538 Fix RCTRootView invalidation using the wrong bridge
Reviewed By: majak

Differential Revision: D3696533

fbshipit-source-id: e7ef4373e975e585f4c34df71966c8b5b30d3e9a
2016-08-10 07:43:33 -07:00
David Aurelio 94666f16c7 Auto-fix lint errors
Reviewed By: bestander

Differential Revision: D3683952

fbshipit-source-id: 9484d0b0e86859e8edaca0da1aa13a667f200905
2016-08-09 06:43:46 -07:00
Rickard Ekman 8e2906ae89 Android: Implement cancelable option for Alerts
Summary:
**Motivation**
In iOS you cannot dismiss alerts by clicking outside of their box, while on Android you can. This can create some inconsistency if you want to have identical behavior on both platforms. This change makes it possible for Android apps to have irremovable/required alert boxes just like in iOS.

This adds an additional parameter to the Alert method. The way to use it is by providing an object with the cancelable property. The cancelable property accepts a boolean value.

This utilizes the Android DialogFragment method [setCancelable](https://developer.android.com/reference/android/app/DialogFragment.html#setCancelable(boolean))

**Usage example**
```js
Alert.alert(
   'Alert Title',
   null,
   [
     {text: 'OK', onPress: () => console.log('OK Pressed!')},
   ],
   {
     cancelable: false
   }
);
```

**Test plan (required)**

I added an additional alert to the UIExplorer project where it can be tested. I also added a part in the Dialog Module test to make sure setting canc
Closes https://github.com/facebook/react-native/pull/8652

Differential Revision: D3690093

fbshipit-source-id: 4cf6cfc56f464b37ce88451acf33413393454721
2016-08-09 06:13:48 -07:00
Pieter De Baets 0222107170 Customize main thread initialization of native modules (2nd try)
Reviewed By: majak

Differential Revision: D3671197

fbshipit-source-id: e8df7669be79303d335f2c881e97310b5fed47f9
2016-08-05 11:28:32 -07:00
Mengjue Wang f0fb228ec7 Provide forceRTL for LTR language to test
Summary:
1. Provide forceRTL function for developer to test RTL layout in LTR language bundle in I18nUtil and expose it in I18nManager.
2. Rename `allowRTL` and `setAllowRTL` functions

Reviewed By: fkgozali

Differential Revision: D3663693

fbshipit-source-id: 3db13a44c069ae73d1728c211306422db5dd8122
2016-08-04 12:28:30 -07:00
Dotan Nahum 77e48f1782 Make MessageQueue to emit "SPY" events in a way that can be extensible
Summary:
This PR adds a capability for MessageQueue to emit "SPY" events in a way that can be extensible, to later allow for a tooling ecosystem to grow, one example is the existing [Snoopy](https://github.com/jondot/rn-snoopy) tool that is, for now, forced to work with monkeypatches, and after this PR will be able to use a "formal" way to trace queue events.

After this change, we can wire a "spy" into a queue that will expose the events in different and interesting ways, see below (done with Snoopy):
  <img src="https://github.com/jondot/rn-snoopy/blob/master/media/snoopy.gif?raw=true" alt="Aggregating and Charting Events with Bar" width="400px"/>
  <img src="https://github.com/jondot/rn-snoopy/blob/master/media/snoopy-filter.gif?raw=true" alt="Aggregating and Charting Events with Bar" width="400px"/>

This removes the hardcoded `SPY_MODE` flag and instead uses a function that can be injected from outside world.

```javascript
MessageQueue.spy((info)=>console.log("event!", info)
```

It also creates
Closes https://github.com/facebook/react-native/pull/9160

Differential Revision: D3669053

Pulled By: javache

fbshipit-source-id: 3e4462aa77fc8514d2ea4f15430f7bec57b583a4
2016-08-04 08:43:31 -07:00
Daniel Schmidt c2cf510ff8 Improve the BackAndroid example to be more clear
Summary:
The example of `BackAndroid` caused a bit of confusion for beginners (see #8822), so I thought we should clarify the functionality a bit. I added a comment indicating that a user would have to implement `this.onMainScreen` and `this.goBack` on their own, this was the original problem.
Closes https://github.com/facebook/react-native/pull/8829

Differential Revision: D3660332

fbshipit-source-id: d84a29586c6a1a439f386e6b88220d7b0a275129
2016-08-02 18:30:38 -07:00
Pieter De Baets b83ccb5749 Reverted commit D3580025
Reviewed By: mhorowitz

Differential Revision: D3580025

fbshipit-source-id: 4422b6b97ef844158e369e022d62d6f0ae641222
2016-08-02 14:13:27 -07:00
Lukas Piatkowski ec0ccf599a #15 Add a button in devtools to start/stop the Sampling Profiler
Differential Revision: D3555704

fbshipit-source-id: 4add16c923fcfd306892efec4630c24ae438d6dd
2016-08-02 11:14:06 -07:00
Pieter De Baets e762d961cd Use new enqueueJSCall method everywhere
Reviewed By: majak

Differential Revision: D3605263

fbshipit-source-id: 215f896d675b937593c8b796ed6ec5261ac74dbf
2016-08-02 11:14:06 -07:00
Pieter De Baets 47d6d289d4 Customize main thread initialization of native modules
Reviewed By: mhorowitz

Differential Revision: D3580025

fbshipit-source-id: 18abc15b894c745f584d91da47035c6db036aafa
2016-08-02 10:27:25 -07:00
Siqi Liu 43f73f675f Enable websocket interception in RN network inspector tool
Summary:
This diff enables network inspection for WebSocket APIs, so by now XMLHttpRequest, Fetch and WebSocket are all supported. Android and iOS are both supported.

This diff monkey-patches the RCTWebSocketModule which WebSocket API builds on, and now it is able to intercept all WebSocket requests when app is running. The intercepted information of a WebSocket includes url, protocols, status, messages (sent and received), close reason, server close event and server error information, etc.

Reviewed By: davidaurelio

Differential Revision: D3641770

fbshipit-source-id: 393df0da74ed95b1fd60e38b0d67ed61b3dd5ff3
2016-08-02 08:28:39 -07:00
Siqi Liu 1e8b83d2e6 Add unique ids to the intercepted XHR objects to make the tracking correctly across inspector restarts.
Summary: In previous `XHRInterceptor`, it sometimes crashes when restarting the network inspector because the id of the XHR objects are not unique all time. Fix this in diff by adding a global id "generator" for all intercepted xhr objects in order to make it safe across inspector restarts.

Reviewed By: davidaurelio

Differential Revision: D3641624

fbshipit-source-id: f9a1589f278023243aa182d3da93ce69c985587c
2016-08-02 08:28:39 -07:00
Charles Dick aba87550cc upload JSC heap capture to bundle server
Reviewed By: bestander

Differential Revision: D3642116

fbshipit-source-id: 9626078bb0f087f55d8270c8e0b082c74bd2df9d
2016-08-02 08:13:57 -07:00