Commit Graph

3188 Commits

Author SHA1 Message Date
Oleksandr Melnykov 8cb66e3202 Integrate RCTMap into Fabric on Android
Summary:
This diff integrates RCTMap into Fabric on Android.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18762933

fbshipit-source-id: 6e3e02e0e8101f94fe0c6582e1a63a66fb2f70f9
2019-12-03 09:07:38 -08:00
Ramanpreet Nara 4d9e5f8481 Delete com.facebook.react.modules.debug.NativeSourceCodeSpec
Summary:
When SourceCode was converted to a TurboModule in D17586276, we had to check in `NativeSourceCodeSpec` into the codebase. Since all the OSS NativeModule base classes are now checked into `react-native-github`, it's no longer necessary to keep `NativeSourceCodeSpec`. So, I'm deleting it.

Changelog:
[Android][Removed] - Delete com.facebook.react.modules.debug.NativeSourceCodeSpec

Reviewed By: PeteTheHeat, mdvacca

Differential Revision: D18732997

fbshipit-source-id: 6026b4bcb9ebb9c4d7ba556bc644698eb550a9de
2019-12-03 06:29:58 -08:00
Ramanpreet Nara 7ce8babfef Make ExceptionsManagers extend ReactContextBaseJavaModule
Summary:
Eventually, we want these to extend the abstract base class code-generated from the NativeModule spec. That base class extends `ReactContextBaseJavaModule`. So, this is a step in the right direction.

Changelog:
[Internal] Make ExceptionsManagerModule extend ReactContextBaseJavaModule

Reviewed By: PeteTheHeat, mdvacca

Differential Revision: D18718061

fbshipit-source-id: 70ba5c45b3ef1dd7602e1186763c8bc7ab5d4f42
2019-11-27 16:27:36 -08:00
David Vacca 5ddbd5c54f Add extra logging information in RN Android animation system
Summary:
This diff re-throw and logs exceptions in the animated module of RN Android
Changelog: internal

Reviewed By: JoshuaGross

Differential Revision: D18694124

fbshipit-source-id: bb4cb56dce99f09c56b0bc62733e8264f2df5a3f
2019-11-27 15:56:52 -08:00
David Vacca 4ad852c137 Add extra logging in the Bridge exception handling
Summary:
This diff adds extra logging in the method that handles exceptions for RN Android
Changelog: internal

Reviewed By: JoshuaGross

Differential Revision: D18694123

fbshipit-source-id: e275445b65473ed55eec9d4b823938e32fa805e5
2019-11-27 15:56:52 -08:00
Joshua Gross 7ab5eb4caf AndroidTextInput: support using commands instead of setNativeProps (native change)
Summary:
In AndroidTextInput, support codegen'd ViewCommands in native and add three commands that will eventually replace usage of setNativeProps on Android.

TextInput will use these commands in a future diff.

Changelog: [Internal]

Reviewed By: TheSavior

Differential Revision: D18612150

fbshipit-source-id: 5d427040686e8c5ab504dd845bc8ef863f558c35
2019-11-27 12:55:48 -08:00
Joshua Gross da5ea0215a AndroidTextInput: keep track of mostRecentEventCount in C++ State
Summary:
Keep track of AndroidTextInput's mostRecentEventCount in C++ State.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18672368

fbshipit-source-id: ea7a635629050a6d4957cbcef6ec0bda5faaad9a
2019-11-27 12:55:47 -08:00
Joshua Gross 07580f0f7e AndroidTextInput: support proper measuring of AndroidTextInput text, and displaying attributed strings
Summary:
Use a similar setup as Paragraph, and support in Fabric:

- Correct measuring of AndroidTextInput
- Correct display of AndroidTextInput attributed strings

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18669957

fbshipit-source-id: 84e0ad8021c9edf8219e0c673c781276ca29787d
2019-11-27 12:55:46 -08:00
Ramanpreet Nara e69be0ae55 Give ReactContextBaseJavaModule a 0 arg ctor
Summary:
We need to make our ExceptionsManagers into TurboModules. To do so, we need to first make them type-safe. This requires extending the base class code-generated from the NativeModule JavaScript spec. That base class extends `ReactContextBaseJavaModule`, which requires `ReactApplicationContext` to instantiate. Unfortunatley, our ExceptionsManagers need to be created before the `ReactInstanceManager`. This means that the `ReactApplicationContext` isn't available by the time they're created.

