Граф коммитов

49 Коммитов

Автор SHA1 Сообщение Дата
Michael Bolin 0b9ea60b4f Back out "Upgrade Prettier from 1.17 to 2.0.2."
Differential Revision: D20639755

fbshipit-source-id: 5028563f9cf0527a30b4259daac50cdc03934bfd
2020-03-24 21:47:35 -07:00
Michael Bolin cf44650b3f Upgrade Prettier from 1.17 to 2.0.2.
Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html

Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.

Reviewed By: zertosh

Differential Revision: D20636268

fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
2020-03-24 20:24:47 -07:00
Riley Dulin ce1703a84d Change stringifySafe to have limits on larger objects
Summary:
In heap snapshots, it was found that really large (20 MB) strings representing network data
were being logged as part of `Systrace.beginEvent` strings from `MessageQueue` in DEV mode.

To combat this, use `JSON.stringify` with limits to keep the depth, strings, arrays, and objects
in check.

Changelog: [Internal] Change `stringifySafe` to have max limits on string size

Reviewed By: yungsters

Differential Revision: D20016501

fbshipit-source-id: e123016557bc154e4210e0b4df44360570da8016
2020-03-02 17:28:21 -08:00
Pieter De Baets 13d8f4848e Stub out callFunctionReturnResultAndFlushedQueue
Summary: Changelog: [Internal] Remove unused BatchedBridge.callFunctionReturnResultAndFlushedQueue

Reviewed By: cpojer

Differential Revision: D19765606

fbshipit-source-id: d639e76c48113060013f9e858a669d8b1e4d20e7
2020-02-06 03:35:32 -08:00
Pieter De Baets 46dcce0031 Remove unused callFunctionReturnResultAndFlushedQueue
Summary: Changelog: [Internal] Remove unused BatchedBridge.callFunctionReturnResultAndFlushedQueue

Reviewed By: sammy-SC

Differential Revision: D19740946

fbshipit-source-id: 9919d52074180d0fcfb7c0929005f0d925578912
2020-02-05 13:02:06 -08:00
George Zahariev 8553e1acc4 Exact-by-default codemod for react-native-github
Summary:
We are rolling out exact-by-default syntax to xplat/js.

I had to manually move around some comments to preserve proper placement.

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D18633611

fbshipit-source-id: 48f7468dcc55b1d00985419d035a61c6820b3abe
2019-11-21 09:42:57 -08:00
Moti Zilberman a483f802fd Remove framesToPop from bridge
Summary: Removes the use of `framesToPop` from method wrappers in the RN bridge.

Reviewed By: rubennorte

Differential Revision: D17764986

