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

148 Коммитов

Автор SHA1 Сообщение Дата
Kevin Gozali 8662d9d3b0 TM iOS: Added backward-compatible ObjC invalidation logic
Summary:
Some ObjC NativeModules conform to `RCTInvalidating` protocol and implements `invalidate` method. This is typically used to clean things up during bridge teardown or reload. In TurboModule system the invalidate method can be replaced by pure destructors, but for backward compatibility, we call existing invalidate method on each module during teardown.

This also cleans up all existing LongLivedObject's.

Reviewed By: mdvacca, RSNara

Differential Revision: D15365655

fbshipit-source-id: 802844b39b5b7adb54970ea541f4d744bbf9e480
2019-05-15 17:36:05 -07:00
Kevin Gozali 6aa896896f Fabric iOS: ask the bridge to queue async callback for the RuntimeExecutor
Summary:
In the case where the first rootView we load enables Fabric, the UIManagerBinding ended up calling AppRegistry (JS) too early, before the bridge was fully ready. This means AppRegistry wasn't set up yet, causing redbox.

To fix this, RuntimeExecutor impl should ask the bridge to queue the callback instead of asking the MessageQueueThread directly. MessageQueueThread only works well IFF the bridge is alive, but it has no knowledge about whether the bridge is alive or not. To support this, we add `invokeAsync` impl to the RCTCxxBridge.

Reviewed By: JoshuaGross

Differential Revision: D14868547

fbshipit-source-id: 3b3f2b9150e930b4a2c71012242305241fc6dbed
2019-04-10 11:04:23 -07:00
Kevin Gozali 71a8944b39 TM iOS: Use weak_ptr to pass around Instance to avoid unreleased refs
Summary:
There is a timing issue when reloading the bridge (in dev mode) and the tear down of the TurboModules. This causes `Instance` to never get freed, hence the "bridge" isn't cleaning up properly. The side effect can be bogus error saying that it's unable to find a module.

To address this, JSCallInvoker should just take in weak_ptr<Instance>.

Reviewed By: RSNara

Differential Revision: D14739181

fbshipit-source-id: f9f2a55486debaeb28d3d293df3cf1d3f6b9a031
2019-04-02 18:11:18 -07:00
Kevin Gozali a43e666a34 TM iOS: force flush message queue when calling into JS from native
Summary: When calling into JS (e.g. promise resolve/reject, callback) in TurboModule, we bypass the bridge's message queue. At times this causes race condition, where there are a bunch of pending UI operations (in RCTUImanager) waiting to be flushed, but nothing adds calls to the message queue. Usually tapping the screen will trigger the flush because we're sending down touch events to JS.

Reviewed By: JoshuaGross

Differential Revision: D14656466

fbshipit-source-id: cb3a174e97542bf80f0a37b4170b6a8e6780fa35
2019-03-29 01:39:39 -07:00
Dhaval Kapil 64f3a87c9d Refactor JSIExecutor to use runtimeInstaller for injecting the logger instance
Summary: This is based on the work done in D8686586. Removed the logger instance from JSIExecutor constructor and installed it into the runtimeInstaller at all call sites.

Reviewed By: mhorowitz

Differential Revision: D14444120