In this diff, I make the `ReactContextBaseJavaModule` have a 0 argument constructor that simply sets its ReactApplicationContext to null. This will allow us to eventually migrate our ExceptionsManagers to the TurboModule system.

Changelog:
[Android][Added] - Give ReactContextBaseJavaModule a 0 arg ctor

Reviewed By: mdvacca

Differential Revision: D18717908

fbshipit-source-id: 203ffc49f2ec0b32a809402801795879d3b3a64b
2019-11-27 10:38:54 -08:00
Sergey Ryabov 1610c08a67 Fix javadocs
Summary: Changelog: [Internal]

Reviewed By: muraziz

Differential Revision: D15538725

fbshipit-source-id: 5cf60f47b07ce355e40d5b064add1df980beed89
2019-11-22 10:10:38 -08:00
Valentin Shergin be324ca2dc Fabric: Adding some logs to Scheduler, UIManager and co
Summary:
We hope that will help us to understand more.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18599164

fbshipit-source-id: 431f83de707fc7113e04abd3dd5b59ee5c9cc675
2019-11-21 16:21:25 -08:00
Ramanpreet Nara 1ad0862363 Revert D16969764: Make RCTDevLoadingView TurboModule-compatible
Differential Revision:
D16969764

Original commit changeset: 47e6682eea3f

fbshipit-source-id: d95b76eb8e57bbaff840b3d85f3745b13d622ce0
2019-11-21 08:43:12 -08:00
David Vacca 9c61693c9e Create ReactFeatureFlag to enable / disable custom implementation of getChildVisibleRect
Summary:
This diff introduces a new ReactFeatureFlag that will be used to enable / disable a custom implementation of getChildVisibleRect in the classes ReactViewGroup, ReactHorizontalScrollView and ReactScrollView.
The new ReactFeatureFlag is disabled by default bevause of T57363204

This is disabling the code landed as part of D17782658 / https://github.com/facebook/react-native/pull/26334

Changelog: Introduce ReactFeatureFlag to disable custom implementation of getChildVisibleRect (disabled by default)
This will disable the custom algorithm created on https://github.com/facebook/react-native/pull/26334

Reviewed By: yungsters

Differential Revision: D18621042

fbshipit-source-id: 35ca3417b596117b47edab29515a824c1726c2ce
2019-11-21 00:09:24 -08:00
Ramanpreet Nara 294e31b7c2 Make RCTDevLoadingView TurboModule-compatible
Summary:
RCTDevLoadingView wasn't hooked up to the codegen. This diff makes RCTDevLoadingView type-safe and also makes it TurboModule-compatible.

Changelog:
[iOS][Added] - Make RCTDevLoadingView TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D16969764

fbshipit-source-id: 47e6682eea3fc49d3f0448c636b5f616d5bce220
2019-11-20 11:20:12 -08:00
Samuel Susla 2d80a248cd Migrate RefreshControl to Native Commands
Summary:
Changelog: [Internal]

Introduce native command `setNativeRefreshing`, it has the word Native in order to avoid name conflict with setRefreshing in Android implementation. Even this component is iOS only, it would make it easier to merge them in the future.

Introduce `RCTRefreshableProtocol` and make `RCTRefreshControl` and `RCTPullToRefreshViewComponentView` to conform to the protocol so view manager can forward command to both, Paper and Fabric component.

Reviewed By: mmmulani

Differential Revision: D18475804

fbshipit-source-id: 4c19225784efc931b7b8f2d2671cc839bce429bf
2019-11-19 10:06:56 -08:00
Emily Janzer 641e9657dd Make ImageLoaderModule TurboModule-compatible
Summary:
Modifying ImageLoaderModule to be TM-compatible by extending the generated abstract class and fixing the conflicting method signatures (int -> double).

Changelog: [Android] [Changed] Changing method signatures for ImageLoaderModule to accept double for requestId

Reviewed By: mdvacca

Differential Revision: D18435628

fbshipit-source-id: bc2a82bda49e339d1feebfe917b0862a1af15a1f
2019-11-18 12:40:31 -08:00
Ramanpreet Nara 29b99720b2 Make TurboModuleRegistry in CatalystInstanceImpl.java volatile
Summary:
We read from / write to `CatalystInstanceImpl.mTurboModuleRegistry` from multiple threads. To ensure that we directly read/write from memory, and not a stale cache, we should make this variable `volatile`.