fbshipit-source-id: f2fac0c33a9a7c821bb920fa65b92a4672150a38
2019-10-09 05:48:15 -07:00
Janic Duplessis 0cafa0f5d1 Use `warnOnce` for excessive number of callbacks error (#26508)
Summary:
I happened to hit this error a couple times and the issue is that if there are let's say 1000 pending callbacks the error would be triggered 500 times and pretty much crash the app. I think it is reasonable to use warn once here so it only happens once.

## Changelog

[General] [Fixed] - Use `warnOnce` for excessive number of callbacks error
Pull Request resolved: https://github.com/facebook/react-native/pull/26508

Test Plan: Tested by reducing the number of pending callbacks required to trigger the error.

Reviewed By: TheSavior

Differential Revision: D17512917

Pulled By: JoshuaGross

fbshipit-source-id: 5ce8e2a0a166805cc6f3fe6d78e2716d6792a80e
2019-09-23 10:14:51 -07:00
Logan Daniels 91f139b941 xplat/js/react-native-github
Reviewed By: panagosg7

Differential Revision: D16657770

fbshipit-source-id: 4e260842c838a35317515044c54ccf55a083da33
2019-08-09 10:11:15 -07:00
Spencer Ahrens 1e45a41dc2 dev error for excessive pending callbacks
Summary:
We've seen some crashes from exceeding property limits (>200k) from storing callbacks, which is insane since callbacks should be called and cleaned up right away in most cases. Browsing around I never see more than about 50 pending callbacks when firing off a whole much of animations and measures and stuff.

In order to track down the leak, I added some code in `__DEV__` to provide more info - hopefully some developers will hit it and report the issue. Unfortunately it's not easy to get any useful information in prod because we strip all the useful debug info, but if this continues to be a problem we could try capturing that info in prod as well (and maybe other info, too).

Reviewed By: PeteTheHeat

Differential Revision: D16267702

fbshipit-source-id: 8185bb8ff0d646b307c98238616950086b1a608f
2019-07-17 14:15:54 -07:00
Spencer Ahrens 8dcee62be9 Use `Map`s instead of `Object`s for `MessageQueue` callbacks
Summary:
This lead to exceeding the Object property count limit in Hermes:
```
Unhandled JS Exception: Property storage can't accommodate 254464 properties, js engine: hermes
```

Reviewed By: PeteTheHeat

Differential Revision: D16212572

fbshipit-source-id: 8fcedb55ebd1f8b289ec759ea1ad4e81cf903dfd
2019-07-17 14:15:54 -07:00
Moti Zilberman 56f08fcf84 Pop bridge frames from errors thrown by sync host function calls
Summary:
When a synchronous call from JS to native code throws an error, it doesn't include a useful stack trace from the native side. To improve error attribution, this diff pops the frames in `MessageQueue.js` and `NativeModules.js` from the stack traces of such errors. This uses the `error.framesToPop` convention understood by RN's global error handler.

For now we limit this to errors converted from C++ exceptions in host functions, since those are not likely to ever contain further JavaScript frames at the point where we catch them; if they did, it would violate our assumption that the top two frames of the stack are in the JS bridge code.

Reviewed By: cwdick

Differential Revision: D15805054

fbshipit-source-id: 8c1dd7c81b00b6a88e31473271889af1f88f7263
2019-06-19 09:15:14 -07:00
Moti Zilberman 0f92984eba Strengthen ModuleConfig Flow typing
Summary:
Types the last 3 members of the `ModuleConfig` tuple (functions, promise method IDs, and sync method IDs) as nullable and immutable arrays. This is in line with how they are used in the code; one debug-only call site had to be fixed to account for nullability.

Also updates the test data in `MessageQueueTestConfig` to explicitly conform to this type.

Reviewed By: amnn

Differential Revision: D15899159

fbshipit-source-id: b6955ba92efc73253de48e2ce7c3034fa91adce3
2019-06-19 09:15:13 -07:00
James Ide 0ee5f68929 Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749)
Summary:
This is the next step in moving RN towards standard path-based requires. All the requires in `Libraries` have been rewritten to use relative requires with a few exceptions, namely, `vendor` and `Renderer/oss` since those need to be changed upstream. This commit uses relative requires instead of `react-native/...` so that if Facebook were to stop syncing out certain folders and therefore remove code from the react-native package, internal code at Facebook would not need to change.

See the umbrella issue at https://github.com/facebook/react-native/issues/24316 for more detail.

[General] [Changed] - Migrate "Libraries" from Haste to standard path-based requires
Pull Request resolved: https://github.com/facebook/react-native/pull/24749

Differential Revision: D15258017

Pulled By: cpojer

fbshipit-source-id: a1f480ea36c05c659b6f37c8f02f6f9216d5a323
2019-05-08 08:48:59 -07:00
Spencer Ahrens 3155ddf2e8 Support callbacks in synchronous native functions
Summary:
We need to move animated native module calls to synchronous so we can properly thread them in with mounting instructions in Fabric. Some of them take callbacks so we need to add support for that when switching to synchronous.

A side benefit is that we can unify codepaths a little more with async callbacks.

Reviewed By: shergin

Differential Revision: D14790898

fbshipit-source-id: dc222b9e74375e046e8a9b1b19d72f652dc6722c
2019-04-08 09:15:13 -07:00
Christoph Nakazawa 4148976a83 Use `invariant` instead of `fbjs/lib/invariant`
Summary: This is one more step to remove `fbjs` from `react-native-github`. This changes both the internal and external code to use `invariant` from zertosh instead of the copy in fbjs.

Reviewed By: yungsters

Differential Revision: D13195941

fbshipit-source-id: 73564ca1715110e7da9c7ef56dc57374d61377e0
2018-12-03 00:07:02 -08:00
Riley Dulin bbb2d9a5b3 Change new Date() to Date.now() to save on date allocations
Summary:
`new Date().getTime()` is equal to `Date.now()`.
`Date.now()` avoids an allocation, which can save some GC time.