fbshipit-source-id: 0476fda4230c467573ea04102a12101bcdf36c53
2019-03-25 09:12:11 -07:00
Rafi Ciesielczuk e2bf843d86 Introduce Module Setup Metric (#23859)
Summary:
The `RCTBridge` contains numerous definitions of notification names, which we can observe in order to get insights into the React Native performance.

The Android implementation is a little different, such that you can listen for any of the [following](https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java) marker constants, simply by including the following code:

```java
ReactMarker.addListener(new ReactMarker.MarkerListener() {
  Override
  public void logMarker(ReactMarkerConstants name, Nullable String tag, int instanceKey) {
    Log.d("ReactNativeEvent", "name: "+ name.name() + " tag: " + tag);
  }
});
```
This will allow you to perform the necessary processing, calculations as required.

 ---

This PR enables observing for the module setup event (`RCTDidSetupModuleNotification`) by including the respective module's name & setup time in milliseconds.

[iOS] [Added] - Gain insights on the module setup times by observing `RCTDidSetupModuleNotification`. The `userInfo` dictionary will contain the module name and setup time in milliseconds. These values can be extracted via `RCTDidSetupModuleNotificationModuleNameKey ` and `RCTDidSetupModuleNotificationSetupTimeKey`.
Pull Request resolved: https://github.com/facebook/react-native/pull/23859

Differential Revision: D14579066

Pulled By: PeteTheHeat

fbshipit-source-id: 52645127c3fc6aa5bd73e3bd471fccd79cb05c14
2019-03-22 10:43:00 -07:00
Changnam Hong 5dd6908b25 Fix RCTJavaScriptLoader loadBundleAtURL error case (#23837)
Summary:
Change the function called when an error is returned from the completionHandler of the `RCTJavaScriptLoader(loadBundleAtURL:onProgress:onComplete:)`.

* AS-IS
    - `RCTLogError()`
    - This error method does not post any notification for users. So users cannot receive notification when `RCTJavaScriptLoader(loadBundleAtURL:onProgress:onComplete:)` complete with error.(i.e. bundleURL is is invalid but not nil, `http://1`, `http://localho:8081/index.bundle`)

* TO-BE
    - `handleError(error:)`
    -  Call this method will post notification for users when `completionHandler` fails with error.

[iOS] [Fixed] - Change the function called when an error is returned from the completionHandler of the `RCTJavaScriptLoader(loadBundleAtURL:onProgress:onComplete:)`.
Pull Request resolved: https://github.com/facebook/react-native/pull/23837

Differential Revision: D14538790

Pulled By: cpojer

fbshipit-source-id: da3306904c0d8113d204edfaa0f9e2a23793981a
2019-03-20 04:53:24 -07:00
zhongwuzw 8266f61935 Change invalid bridge log level from error to warn (#24005)
Summary:
I encountered invalid bridge error when I develop (reload high frequency) some times, and if it happened, I only can restart the app, because we would always show error invalid message if we trigger reload command. So I recommend Change invalid bridge log level from error to warn, I think it's enough.

cc. cpojer .

<img width="375" alt="892C97F4-E910-4E3B-935A-65C899916E6E" src="https://user-images.githubusercontent.com/5061845/54538344-0d32c600-49cf-11e9-818c-0e4cb5a0a518.png">

[iOS] [Fixed] - Change invalid bridge log level from error to warn
Pull Request resolved: https://github.com/facebook/react-native/pull/24005

Differential Revision: D14504820

Pulled By: cpojer

fbshipit-source-id: f24c4876fdb3e64183c09c5ddc598a8c87e405a7
2019-03-18 10:48:59 -07:00
Kevin Gozali 17082d92cf NativeModules iOS: downgrade duplicated module message to warning instead of error
Summary: [iOS] [Changed] - There seems to be a potential race condition during reloading that could cause "double registration" of modules. This should be mostly harmless, so downgrade to warning for the message instead of redboxing.

Reviewed By: cpojer

Differential Revision: D14179922

fbshipit-source-id: 5c16ac674f633a548353277d9f875544ed10ba9b
2019-02-21 20:10:30 -08:00
Eric Lewis b0c69aba1d Allow compiler optimization (#23536)
Summary:
Fixes a warning thrown by Xcode & allow RVO to be performed.

[iOS] [Fixed] - Fix Xcode warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/23536

Reviewed By: JoshuaGross

Differential Revision: D14142973

Pulled By: hramos

fbshipit-source-id: e23050aed811127a3b4f73aa8a74472e4cc8e98c
2019-02-20 17:29:35 -08:00
Eric Lewis 19866aee3d Fix 50 xcode warnings (#23553)
Summary:
This PR reduces the number of warnings in React from 68 to 18. Mostly by marking unused variables. RNTester's warnings are more than halved.

[iOS] [Fixed] - Xcode warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/23553

Differential Revision: D14151339

Pulled By: hramos

fbshipit-source-id: 8255330bf910a69a4c03051d91d7b0de3fadf2d1
2019-02-20 10:17:26 -08:00
Kevin Gozali a9dd828c68 Don't attempt to load RCTDevLoadingView lazily
Summary:
There's a very old issue with reload logic: invalidation and resetting up of the bridge could be racing. In this case, we hit a redbox when:
* Chrome debugger is enabled in previous app run, then we launch the app again
* The bridge starts, then immediately reloads itself to connect to Chrome
* On the 2nd setup, the logic to update the green loading bar, with the % indicator for loading off metro, failed to find the DevLoadingView module instance because the bridge is in the middle of invalidating

See https://github.com/facebook/react-native/issues/23235

To test:
Using react-native init from github, do the steps in https://github.com/facebook/react-native/issues/23235, no more redbox. Note that the loading indicator % won't be proper still, but at least it doesn't crash/redbox.

Reviewed By: JoshuaGross

Differential Revision: D14110814

fbshipit-source-id: 835061e50acc6968bffbcc2ddfbe8da79a100df9
2019-02-15 13:31:51 -08:00
Ramanpreet Nara 0ceefb40d5 Enable module lookup in TurboModules
Summary:
NativeModules are instantiated by the bridge. If they choose, they can capture the bridge instance that instantiated them. From within the NativeModule, the bridge can then be used to lookup other NativeModules. TurboModules have no way to do such a lookup.

Both NativeModules and TurboModules need to be able to query for one another. Therefore, we have four cases:
1. NativeModule accesses NativeModule.
2. NativeModule accesses TurboModule.
3. TurboModule accesses NativeModule.
4. TurboModule accesses TurboModule.

In summary, this solution extends the bridge to support querying TurboModules. It also introduces a `RCTTurboModuleLookupDelegate` protocol, which, implemented by `RCTTurboModuleManager`, supports querying TurboModules:
```
protocol RCTTurboModuleLookupDelegate <NSObject>
- (id)moduleForName:(NSString *)moduleName;
- (id)moduleForName:(NSString *)moduleName warnOnLookupFailure:(BOOL)warnOnLookupFailure;
- (BOOL)moduleIsInitialized:(NSString *)moduleName
end
```

If TurboModules want to query other TurboModules, then they need to implement this protocol and synthesize `turboModuleLookupDelegate`:

```
protocol RCTTurboModuleWithLookupCapabilities
property (nonatomic, weak) id<RCTTurboModuleLookupDelegate> turboModuleLookupDelegate;
end
```

NativeModules will continue to use `RCTBridge` to access other NativeModules. Nothing needs to change.

When we attach the bridge to `RCTTurboModuleManager`, we also attach `RCTTurboModuleManager` to the bridge as a `RCTTurboModuleLookupDelegate`. This allows the bridge to query TurboModules, which enables our NativeModules to transparently (i.e: without any NativeModule code modification) query TurboModules.

In an ideal world, all modules would be TurboModules. Until then, we're going to require that TurboModules use the bridge to query for NativeModules or TurboModules.

`RCTTurboModuleManager` keeps a map of all TurboModules that we instantiated. We simply search in this map and return the TurboModule.

This setup allows us to switch NativeModules to TurboModules without compromising their ability to use the bridge to search for other NativeModules (and TurboModules). When we write new TurboModules, we can have them use `RCTTurboModuleLookupDelegate` to do access other TurboModules. Eventually, after we migrate all NativeModules to TurboModules, we can migrate all old callsites to use `RCTTurboModuleLookupDelegate`.

Reviewed By: fkgozali

Differential Revision: D13553186

fbshipit-source-id: 4d0488eef081332c8b70782e1337eccf10717dae
2019-01-31 11:35:05 -08:00
zhongwuzw d55558e138 Fix isBatchActive of RCTCxxBridge (#22785)
Summary:
Seems we lost handler of `isBatchActive` from [RCTBatchedBridge a86171a](a86171a482/React/Base/RCTBatchedBridge.m) to [RCTCxxBridge 5bc7e39](b774820dc2 (diff-a2a67635fffd7b690d14dc17ae563a71)).

Changelog:
----------

[iOS] [fixed] - Fix isBatchActive of RCTCxxBridge
Pull Request resolved: https://github.com/facebook/react-native/pull/22785

Reviewed By: mhorowitz

Differential Revision: D13731897

Pulled By: cpojer

fbshipit-source-id: 8d6b85bcea8fe8997a93b4e1ac8b8007422ca20e
2019-01-21 00:28:48 -08:00
Alexey Lang 27d8824b4b Make JSCExecutorFactory accessible from outside
Summary: I need this to set up QPL hooks in Instagram on iOS (see D13668326).

Reviewed By: mhorowitz

Differential Revision: D13668327

fbshipit-source-id: ee17d29ec0bbf4ef74736b1d7a095f955c0a7cc1
2019-01-16 10:47:44 -08:00
Kevin Gozali 608670ebed iOS: guard against bad RCTModuleData instance
Summary: In some rare race condition (usually involving network request handling vs bridge shutting down), there may be bad access to an RCTModuleData that may have been de-allocated. To prevent crashes, let's guard the access and return nil appropriately.

Reviewed By: yungsters

Differential Revision: D13548755

fbshipit-source-id: b97326524cd9ca70a13d15098a1eaadfc7f1a6a8
2018-12-26 11:11:12 -08:00
Kevin Gozali 2918679479 iOS: ignore extra modules during bridge start up if it's marked for TurboModule
Summary: Currently, bridge delegate can provide extra modules during bridge start up path. For TurboModules, we don't need this mechanism (if we need eager init, it will be done in a different way). So, let's ignore modules marked as RCTTurboModule if they are supplied as "extra native modules".

Reviewed By: axe-fb

Differential Revision: D13383710

fbshipit-source-id: c88d32739be9f66e0daf07ef5465ea6457f8d1c6
2018-12-11 00:00:56 -08:00
Marc Horowitz 99c370959a Don't create the JSCRuntime until createJSExecutor() is called.
Summary:
This avoids an intermittent reentrancy bug in JSC on iOS 11
(https://bugs.webkit.org/show_bug.cgi?id=186827).  It also makes the
code more consistent with android.

Reviewed By: amnn

Differential Revision: D13313265

fbshipit-source-id: f42476b2f660e127ecfc9c72584554817eea1010
2018-12-04 12:01:59 -08:00
Peter Argany 18f3de9dce Allow init of Native Module before bridge is initialized [2/N]
Summary:
This may be controversial.

Right now, RelayPrefetcher is initialized [here](https://fburl.com/p01iunr1), after bridge is initialized. I want to create a FBRelayPrefetcherModule instance eagerly (diff 3 in stack), and then pass that into the bridge module registry. This way, native side gets to use RelayPrefetcher before bridge is init, and JS still accesses the same instance of FBRelayPrefetcherModule.

The only other option is drastically change bridge init, to allow passing in some eagerly initialized instances.

Reviewed By: shergin

Differential Revision: D13164277

fbshipit-source-id: b45111cd68d78820e61e4fca7e54a7e8df32a3f0
2018-11-26 17:28:11 -08:00
Kevin Gozali 39b8fa95a3 iOS TM: Rename RCTJSINativeModule => RCTTurboModule
Summary: Simple codemod to rename RCTJSINativeModule => RCTTurboModule (the protocol) for less confusion.

Reviewed By: PeteTheHeat

Differential Revision: D13054206

fbshipit-source-id: 4829dc69838c623336475ea8ee11be815d79711c
2018-11-14 10:42:04 -08:00
Kevin Gozali d7a0c44590 iOS: add moduleForNameForcedLoad: to lookup modules by name and force load them
Summary:
Some module classes may not be loaded yet, so looking up via classes may not always give the correct instance. This diff added a new lookup method that delegate to the bridge delegate to force load the modules as needed.

The existing moduleForName: method was left untouched because it's solely used by RCTUIManager at the moment.

Reviewed By: dshahidehpour

Differential Revision: D13033876

fbshipit-source-id: 4082fcd68498004f678b4b95adc82b5b134fefdf
2018-11-13 20:11:47 -08:00
Peter Argany 188cbb04ad Reset module registry flag when resetting React Instance
Summary:
D12911108 fixed a UBN race condition by adding a flag for module registry.

This flag was never reset if react instance gets reset, causing an assert to fire in IG.

Reviewed By: fkgozali

Differential Revision: D13010651

fbshipit-source-id: e20453f3c546d759a58fd7fb93553f774410905f
2018-11-09 17:14:02 -08:00
Kevin Gozali 80f92adf1f iOS: ignore double registration of lazy modules with chrome attached
Summary: Depending on when Chrome debugger is attached, modules may get double registered. Simply ignore it for this case. The redbox was not a fatal error, which can be dismissed.

Reviewed By: shergin

Differential Revision: D12996107

fbshipit-source-id: 292f63102337077848842ca46b3daed08b1cae12
2018-11-09 11:39:06 -08:00
Dustin Shahidehpour 81b74ec1ed Give eagerly loaded modules precedent over lazily loaded one.
Summary: Before lazily-loading code existed, modules that were already loaded into memory took precedent over modules that were additionally registered. With lazily loading modules, instead of giving eagerly loaded modules precdence, it throws a redbox. This diff fixes that behavior.

Reviewed By: PeteTheHeat

Differential Revision: D12983805

fbshipit-source-id: fe4fcf35d5c2ca6f9f4e3f0d1d8c2ca35468fb1b
2018-11-08 13:57:06 -08:00
Kevin Gozali 1f394fa673 iOS: Attempt to load lazy modules when asked from native
Summary:
Previously, asking for an instance of NativeModule from the native side gave `nil` if the lazy modules have not been loaded, which is not consistent with the access from JS. This at least attempts to force load the lazy modules when asked from native.

p.s. one asks for a module by doing `[bridge moduleForClass:[FooBar class]]`.

Reviewed By: spredolac

Differential Revision: D12931640

fbshipit-source-id: 15d2dc574067d3386ef921512ce4bc837749dabd
2018-11-07 07:33:39 -08:00
Peter Argany 1c3191992a Added locking around RN bridge cxx module registry to avoid crash
Summary:
D12904277 was my sad, optimistic attempt to fix this crash.

As @[100006577537606:Slobodan] mentioned on T35879909, the real issue is that moduleRegistry is being created (using _moduleDataByID dict) concurrently while we try to append to this dict.

I added locks around these usage of _moduleDataByID.

Reviewed By: fkgozali

Differential Revision: D12911108

fbshipit-source-id: 2435b7a477c27585898f351c4a0d4c1bd4056756
2018-11-02 18:18:50 -07:00
Peter Argany 6770b53f8d Added lock around RN module initialization to fix crash
Summary:
T35879909 is a UBN caused by a race condition in RN initialization. I haven't been able to repro, but the crash logs point to a bad memory access in this method. Another thread must be deallocating something concurrently.

This is a quick fix to patch into v197.

Reviewed By: fkgozali

Differential Revision: D12904277

fbshipit-source-id: 5740183f9a7c8f2c45ca627662891cb0c1048764
2018-11-02 11:29:18 -07:00
Kevin Gozali 04ea9762e2 iOS: register lazy nativemodules on startup when Chrome is attached
Summary:
@public
This allows apps to specify custom lazy modules that they need to load during chrome debugging. This is because lazy modules won't be available on start up, hence these modules will be missing in JS land, causing problems.

Reviewed By: shergin

Differential Revision: D12899408

fbshipit-source-id: dca313648e994b22e3ee5afec856ef76470065f9
2018-11-02 00:16:16 -07:00
Valentin Shergin 8f04699c4c Fabric: New UIManager registration process (beginning)
Summary:
This diff introduces a new integration concept (called RuntimeExecutor) which consolidates `Runtime` and the dispatching mechanism.
As simple as that:
`using RuntimeExecutor = std::function<void(std::function<void(facebook::jsi::Runtime &runtime)> &&callback)>;`

Reviewed By: fkgozali

Differential Revision: D12816746

fbshipit-source-id: 9e27ef16b98af861d494fe50c7e50bd0536e6aaf
2018-10-29 13:06:24 -07:00
Slobodan Predolac dbc864c9cd Relax the requirement that lazy module cannot be initialized on the main thread
Summary:
[RN] Relax the requirement that lazy module cannot be initialized on the main thread
I tried to understand the D5364734 that intoduced this, and I am not sure, but belive that asserting here is too strict. If you have a module that you want to lazily initialize, and module does not demand the main queue, it should be just a warning if you run on the main queue, not necessarily an error.

Reviewed By: mmmulani

Differential Revision: D10429880

fbshipit-source-id: 018c211d45b98dd8c552bf0289fe517d05e56d47
2018-10-18 15:26:27 -07:00
Marc Horowitz e8cbc4f893 iOS files removed for switch to JSI
Summary:
JSI+JSCRuntime replaces direct use of JSC.  This is like the previous
diff, except for iOS.

Reviewed By: RSNara

Differential Revision: D9369108

fbshipit-source-id: 4ed2c0d660ba2a30edf699d95278c72cabcc9203
2018-10-18 01:06:24 -07:00
Marc Horowitz c49d3653ef iOS changes to switch to JSI
Summary:
change RCTCxxBridge to use JSIExecutorFactory+JSCRuntime
instead of JSCExecutorFactory.  Also remove JSC usage from RN in other
files.  This allows deleting files, too, which is done further down
the stack.

Reviewed By: RSNara

Differential Revision: D9369111

fbshipit-source-id: 67ef3146e3abe5244b6cf3249a0268598f91b277
2018-10-18 01:06:24 -07:00
Alexey Lang 1fc8a46570 Bump up the buffer size and show a warning if the trace might be truncated
Summary: The current buffer size isn't enough even to capture a short TTI trace.

Reviewed By: mhorowitz

Differential Revision: D10112538

fbshipit-source-id: 266fa6ffa916049245b21d7725a364d75589c776
2018-10-02 05:48:00 -07:00
Sergei Dryganets d1ff0b0cc5 Debug only code were leaking into release builds on iOS. (#21232)
Summary:
RCT_DEBUG is always defined - it is just rather 0 or 1 so
```#ifndef RCT_DEBUG is always true```
Pull Request resolved: https://github.com/facebook/react-native/pull/21232

Differential Revision: D9982316

Pulled By: hramos

fbshipit-source-id: 5408bfcf95a6ed2beae38217a6ad1ee43950857d
2018-09-20 17:47:52 -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
Kevin Gozali 6052e97ba7 Added RCTJSINativeModule protocol to allow enabling JSI-bound nativemodule
Summary:
Instead of asking existing modules to implement `+allowJSIBinding`, introduce a temporary "empty" protocol so modules can just adopt it for migration purpose.

Eventually this protocol may just go away.

Modules need to adopt both `RCTBridgeModule` and `RCTJSINativeModule` for time being for backward compatibility.

p.s. the entire system isn't enabled yet, this is just some of the pre-reqs for NativeModule improvements.

Reviewed By: mmmulani

Differential Revision: D9762913

fbshipit-source-id: 470f640f11a5991e5cfa9c48a1931da660ebfcd2
2018-09-11 12:17:26 -07:00
Kevin Gozali 6a1f48e06d TM iOS: rollout strategy 1 - added RCTEnableJSINativeModule(BOOL)
Summary:
To be able to test out new approach for NativeModules, introduce a simple runtime flag to enable the new system (doesn't exist yet). In addition, each module should declare a static `+ (BOOL)allowJSIBinding` in the objc class to be considered for the new approach. Doing so skips the processing of the module during bridge startup.

Note: this doesn't do anything special for `- (NSArray *)extraModulesForBridge:(RCTBridge *)bridge` impl yet.

Differential Revision: D9554296

fbshipit-source-id: 3508db6589e9f72367f62aa7ca15fce3d3adda72
2018-08-29 15:48:59 -07:00
Jeff Thomas 5c160e5ded Way to register RCT_MODULE in Plugin2.0 instead of +load
Summary:
[RFC] WIP: Way to register RCT_MODULE in Plugin2.0 instead of +load

This seemed like the simplest way to do this to register in the existing
didNotFindModule callback so that we don't have to touch any opensource code.

NOTE: The new version of this fixes the problems with dylibs, but not the -ObjC flag removal. This seems like the right call to avoid users having to implement c-functions to return their classes; instead we used objc_getClass.

Reviewed By: dshahidehpour

Differential Revision: D9112719

fbshipit-source-id: cf8df97d7c443cafa0e06a1e61bdf2612944ed87
2018-08-18 10:01:57 -07:00
Alex Dvornikov 1cd9aa2dea Add REGISTER_JS_SEGMENT perf markers
Reviewed By: cwdick

Differential Revision: D9244289

fbshipit-source-id: 9004a0405f9622cbd0bbb837b99df32454f35bb8
2018-08-10 09:37:42 -07:00
Mehdi Mulani 3d8b83927b Use module copies in RCTBridge APIs
Summary: This array can be modified while it's being iterated, so we need to take a copy. I also found another crash and guarded against it.

Reviewed By: fkgozali

Differential Revision: D8955708

fbshipit-source-id: 76250bc5d451776e74505733c0f3c14e555fb576
2018-07-23 14:47:45 -07:00
Kevin Gozali 7b9b1559a7 iOS: Avoid double reload event when reloading JS
Summary:
@public
The bridge may send the reload event twice when reloading JS in some rare condition. The 2nd one was actually when the "new" bridge wasn't valid yet, so log an error if that happens. This may happen if the connection to Metro server gets into a weird state. Restarting Metro would solve the problem.

The issue was that `RCTBridgeWillReloadNotification` fired twice for each reload with metro connected.

Reviewed By: mmmulani

Differential Revision: D8509448

fbshipit-source-id: 647fb98c0a97503409a10451b8f152145947ae20
2018-06-19 18:47:41 -07:00
Kevin Gozali 2ca4770011 fabric: send events via JS thread
Summary: Calling the event emitters on the main thread seems to be problematic, so let's dispatch it via the JS thread. This requires some changes to make "eventTarget" single-use because otherwise the binding would need to synchronize the actual JS call with the act of releasing the target.

Reviewed By: shergin

Differential Revision: D8375291

fbshipit-source-id: bd2b42731176ae209f4a19c232309c163fb1c01b
2018-06-15 11:02:17 -07:00
Héctor Ramos da7873563b Migrate Android sources to MIT license header
Reviewed By: fkgozali

Differential Revision: D8065619

fbshipit-source-id: 719c303b40c96950bab8e5dde9a75f449b2956c6
2018-05-31 15:37:30 -07:00
Dmitry Zakharov 7c5845a5a2 Remove Native Extensions
Reviewed By: michalgr

Differential Revision: D8057885

fbshipit-source-id: 6af7f7729201d26a704adaadb15813979cd035f8
2018-05-21 12:21:56 -07:00
Marc Horowitz a363a7b501 Refactor ReactMarker out of Platform
Reviewed By: fromcelticpark

Differential Revision: D7803908

fbshipit-source-id: 957e80519c209732b163ece2bccb7c8c36ff8107
2018-05-09 22:12:03 -07:00
Dmitry Zakharov b5f90ed497 Update ModuleRegistry if there're new modules registered
Reviewed By: fkgozali

Differential Revision: D7638394

fbshipit-source-id: c1690da7977f0335bc661df5f19dc9f473150d41
2018-04-17 08:32:15 -07:00
David Aurelio edd22bf49d Log bridge description for e2e reloads
Reviewed By: mhorowitz

Differential Revision: D7577953

fbshipit-source-id: 96871c664cb7ec84570bc76f2edb36ff8c8c6aeb
2018-04-10 19:29:58 -07:00
Frederic Barthelemy 75a735976d RCTObjcExecutor: fix initializer-list initialization order build warning.
Summary:
Fixes: #18384

Previously line 42 had a warning of: `Field 'm_jsThread' will be initialized after field 'm_delegate'`

This appears to be because the private member fields are declared in a different order than the initializer-list was told to initialize things.

I chose to re-order the initializer list because that fixes the warning by matching the code structure to what the compiler was telling us it was going to do.

An alternate fix would be to change the order of the member variables declared in the `private:` section to match the coded order in the initializer list. This might be the right move if the initializer list had the correct intent, but this would be a breaking change from a behavior perspective, so I'd need somebody with more knowledge to suggest this is the right move.

A. Examine line to see the warning is gone.
B. Get a C++ guru to figure out the intent of this file and see if this actually exposed a bug that recommends we go with the alternate fix suggested above.

[IOS][MINOR][React/CxxBridge/] - Build warning fix

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Closes https://github.com/facebook/react-native/pull/18385

Differential Revision: D7328272

Pulled By: mhorowitz

fbshipit-source-id: 59d7ace6222c4609ac7d023f97e522e85e02a9db
2018-03-19 15:51:59 -07:00
David Aurelio 48c339ddc7 Add `RCTJavaScriptWillStartExecutingNotification`
Summary:
`RCTJavaScriptWillStartLoadingNotification` is being posted when starting the bridge, not when starting to execute JS code.

Here, we add `RCTJavaScriptWillStartExecutingNotification`, and in post it before executing JS with `RCTCxxBridge`.

Reviewed By: fromcelticpark

Differential Revision: D7153659

fbshipit-source-id: 902075308d54a47bef43b6f57edf2e624f621ceb
2018-03-06 11:05:25 -08:00
Dan Zimmerman 19a4a7d3cb Remove callFunctionSync experimental APIs
Reviewed By: michalgr

Differential Revision: D6124038

fbshipit-source-id: 219afe30783da92cf10f800dc35e64823b61cf4b
2018-03-05 14:32:00 -08:00