Changelog:
[Android][Fixed] Make TurboModuleRegistry in CatalystInstanceImpl.java volatile

Reviewed By: fkgozali

Differential Revision: D18542954

fbshipit-source-id: 0a47f05e0653b4f7f58503c678bdf31c68eab9bf
2019-11-15 17:31:31 -08:00
David Vacca 8accd77c45 Deprecate CallerContext from ReactImageManager
Summary:
This diff deprecates the constructors and getter method exposing CallerContext in ReactImageManager.
This will be replaced by the ReactCallerContextFactory class

Changelog: Deprecation of constructors and methods that expose CallerContext in ReactImageManager class

Reviewed By: JoshuaGross

Differential Revision: D18474012

fbshipit-source-id: d8190f938e00da0499bfef7e81522dc8022a8836
2019-11-15 17:28:12 -08:00
David Vacca 882e4a3f17 Integrate ReactContextContainerFactory as part of ReactImageViewManager
Summary:
This diff exposes the ReactContextContainerFactory class on ReactImageViewManager and it customize ChainContext to improve Fresco logging

Changelog: Expose new ReactContextContainerFactory class as part of ReactImageViewManager

Reviewed By: JoshuaGross

Differential Revision: D18474013

fbshipit-source-id: 143461da22966694e5b1e2c3b5b39e3d6be91fd6
2019-11-15 17:28:12 -08:00
David Vacca f0b6f8441b Expose SurfaceID as part ReactRootView
Summary:
This diff exposes the surfaceID as part of ReactRootView.

Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D18474014

fbshipit-source-id: 98f651b211d3cc4df88c6b1eb257bc12129eff57
2019-11-15 17:28:12 -08:00
Joshua Gross 76f41a0578 Gate fix for T54997838 with a feature flag
Summary:
Gating fix for T54997838 behind a feature flag for experimentation.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18534767

fbshipit-source-id: 5c0191c454fba6dd4a36d6e179959651ec197cac
2019-11-15 17:01:03 -08:00
Joshua Gross cc6b430c3a Annotate UIManager methods to document thread semantics
Summary:
Document which methods can be called on UI thread or ANY thread.

In the future we should see if we can use only `ThreadConfined` or the AndroidX annotations instead of using both / choosing between them at each site.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18532542

fbshipit-source-id: 3b5406ea5035615a0ebf83484bf8ec0747a6b6f7
2019-11-15 17:01:02 -08:00
David Vacca cddf9eb1da Extending ThemeReactContext to store surfaceID
Summary:
This diff extends ThemeReactContext class to store the surfaceID field

The getSurfaceID method is being exposed as a public method

Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D18474015

fbshipit-source-id: ee1f859a802d36c51dec537fa91d90022523e88d
2019-11-15 09:30:41 -08:00
David Vacca 9713b63d9a Introducing ReactCallerContextFactory interface
Summary:
This interface is used from ReactImageManager to customize the CallerContext object associated with each instance of ReactImageView.
CallerContext are used on Fresco to customize Debug and logs

Changelog: Introduce ReactCallerContextFactory interface, this interface is intended to customize Debug and logging on Fresco

Reviewed By: JoshuaGross

Differential Revision: D18474017

fbshipit-source-id: eda0fc9d3f64bbcc23ee1b7f5d779b441da1fe6c
2019-11-15 09:30:41 -08:00
Joshua Gross ce226c1f28 Fix T54997838
Summary:
Fixes T54997838 by preventing any view mutations during `onMeasure` calls.

There might still be places where this is possible, but this is where I'm seeing all the crashes currently.

See comments in ReactRootView for why views were mutated during onMeasure.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18518591

fbshipit-source-id: 1406af8a6b0bfcc86f4cc5b451b3967f312dfd85
2019-11-14 21:23:32 -08:00
Ramanpreet Nara 7f637139e7 Make sure that ReactFeatureFlags.useTurboModules is read from memory
Summary:
`ReactFeatureFlags.useTurboModules` can be written to and read from any number of threads. We should use `volatile` to make sure that all threads read/write this data straight from/to memory.

Changelog:
[Android][Fixed] - Make ReactFeatureFlags.useTurboModules volatile