This micro-optimization isn't worth it in most places, but since MessageQueue is one of the hottest pieces of JS in RN, it's worth it.

Reviewed By: javache

Differential Revision: D9972334

fbshipit-source-id: 05d78fd65304f0f27115d76b8b52db11a52c86a0
2018-09-21 11:11:33 -07:00
Marc Horowitz 7f1fcb67e5 Improve the bridge params validator, and its invariant string
Summary:
NaN is not handled consistently by the bridge in all cases,
so detect it and complain.  In order to make the complaint more
obvious, use JSON.stringify on the value, and a replacer so that some
of the censoring which normally takes place doesn't get in the way of
clarity.

Reviewed By: mmmulani

Differential Revision: D9779799

fbshipit-source-id: 6c1a6bfe05ecaa3aeb558acc49dfd54461e1ba74
2018-09-12 19:10:16 -07:00
Héctor Ramos 1151c096da Update copyright headers to yearless format
Summary: This change drops the year from the copyright headers and the LICENSE file.

Reviewed By: yungsters

Differential Revision: D9727774

fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
2018-09-11 15:33:07 -07:00
Kirill Nikolaev 52f431b4bb Eliminate circular dependency between MessageQueue and JSTimers modules. (#19526)
Summary:
This makes JSTimers actively register a callback for callImmediates.

Besides being generally tricky, circular dependency prevent compiling React Native code with bundlers that rely on concatenating module sources rather that evaluating code at the time of requiring, like Google Closure Compiler.

Sadly, Google Closure Compiler setup that prompted this change is complicated and brittle. And there are no good public tools to find circular dependencies among Haste-style modules (with unqualified require paths).

So some advice on a good test plan would be useful. Does Facebook have any tools to find circular dependencies with Haste-style requires?

FWIW, a check that worked for me was to replace all import paths in React Native from Haste style to normal relative paths (which I needed anyway) and then run [`madge`](https://www.npmjs.com/package/madge) on the code base:

```
$ ~/node_modules/.bin/madge --circular react-native/Libraries
Processed 390 files (7.4s) (81 warnings)

✖ Found 2 circular dependencies!

1) BatchedBridge/NativeModules.js > BatchedBridge/BatchedBridge.js > BatchedBridge/MessageQueue.js > Core/Timers/JSTimers.js
2) StyleSheet/flattenStyle.js > StyleSheet/StyleSheet.js
```

(The second cycle is already eliminated in a8e3c7f578).

[GENERAL] [MINOR] [MessageQueue] - MessageQueue implementation doesn't have a circular dependency on JSTimers.
Closes https://github.com/facebook/react-native/pull/19526

Reviewed By: hramos

Differential Revision: D8458755

Pulled By: yungsters

fbshipit-source-id: e753139b920ba1ad1a6db10f974c03ca195340c7
2018-06-15 17:06:29 -07:00
Nurzhan Bakibayev 10814e2e61 Remove __fbUninstallRNGlobalErrorHandler
Reviewed By: pakoito

Differential Revision: D7831179

fbshipit-source-id: 6db9fe617d5a1a23a4aa46c9c3028db13a7a52a0
2018-05-21 11:12:46 -07:00
Eli White cd7c91f35d Convert react-native-github/Libraries to let/const
Reviewed By: sahrens

Differential Revision: D7961763

fbshipit-source-id: ff7dd1d2c7101c8019e0b4f844d8c377b4d13a13
2018-05-10 19:10:38 -07:00
Riley Dulin d4d515cdc3 MessageQueue not initializing inCall
Reviewed By: yungsters

Differential Revision: D7898700

fbshipit-source-id: c2b4d6e75e7f5871cd40b00bd173e6f1a929b26a
2018-05-10 11:02:45 -07:00
Spencer Ahrens 5b923e0eaf Add args to bridge function call systrace markers
Reviewed By: yungsters

Differential Revision: D7797728

fbshipit-source-id: 615affc57e658d4dd08a88f829d38be930804372
2018-04-30 09:55:49 -07:00
Rubén Norte d5e9e55fa3 Remove @providesModule from all modules
Summary:
This PR removes the need for having the `providesModule` tags in all the modules in the repository.

It configures Flow, Jest and Metro to get the module names from the filenames (`Libraries/Animated/src/nodes/AnimatedInterpolation.js` => `AnimatedInterpolation`)

* Checked the Flow configuration by running flow on the project root (no errors):

```
yarn flow
```

* Checked the Jest configuration by running the tests with a clean cache:

```
yarn jest --clearCache && yarn test
```

* Checked the Metro configuration by starting the server with a clean cache and requesting some bundles:

```
yarn run start --reset-cache
curl 'localhost:8081/IntegrationTests/AccessibilityManagerTest.bundle?platform=android'
curl 'localhost:8081/Libraries/Alert/Alert.bundle?platform=ios'
```

[INTERNAL] [FEATURE] [All] - Removed providesModule from all modules and configured tools.
Closes https://github.com/facebook/react-native/pull/18995

Reviewed By: mjesun

Differential Revision: D7729509

Pulled By: rubennorte

fbshipit-source-id: 892f760a05ce1fddb088ff0cd2e97e521fb8e825
2018-04-25 07:37:10 -07:00
Paco Estevez Garcia 976712afa3 Replace RN exception handling override with new version
Reviewed By: Hypuk

Differential Revision: D7385541

fbshipit-source-id: 287d3f4d681046f740ed0552e00a2249c3803a0b
2018-04-03 06:01:37 -07:00
Charles Dick aabd5d1458 Use map instead of array
Reviewed By: dcaspi

Differential Revision: D7327839

fbshipit-source-id: e48d2b9f34e337d14f9519eac16b6a15fa56deb5
2018-03-20 04:17:55 -07:00
Sophie Alpert 1490ab12ef Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:31:53 -08:00
Marc Horowitz ea2e2c54cb Make the __DEV__ argument check more robust
Summary: JSON.stringify will convert a function to null, but folly::dynamic in the native code can't represent a JS function. Props do sometimes have functions, but don't permit them everywhere.

Reviewed By: johnislarry

Differential Revision: D6541878

fbshipit-source-id: b2a9d3ba7899dfb98a6a2ada3aa91a26549fdd94
2017-12-14 11:17:39 -08:00
Paco Estevez Garcia 1d16923063 Add remote API to uninstall the global error handler in RN
Reviewed By: fromcelticpark

Differential Revision: D6426209

fbshipit-source-id: 804e73e0dc4e4b85b336e3627c00840d2ff3c9d6
2017-12-11 08:06:24 -08:00
Riley Dulin 7b575d669d Improve flow typing and linting for MessageQueue
Differential Revision: D5987892

fbshipit-source-id: 8b9218875944decc5e21863e3c3f3a659ff2e2e4
2017-10-10 16:32:28 -07:00
Riley Dulin 089add4de7 Add @format to MessageQueue
Reviewed By: javache

Differential Revision: D5925489

fbshipit-source-id: 799b530a2540850722ad1910263030afb951c4c5
2017-09-28 13:16:00 -07:00
Jonathan Lee 182874d972 Reverting changes to MessageQueue
Reviewed By: zjj010104

Differential Revision: D5785916

fbshipit-source-id: ed30e3d2763d16c5a1f550f05d2b9f0997b83fbe
2017-09-07 14:30:59 -07:00
Pieter De Baets cb313569e5 Increase information logged to MessageQueue.spy
Reviewed By: dulinriley

Differential Revision: D5517734

fbshipit-source-id: de7ba08130d229882256bcb1496d6efc708bdce7
2017-07-31 06:16:41 -07:00
Kody Greenbaum 26764d4179 Revert D5470356: [react-native] Increase information logged to MessageQueue.spy
Differential Revision: D5470356

fbshipit-source-id: 27b247ac3c538f801c1f9a86f74fb3098064e92e
2017-07-25 11:53:20 -07:00
Pieter De Baets f445ac8ef1 Increase information logged to MessageQueue.spy
Reviewed By: dulinriley

Differential Revision: D5470356

fbshipit-source-id: 663dfa4e0c8cc5292e27f607111fc35a565a0bd8
2017-07-25 08:01:28 -07:00
Miguel Jimenez Esun 1d7c990424 Make a method used externaly (in a test) public
Summary: The method is being used in a test, so if a private method name mangling happens, the name of the method changes and the test fails.

Reviewed By: cpojer

Differential Revision: D5347967

fbshipit-source-id: ee964c2876bcfea5253d2ce7f9f02d4dbeebeab3
2017-07-03 07:53:58 -07:00
Pieter De Baets 0ae11f12f3 Merge JSTimers and JSTimersExecution
Reviewed By: mmmulani

Differential Revision: D5292923

fbshipit-source-id: d8331cbac28ba3bbf47c9746238a755b707903ea
2017-06-22 09:52:33 -07:00
Alex Dvornikov e38641cd73 Fixed error in _getCallableModule method in MessageQueue
Reviewed By: javache

Differential Revision: D5208462

fbshipit-source-id: 13f71e2b7988305eccfa91c349ff120fad9129f0
2017-06-08 12:49:37 -07:00
Alex Dvornikov 485bb70691 Allow lazy modules registration with the BatchedBridge
Reviewed By: javache

Differential Revision: D5181849

fbshipit-source-id: f63562c360488a9818605b25c1338214daac7411
2017-06-06 07:07:19 -07:00
Pieter De Baets 07ee2fb90a Only call callImmediates once per batch
Reviewed By: AaaChiuuu

Differential Revision: D5163897

fbshipit-source-id: bcff70c4a6a6329b9ae771d9cad14876e3a40250
2017-06-02 08:17:07 -07:00
rh389 0a55e42ef6 Refactor MessageQueue
Summary:
Looking to address a few new `FlowFixMe`s I had to do some minor refactoring of `MessageQueue`. Has the advantage of (IMO) making things clearer by removing a redundant counter and some gratuitous bitwise operations.

Previously `_callbacks` was an array of `?Function`s where even elements were failure callbacks and odd elements were successes. Each new call incremented `_callID` by one and `_callbackID` by two. I've changed this to use two arrays `_successCallbacks` and `_failureCallbacks` indexed by `callID`. That made the `_callbackID` counter unnecessary and reduced the need for computed indices.

Tested with flow and a quick play with UIExplorer.
Closes https://github.com/facebook/react-native/pull/11986

Differential Revision: D4962162

Pulled By: javache

fbshipit-source-id: 17dddfedc0cb5950dbdd9bd06fae6eb6de4c4a7d
2017-04-28 04:04:14 -07:00
Marc Horowitz 1916b38a65 Support passing a collection of native modules to JSContext
Reviewed By: javache

Differential Revision: D4772649

fbshipit-source-id: dd9353edb0c2c013a3b7fe772231db12cdd8cdae
2017-03-31 01:00:52 -07:00
Pieter De Baets 7de59b102d Support calls through MessageQueue when interecting with JSValue directly
Reviewed By: yungsters

Differential Revision: D4756241

fbshipit-source-id: 5c7309a18ac476a620451bf471471596c9f82cf8
2017-03-28 07:18:21 -07:00
Spencer Ahrens 5d4d62f474 Some perf tools for debugging js stalls
Summary:
The stall watchdog is handy to detect stalls, but it doesn't really tell us what was
happening. This diff makes it easy to track React perf and bridge traffic during any stall, and
prints it out if the stall exceeds the threshold.

Reviewed By: yungsters

Differential Revision: D4479439

fbshipit-source-id: 87f94913ec341a648d7744249597dc30b29759ab
2017-02-06 17:46:34 -08:00
Gabe Levi e2ce98b7c6 Fix the suppress comment regex for react_native
Reviewed By: davidaurelio

Differential Revision: D4435640

fbshipit-source-id: c680aee6931979859f04c0dca47037ba6f6cba73
2017-01-19 10:28:28 -08:00
Gabe Levi a4bfac907e Deploy v0.38.0
Reviewed By: jeffmo

Differential Revision: D4428858

fbshipit-source-id: 10dc69349a2b563e1fa444a8b0612e3b2d4ccd1c
2017-01-18 11:13:30 -08:00
Gabe Levi 61d1a4fb39 Deploy v0.35.0
Reviewed By: davidaurelio

Differential Revision: D4177391

fbshipit-source-id: c02cf98ed275b7032103b11eab6d0e189f8d8f24
2016-11-14 20:45:17 -08: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