Reviewed By: fkgozali

Differential Revision: D18505673

fbshipit-source-id: 0b2527b8cb95c1e1aedc6b03b12a6b1e6a6cdaa4
2019-11-14 11:03:59 -08:00
Sidharth Guglani f0f83eb3b1 Remove useVanillaJNI flag and usage of fbjni in yoga build
Summary:
## Changelog:

[General] [Yoga] - Use vanilla jni instead of fbjni for all the jni communication

Reviewed By: astreet

Differential Revision: D17808005

fbshipit-source-id: 5e9a1ed73978f519c71c248774a28e5a294e7c7f
2019-11-13 15:16:47 -08:00
Oleksandr Melnykov c5c3264a94 Add setNativeRefreshing command to SwipeRefreshLayoutManager
Summary:
As a part of the migration from `setNativeProps` in Fabric and Paper, we are replacing it by view commands in the RefreshControl component on Android.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18475428

fbshipit-source-id: f2e978d88e34c74771f8582247ecc82b2b942557
2019-11-13 10:21:04 -08:00
Oleksandr Melnykov cd1e34d4a2 Add setNativeValue command to ReactCheckBoxManager
Summary:
As a part of the migration from `setNativeProps` in Fabric and Paper, we are replacing it by view commands in the Checkbox component on Android.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18451524

fbshipit-source-id: 566f3574b85a1ae97f78b2fb95548b8529c0c92f
2019-11-13 10:15:50 -08:00
Oleksandr Melnykov bca8fa5a16 Use generated Java delegate for setting properties on ReactViewPagerManager
Summary:
This diff migrates ReactViewPagerManager to use the generated delegate for setting its properties.

Changelog: [Android] [Added] - Use generated Java delegate for setting properties on ReactViewPagerManager

Reviewed By: mdvacca

Differential Revision: D18298049

fbshipit-source-id: f989bedb16e3cabe6a9a8e4238a2b74515041d23
2019-11-12 05:41:28 -08:00
Marc Horowitz 61cb2686a2 Update hermes-engine to newest version 0.3.0
Summary:
Changelog:

[Android] [Changed] - Update hermes-engine to newest version 0.3.0

Reviewed By: cpojer

Differential Revision: D18364012

fbshipit-source-id: 819f7f7980f4bc965c8875eef70ee0108882f922
2019-11-11 18:38:01 -08:00
Emily Janzer d37baa78f1 Split JS spec for image loader module
Summary:
It turns out the ImageLoader native module has different method signatures on iOS than on Android, so the JS spec we currently have won't work for ANdroid. In this diff I'm splitting up the spec for NativeImageLoader into an Android & iOS versions (similar to PlatformConstants), and updating the Android spec to match the native implementation. I'm also changing `RCTImageLoader` to use the new generated spec, and updating the JS callers (`Image.android.js` and `Image.ios.js`) to use the right one for the platform (instead of importing the untyped `ImageLoader` native module from `react-native`, like we were on Android :-/).

This will be a breaking change for anyone who's directly using `NativeImageLoader.js`, but I think most callsites should be using the `Image` component instead.

Changelog: [General] [Changed] Split NativeImageLoader into NativeImageLoaderAndroid and NativeImageLoaderIOS

Reviewed By: RSNara

Differential Revision: D18439538

fbshipit-source-id: 94c796d3fd27800ea17053e963bee51aca921718
2019-11-11 17:24:25 -08:00
David Vacca 0284a73042 Update type for tag in Android mounting layer
Summary:
Easy replace of int -> Tag type in Binding

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D18429188

fbshipit-source-id: 08a19dff60bd90585f59a284be0e46ee7f381bcc
2019-11-11 12:36:05 -08:00
Oleksandr Melnykov a62a685b14 Add setNativeSelectedPosition command to ReactPickerManager
Summary:
Fabric doesn't support setNativeProps, so we have to use commands instead to set the value of the native component.

Changelog: [Android] [Added] - Add setNativeSelectedPosition command to ReactPickerManager

Reviewed By: mdvacca

Differential Revision: D18007791

fbshipit-source-id: dfa26792205189a336ab43b1c51f43f8f57c8e72
2019-11-11 12:32:51 -08:00
David Vacca a20939f49d Fix Collapsing of mutation instructions
Summary:
This diff fixes the algorithm that collapses mutation instructions in Fabric Android
The problem was that we were always relying on the fact that the oldShadowNode is present as part of the mutation instruction (which is not correct for mutation instructions of type CREATE)

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D18411360

fbshipit-source-id: 36f5e75f792db87003fcaef2ddcd9452415a0ad6
2019-11-09 10:38:25 -08:00
David Vacca f7385ac1b8 Setup collapsing of mounting instructions as disabled by default
Summary:
This diff updates the configuration of collapsing of mounting instructions to be disabled by default (in case the user didn't get any value from the server)

Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D18411934

fbshipit-source-id: 21f9ca525c28134800e929407c5a1e29a84de68e
2019-11-08 18:48:50 -08:00
Ramanpreet Nara d73ae1baa3 Make RCTWebSocketModule TurboModule-compatible
Summary:
Changelog:
[iOS][Added] - Make RCTWebSocketModule TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18353766

fbshipit-source-id: fde0f6593dd203ab3dcb8f9cf40012ba4761d6ba
2019-11-08 14:14:46 -08:00
David Vacca 2d40369237 Disable collapsing of mounting instructions
Summary:
Disable collapsing of mounting instructions

Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D18387365

fbshipit-source-id: dbb6325297ef73d902fbe519726accd40a78b559
2019-11-07 18:26:27 -08:00
Valentin Shergin 9883da167b Fabric: Removing RuntimeExecutor from EventBeatManager
Summary:
This diff changes the implementation a little bit:
* We don't use RuntimeExecutor there anymore (because it's already been used in EventBeat). The actual purpose of EventBeatManager was distilled to "provide a tick synchronized with the main run loop";
* Now we use dedicated EventBeatManagerObserver interface to decouple this functionality from EventBeat-intrinsic functionality;
* A bunch of small clean-ups.
* Now we ensure threading and capturing ownership in a single function in AsyncEventBeat class. Before this change, the EventBeatManager called `beat` function of the EventBeat directly bypassing AsyncEventBeat class, and effectively bypassing the check that underlying infra still exists (aka EventBeat::OwnerBox feature). That alone might fix some C++ crashes that we see.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18307655

fbshipit-source-id: 3b582cb71085ed99ee94f8e6d575196c2082557b
2019-11-07 09:43:07 -08:00
Valentin Shergin 68782d2239 Fabric: Removing unnecessary code from EventBeatManager
Summary:
* We no more pollute the global namespace with JSI stuff;
* We don't use JSI here, so why to include;
* We don't use `Instance`, so why to forward-declare this;

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross, sammy-SC

Differential Revision: D18307654

fbshipit-source-id: b6c3ad55d7bd605074db9fa1d4bc58a73e0b2d74
2019-11-07 09:43:06 -08:00
Valentin Shergin 50b171ff8b Fabric: Removing scheduling to JS thread from EventBeatManager.java
Summary:
The C++ counterpart of EventBeatManager uses RuntimeExecutor for that, so it's redundant to do that in EventBeatManager.java.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18307657

fbshipit-source-id: 65823b25d691a56540247d317e3c0e86685150c8
2019-11-07 09:43:06 -08:00
Joshua Gross b7c2d4389a Guard against result of getUIManager(...) being null
Summary:
`getUIManagerX(...)` can return null now. Guard in a few places that use it or add comments.

Changelog: [Internal]

Reviewed By: alexeylang

Differential Revision: D18351197

fbshipit-source-id: f077835468a75d1af24cfb4210989ba875ff9086
2019-11-06 12:14:09 -08:00
Oleksandr Melnykov e99b926d27 Use generated Java delegate for setting properties on ReactDialogPickerManager and ReactDropdownPickerManager
Summary:
This diff migrates ReactDialogPickerManager and ReactDropdownPickerManager to use the generated delegates for setting their properties.

Changelog:
[Android] [Added] - Use generated Java delegate for setting properties on ReactDialogPickerManager and ReactDropdownPickerManager

Reviewed By: mdvacca

Differential Revision: D17930994

fbshipit-source-id: 009ad9eceb683b7170eddeccfd986b1dc5cb8c0b
2019-11-06 05:23:45 -08:00
Emily Janzer 6598292ede Add a field + getter for instanceKey to ReactContext
Summary:
Adding a new String field for `instanceKey` to ReactContext, which is set via a new constructor on ReactApplicationContext. Also adding getters to ReactContext and ThemedReactContext so that it's accessible from any instance/subclass of ReactContext.

This will only be used in bridgeless mode.

Reviewed By: mdvacca

Differential Revision: D18316556

fbshipit-source-id: 9757da72fde4ba36034c1e129326461fed496229
2019-11-05 19:01:53 -08:00
Joshua Gross f77abc583c Add UI asserts and logs to a few more places
Summary:
Add UI asserts to ensure thread safety of some operations.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18339981

fbshipit-source-id: 9162b6351f40bdd543d3e255691e9f54d1934589
2019-11-05 18:20:01 -08:00
Joshua Gross b1b97b8b45 UiThreadUtil.assertX should only throw in DEBUG mode
Summary:
Turns out that `SoftAssertions.java` has always been a lie - it actually always throws exceptions. Migrate it to using `ReactSoftException`.

This file hasn't been touched at all since it was originally open-sourced, besides codemods!

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18336020

fbshipit-source-id: cba3db25a9f9d61325dd3f7843e92e984ae56281
2019-11-05 15:36:29 -08:00
David Vacca e885ddedb9 Fix crash when using TextInput.FontVariant prop in Android API level < 26
Summary:
This diff fixes a crash when using TextInput.FontVariant prop in Android API level < 26

Changelog: Fix TextInput.FontVariant prop in Android API level < 26 (related to PR https://github.com/facebook/react-native/pull/27006)

Reviewed By: JoshuaGross

Differential Revision: D18331807

fbshipit-source-id: 5eac4d9e38eb099fae1287d128f3f8c249b0b8bc
2019-11-05 14:40:19 -08:00
Joshua Gross a7f56e73e4 Add UI-Thread assertions in methods that mutate Views
Summary:
As part of `T54997838` we're auditing where removeView could possibly be called in a background thread, and adding annotations to indicate places where we don't think it's possible.

Changelog: [internal]

Reviewed By: makovkastar

Differential Revision: D18320461

fbshipit-source-id: 84b6b9e293d903f835fc42bc98614efb54158986
2019-11-05 13:18:59 -08:00
David Vacca 3281714312 Ensure that ReactInstanceManager is still alive when animation system updates views in Fabric
Summary:
This diff ensures that ReactInstanceManager has a valid catalystInstance when updating views as part of the animation system.
This also force the update of views to be posted in the UI Thread

Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D18311782

fbshipit-source-id: 1f1e7b0d34346f34b3607e5b75e5c14cda3f4861
2019-11-05 12:33:07 -08:00
Vincent Cheung 1df8bd4932 Fix multiple set-cookie not aggregated correctly in response headers (#27066)
Summary:
Multiple `set-cookie` headers should be aggregated as one `set-cookie` with values in a comma separated list. It is working as expected on iOS but not on Android. On Android, only the last one is preserved

The problem arises because `NetworkingModule.translateHeaders()` uses `WritableNativeMap` as the translated headers but uses both native and non-native methods. The mixup causes out of sync data that both sets of methods do no agree. A simple fix is to use `Bundle` as the storage and only convert it to `WritableMap` at the end in one go

Related issues: https://github.com/facebook/react-native/issues/26280, https://github.com/facebook/react-native/issues/21795, https://github.com/facebook/react-native/issues/23185

## Changelog

[Android] [Fixed] - Fix multiple headers of the same name (e.g. `set-cookie`) not aggregated correctly
Pull Request resolved: https://github.com/facebook/react-native/pull/27066

Test Plan:
A mock api, https://demo6524373.mockable.io/, will return 2 `set-cookie` as follows:
```
set-cookie: cookie1=value1
set-cookie: cookie2=value2
```

Verify the following will print the `set-cookie` with a value `cookie1=value1, cookie2=value2`
```javascript
  fetch('https://demo6524373.mockable.io/')
    .then(response => {
      console.log(response.headers);
    });
```
On iOS, `set-cookie` will have `cookie1=value1, cookie2=value2` while on Android it will have `cookie2=value2` (preserving only the last one)

Differential Revision: D18298933

Pulled By: cpojer

fbshipit-source-id: ce53cd41d7c6de0469700617900f30a7d0914c26
2019-11-05 03:30:02 -08:00