Commit Graph

186 Commits

Author SHA1 Message Date
Jakub Šimo 82f3964f2d Change Promise.done to Promise.then
Summary:
- [X] Explain the **motivation** for making this change.
- [X] Provide a **test plan** demonstrating that the code is solid.
- [X] Match the **code formatting** of the rest of the codebase.
- [X] Target the `master` branch, NOT a "stable" branch.

`Promise.done` is non-standard, `Promise.then` is preferred as a standardized method. On Android, polyfill filling in `Promise.done` has been most probably taken out in newer versions of `react-native` and app crashes when it tries to query network state through `NetInfo`.

No tests are required for this change.
Closes https://github.com/facebook/react-native/pull/13489

Differential Revision: D4897566

Pulled By: mkonicek

fbshipit-source-id: 140720d7367cd1d9bf8924ec8a118c1bff4e461d
2017-04-16 15:30:46 -07:00
Adam Comella e544563bd2 BREAKING: Android: Support withCredentials flag in XHRs
Summary:
Corresponding iOS PR: #12275

Respect the withCredentials XMLHttpRequest flag for sending cookies with requests. This can reduce payload sizes where large cookies are set for domains.

This should fix #5347.

This is a breaking change because it alters the default behavior of XHR. Prior to this change, XHR would send cookies by default. After this change, by default, XHR does not send cookies which is consistent with the default behavior of XHR on web for cross-site requests. Developers can restore the previous behavior by passing `true` for XHR's `withCredentials` argument.

**Test plan (required)**

Verified in a test app that XHR works properly when specifying `withCredentials` as `true`, `false`, and `undefined`. Also, my team uses this change in our app.

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

Differential Revision: D4673646

Pulled By: ericvicenti

fbshipit-source-id: 924c230c9df72071b3cf9151c3ac201905ac28a5
2017-04-10 22:46:12 -07:00
Pieter De Baets 7c9173bc9e Enable -Wimplicit-retain-self en sync warning config for all projects
Summary:
This is enforced for all of our internal iOS code and a common cause of import failures.

cc janicduplessis
Closes https://github.com/facebook/react-native/pull/13124

Differential Revision: D4765016

fbshipit-source-id: 7c8248c98bca0fa6bad24d5a52b666243375e0db
2017-03-23 15:01:34 -07:00
Adam Comella 454ab8fc23 BREAKING: iOS: Support withCredentials flag in XHRs
Summary:
Corresponding Android PR: #12276

Respect the withCredentials XMLHttpRequest flag for sending cookies with requests. This can reduce payload sizes where large cookies are set for domains.

This should fix #5347.

This is a breaking change because it alters the default behavior of XHR. Prior to this change, XHR would send cookies by default. After this change, by default, XHR does not send cookies which is consistent with the default behavior of XHR on web for cross-site requests. Developers can restore the previous behavior by passing `true` for XHR's `withCredentials` argument.

**Test plan (required)**

Verified in a test app that XHR works properly when specifying `withCredentials` as `true`, `false`, and `undefined`. Also, my team uses this change in our app.

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

Differential Revision: D4673644

Pulled By: mkonicek

fbshipit-source-id: 2fd8f536d02fb39d872eb849584c5c4f7e7698c5
2017-03-08 06:15:15 -08:00
Adam Comella 36f09dc252 Add onabort to XHR classes
Summary:
04d870b added support for onabort in XHRs. The other on* events are declared on XMLHttpRequest and XMLHttpRequestEventTarget. This adds onabort there as well.

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

Differential Revision: D4673648

Pulled By: mkonicek

fbshipit-source-id: 0c5255da77537103c5ad91d9b2826d064140708d
2017-03-08 05:59:41 -08:00
Pieter De Baets 7d51580479 Use weakSelf in RCTNetworking callbacks
Reviewed By: shergin

Differential Revision: D4551000

fbshipit-source-id: fcfce41adb8fd76343b973339ffe1cac0bf8a756
2017-02-13 12:29:58 -08:00
Matthew Oaxaca 34edf92cbf Network/FormData typeof object allowing null
Summary:
Submitting PR in response to https://github.com/facebook/react-native/issues/12251

**Test plan (required)**

$formData = new FormData()
$formData.append('value', null)

Included Unit Tests
Closes https://github.com/facebook/react-native/pull/12253

Differential Revision: D4545291

Pulled By: lacker

fbshipit-source-id: 2780f24e1fe1e0d5be3bb12b64aa6cd9a20554bf
2017-02-10 13:30:48 -08:00
rh389 7a4166c31d Deal with 0.38 'FlowFixMe's
Summary:
Largely typing fixes to deal with the glut of new `FlowFixMe` suppressions introduced with flow 0.38 in a4bfac907e

Tested with flow itself. CC gabelevi
Closes https://github.com/facebook/react-native/pull/11985

Differential Revision: D4452045

Pulled By: ericvicenti

fbshipit-source-id: acc46c4c406ae706a679e396be1d40ae2f4ce5a1
2017-01-31 13:13:32 -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
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
unordered 8ec774396c fix ios formdata boundary include slash
Summary:
some server not work when upload a file with FromData in ios.
the reason is that there is a slash in boundary, like:
```
multipart/form-data; boundary=b/QeEbFgqK9PCZo4T/eXv7f.T74SHd5MxCZ846AsTz-yNV0xrRR_Zks4fkNMCzJck9ZE8o

// koa request.js (line 548)
  is(types) {
    if (!types) return typeis(this.req);
    if (!Array.isArray(types)) types = [].slice.call(arguments);
    return typeis(this.req, types);
  }

// type-is index.js (line 237)
function normalizeType (value) {
  // parse the type
  var type = typer.parse(value)

  // remove the parameters
  type.parameters = undefined

  // reformat it
  return typer.format(type)
}

// media-typer
var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u0020-\u007e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g;
```

thanks for dougwilson 's [answer](https://github.com/jshttp/media-typer/issues/5).
> The / is an illegal character for Content-Type, which is what this module parses
Closes https://github.com/facebook/react-native/pull/11342

Differential Revision: D4326750

Pulled By: javache

fbshipit-source-id: b1c78a335c95a5c223537545d87beaffe15d673d
2016-12-14 08:28:42 -08:00
Pieter De Baets 59407f3660 Redo exported headers and include paths for opensource
Summary:
Xcode really sucks, per some discussion on e1577df1fd and https://developer.apple.com/library/content/technotes/tn2215/_index.html, if you use the headers phase, and mark headers in your static library as public, they will actually end up in the final package that's built and you can't submit to the app store! This changes our xcode setup to use a copy files phase instead.

I've also changed the header include path to be $(BUILT_PRODUCTS_DIR)/include, which is added to the include path by Xcode by default, so 3rd party libraries should not be impacted by these changes anymore.

Reviewed By: mkonicek

Differential Revision: D4291607

fbshipit-source-id: 969b9ebcbeb8161f85427f8c429e198d9d0fae30
2016-12-07 15:28:29 -08:00
Gabe Levi bf901d926e Deploy v0.36.0
Reviewed By: zertosh

Differential Revision: D4237912

fbshipit-source-id: cc251884350ffa3c8715a4920f90bd301e8a9b7f
2016-11-28 10:13:31 -08:00
Pieter De Baets e1577df1fd Move all header imports to "<React/..>"
Summary:
To make React Native play nicely with our internal build infrastructure we need to properly namespace all of our header includes.

Where previously you could do `#import "RCTBridge.h"`, you must now write this as `#import <React/RCTBridge.h>`. If your xcode project still has a custom header include path, both variants will likely continue to work, but for new projects, we're defaulting the header include path to `$(BUILT_PRODUCTS_DIR)/usr/local/include`, where the React and CSSLayout targets will copy a subset of headers too. To make Xcode copy headers phase work properly, you may need to add React as an explicit dependency to your app's scheme and disable "parallelize build".

Reviewed By: mmmulani

Differential Revision: D4213120

fbshipit-source-id: 84a32a4b250c27699e6795f43584f13d594a9a82
2016-11-23 07:58:39 -08:00
Pieter De Baets 7c91f894ba Fix CSSLayout import hack, update podspec
Summary: Correct header import paths, update podspec so we point at the copy in ReactCommon (and can eventually remove the copy under React)

Reviewed By: astreet

Differential Revision: D4204501

fbshipit-source-id: e979a010092f025b2cdc289e1e5f22fc7b65a8d1
2016-11-21 09:13:36 -08:00
Saleeh 27ae04cabd Fixed #7564
Summary:
Fix for some firewall with ModSecurity
 rules for MULTIPART_STRICT_ERROR, namely MULTIPART_BOUNDARY_QUOTED.
Closes https://github.com/facebook/react-native/pull/10876

Reviewed By: javache

Differential Revision: D4176229

Pulled By: ericvicenti

fbshipit-source-id: 8db819bd3e9b23fa3c1802c48091bb4c44358381
2016-11-15 08:44:30 -08:00
Jeff Morrison bd3be5bd24 Update fbsource
Reviewed By: zertosh

Differential Revision: D4111832

fbshipit-source-id: 301969a1c828fb87e7e09c1eea3cd44799b89509
2016-11-08 12:43:48 -08:00
Alexander Blom 1709043a12 Add Network agent
Summary: Adds methods in XMLHttpRequest so that the agent can hook the events needed for the implementation, these are only enabled if the agent is enabled (which means that the inspector is connected), it is also stripped out in non-dev currently.

Reviewed By: davidaurelio

Differential Revision: D4021516

fbshipit-source-id: c0c00d588404012d20b744de74e5ecbe5c002a53
2016-11-02 12:29:15 -07:00
Leo Natan 3ac3749ac3 Fix for Unicode decoding issue when using incremental networking.
Summary:
This is **a critical issue**.

The issue arises when incremental networking is enabled from JS by setting `onprogress` or `onload` on an `XMLHttpRequest` object.

The results:

![example1](https://cloud.githubusercontent.com/assets/2270433/18829964/5a54ff30-83e7-11e6-9806-97857dce0430.png)

![example2](https://cloud.githubusercontent.com/assets/2270433/18829966/5bf40a66-83e7-11e6-84e6-9e4d76ba4f8b.png)

Unicode characters get corrupted seemingly in random. The issue is from the way Unicode character parsing is handled in `RCTNetworking.mm`. When incremental networking is enabled, each chunk of data is decoded and passed to JS:

```objective-c
incrementalDataBlock = ^(NSData *data, int64_t progress, int64_t total) {
NSString *responseString = [RCTNetworking decodeTextData:data fromResponse:task.response];
if (!responseString) {
  RCTLogWarn(@"Received data was not a string, or was not a recognised encoding.");
  return;
}
NSArray<id> *responseJSON = @[task.requestID, responseString, @(prog
Closes https://github.com/facebook/react-native/pull/10110

Reviewed By: yungsters

Differential Revision: D4101533

Pulled By: fkgozali

fbshipit-source-id: 2674eaf0dd4568889070c6cde5cdf12edc5be521
2016-10-31 13:13:38 -07:00
leeight f9e36a08a8 Make sure xhr req header's value is String type
Summary:
In the `NetworkingModule.java`, `header.getString(1)` was
called, so the value must be String type.

FIX #10198
Closes https://github.com/facebook/react-native/pull/10222

Differential Revision: D4080319

Pulled By: lacker

fbshipit-source-id: 85234a2bbf90e5b9e0e65ceadbfabb330b2d1322
2016-10-25 22:29:35 -07:00
Cristian Carlesso 6a462fb085 Moving the jest configuration from jest-react-native to react native.
Reviewed By: cpojer

Differential Revision: D3923609

fbshipit-source-id: 62804df81b064871b499ae8c091e13dd1e0f229b
2016-10-17 08:44:05 -07:00
Pieter De Baets 8802db3cc0 Update checked-in xcodeproj for RCTHTTPRequestHandler.mm
Reviewed By: majak

Differential Revision: D4009309

fbshipit-source-id: a88021d935a2ac21a220956e77f167c8598eaf1c
2016-10-12 10:58:53 -07:00
Pieter De Baets 4b7f84aee8 Add lock to RCTHTTPRequestHandler
Reviewed By: mmmulani

Differential Revision: D4001762

fbshipit-source-id: 3a388bbeddeb7b5f6923274137abfc5e20d001b1
2016-10-12 08:59:04 -07:00
Pieter De Baets 26be005b0a Cancel network requests from the correct queue
Summary: Fix suggested by sooth-sayer (https://github.com/facebook/react-native/pull/10280)

Reviewed By: mmmulani

Differential Revision: D4001618

fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76
2016-10-11 12:43:40 -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
Douglas Lowder 8622998335 Apple TV support 2: Xcode projects and CI (scripts/objc-test.sh)
Summary:
* Motivation *

Second PR for Apple TV support.

* Test plan *

Apple TV tests have been added to scripts/objc-test.sh
Closes https://github.com/facebook/react-native/pull/10227

Differential Revision: D3974064

Pulled By: javache

fbshipit-source-id: 36dffb4517efa489e40fa713a30655d1d76ef646
2016-10-05 07:28:44 -07:00
Erik Arvidsson 24c72f513e XMLHttpRequest.getAllResponseHeaders should use CRLF
Summary:
XMLHttpRequest.prototype.getAllResponseHeaders was previously joining
the headers with `\n`. The spec at:

https://xhr.spec.whatwg.org/#the-getallresponseheaders()-method

step 3.2, requires the headers to be joined using `\r\n`.
Closes https://github.com/facebook/react-native/pull/10034

Differential Revision: D3917020

fbshipit-source-id: f4e920f6bebacc3aa5c52c84348157d2b530480f
2016-09-23 16:28:56 -07:00
Erik Arvidsson 04d870b10b XMLHttpRequest should dispatch loadend events
Summary:
The code was never dispatching the loadend event. The event should be
dispatched after the load, error, timeout and abort events (abort
events are not yet supported).

https://xhr.spec.whatwg.org/#event-xhr-loadend
Closes https://github.com/facebook/react-native/pull/10047

Differential Revision: D3911080

fbshipit-source-id: 450f50a6f2a5c6845889bce624c64a1ca47ec06b
2016-09-22 17:13:46 -07:00
Adam Comella 9304df3e3d For file uploads, don't stomp on developer's Content-Type header
Summary:
Currently when doing a file upload, the Content-Type header gets set to whatever MIME type iOS computed for the file. The Content-Type header the developer provided never takes precedence.

For example, when uploading an image, iOS might determine that the MIME type is "image/jpeg" and so this would be the Content-Type of the HTTP request. But the developer might need the Content-Type to be "application/octet-stream". With this change, if the developer provides a Content-Type header, it will not be overriden.

There is only one exception to this rule which is for "multipart" requests. In this case, the developer's Content-Type header is always ignored. This is because the Content-Type header needs to contain the boundary string and that information is not available to the developer in JavaScript.

This change makes iOS's behavior more consistent with Android's.

**Test plan (required)**

In a small test app, verified that the developer's Content-Type header takes precedence when it's provided. Verif
Closes https://github.com/facebook/react-native/pull/9651

Differential Revision: D3820001

Pulled By: mkonicek

fbshipit-source-id: fdb8871f88a0d0db1ae59f75bb62b896fe69542d
2016-09-05 14:58:40 -07:00
David Aurelio 13994d5810 re-enable and fix tests
Summary:
When bringing back `node-haste` to React Native, I left an `fdescribe` in a test that led to ~70 tests being skipped.
This re-enables these tests, and fixes test failures

Reviewed By: cpojer

Differential Revision: D3811225

fbshipit-source-id: 67a16f385759bb829f1f3f559862eab7e78f2097
2016-09-03 01:13:37 -07:00
Marc Horowitz a8cf12a932 Fix some unsafe thread behavior
Reviewed By: javache

Differential Revision: D3789293

fbshipit-source-id: 80118c7f8faf487fe35d4d83a91f023219f6bf80
2016-09-01 19:58:58 -07:00
Pieter De Baets 07553d0f1c Update React Native minimum OS version to iOS8
Reviewed By: majak

Differential Revision: D3723143

fbshipit-source-id: 482f9820370b752d937e6df7f74c33d53a0a2e7d
2016-09-01 19:43:47 -07:00
Pieter De Baets 46b54fd7a8 Support bundle argument for image loading
Reviewed By: mmmulani

Differential Revision: D3768798

fbshipit-source-id: 5b35f06957cebfe74aca90fe6a456f7f739509a9
2016-08-31 17:43:49 -07:00
Ian MacLeod 63931b1a68 Support RCTNetworking#clearCookies on iOS
Summary:
This adds cookie clearing support for iOS to match the existing support on Android.  Helpful for resetting the app to a clean state (say, when logging a user out).
Closes https://github.com/facebook/react-native/pull/9264

Differential Revision: D3776492

Pulled By: javache

fbshipit-source-id: 59ae19ac09d3cf0d0e229cd9e8e30865e65ca96c
2016-08-26 05:43:39 -07:00
Pieter De Baets 14188289fc Add some defensive cleanup of cancelBlock in RCTImageLoader
Reviewed By: mmmulani

Differential Revision: D3742177

fbshipit-source-id: 1cd16c2519052ec5811ecadf2530a5846b4ae1bc
2016-08-19 10:46:09 -07:00
Pieter De Baets 0b1954cace Avoid dispatching network callbacks when already on the right queue
Reviewed By: mmmulani

Differential Revision: D3690133

fbshipit-source-id: a1769016a05b3163a3b1c93f448864aeaecc6e46
2016-08-17 10:44:01 -07:00
Pieter De Baets 66bea7d1e5 Perform all callbacks from RCTNetworkTasks on a given queue
Reviewed By: mmmulani

Differential Revision: D3690022

fbshipit-source-id: 55c0121f7a99cc2186e68d0bb3ebfe5355af98fc
2016-08-17 10:44:01 -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
Scott Wolchok 0e65456d9c plumb trackingName through to native requests
Reviewed By: javache

Differential Revision: D3600752

fbshipit-source-id: 84cea3b67daa67b92a8845454aecf1462c857b50
2016-07-22 11:28:56 -07:00
Janic Duplessis 5903949ad6 Load local assets synchronously to prevent image flicker
Summary:
This uses `[UIImage imageNamed:]` to load local assets that are bundled using `require('../image/path.png')` and makes sure it is done synchronously on the main queue to prevent images from flickering. This improves user experience a lot when using large local images and prevents icon flickers to match the behaviour of most native apps.

This adds to methods to the ImageLoader protocol, one to tell if the image loader must be executed on the url cache queue and one to tell if the result of the image loader should be cached. I then use these to make the LocalImageLoader bypass the url cache queue and avoid caching images twice.

Note that this doesn't affect debug builds since images are loaded from the packager.

I'm not sure if we want to still support async loading of local images as I'm not sure how much of a perf difference this will make. Maybe someone at fb can benchmark this see how it affects your apps but there wasn't a noticeable one in mine. Also I only enabled this for loading png and jpg im
Closes https://github.com/facebook/react-native/pull/8102

Reviewed By: bnham

Differential Revision: D3433647

Pulled By: javache

fbshipit-source-id: 37bd6aff20c0465c163db3cdbcaeaedff55f7b1f
2016-07-21 07:58:51 -07:00
David Aurelio 9bfa393a79 fix new flow errors after D3561327
Reviewed By: bestander

Differential Revision: D3561376

fbshipit-source-id: 226f0d1c6a771a987f9e04f114dc3ba1cca531b1
2016-07-14 04:58:43 -07:00
Philipp von Weitershausen 08c375f828 Add responseType as a concept to RCTNetworking, send binary data as base64
Summary:
In preparation for Blob support (wherein binary XHR and WebSocket responses can be retained as native data blobs on the native side and JS receives a web-like opaque Blob object), this change makes RCTNetworking aware of the responseType that JS requests. A `xhr.responseType` of `''` or `'text'` translates to a native response type of `'text'`. A `xhr.responseType` of `arraybuffer` translates to a native response type of `base64`, as we currently lack an API to transmit TypedArrays directly to JS. This is analogous to how the WebSocket module already works, and it's a lot more versatile and much less brittle than converting a JS *string* back to a TypedArray, which is what's currently going on.

Now that we don't always send text down to JS, JS consumers might still want to get progress updates about a binary download. This is what the `'progress'` event is designed for, so this change also implements that. This change also follows the XHR spec with regards to `xhr.response` and `xhr.responseText`:

- if the response type is `'text'`, `xhr.responseText` can be peeked at by the JS consumer. It will be updated periodically as the download progresses, so long as there's either an `onreadystatechange` or `onprogress` handler on the XHR.

- if the response type is not `'text'`, `xhr.responseText` can't be accessed and `xhr.response` remains `null` until the response is fully received. `'progress'` events containing response details (total bytes, downloaded so far) are dispatched if there's an `onprogress` handler.

Once Blobs are landed, `xhr.responseType` of `'blob'` will correspond to the same native response type, which will cause RCTNetworking to only send a blob ID down to JS, which can then create a `Blob` object from that for consumers.

Closes https://github.com/facebook/react-native/pull/8324

Reviewed By: javache

Differential Revision: D3508822

Pulled By: davidaurelio

fbshipit-source-id: 441b2d4d40265b6036559c3ccb9fa962999fa5df
2016-07-13 04:58:37 -07:00
Spencer Ahrens 4d6c1e55d7 Bring back trackingName
Reviewed By: yungsters

Differential Revision: D3501805

fbshipit-source-id: be7e1a76c022d050542af797dda49b3cf14340bb
2016-07-11 17:58:21 -07:00
Skotch Vail bcf4bb6edd Automated changes to remove implicit capture of self in blocks: Libraries/FBReactKit/BUCK
Reviewed By: javache

Differential Revision: D3442470

fbshipit-source-id: 584a2bb3df5f7122166778b8fd44fae45560491e
2016-07-07 12:44:14 -07:00
Jeff Morrison df46891dfe v0.27.0: fbsource
Reviewed By: gabelevi

Differential Revision: D3421744

fbshipit-source-id: d72275fa70687a188c6175dbd193ab8d79d9051e
2016-06-13 14:28:25 -07:00
Nick Lockwood 235749ba19 Fix missing images
Summary:
Under rare and as-yet-to-be determined circumstances, images can sometimes fail to load/download and get "stuck", without producing an error.

Because the `RCTNetworkTask` for these images is stuck in the "in progress" state, they clog up the RCTImageLoader task queue, which has a limit of 4 concurrent in-progress tasks.

This was previously masked by the fact that we automatically cancelled image requests when the RCTImageView moved offscreen, but we no longer do that.

This diff adds logic to detect some types of stuck task and remove them, thereby unblocking the queue. I've also restored the functionality of cancelling downloads for offscreen images (but not unloading the image itself) so that stuck images will be cancelled when you move to another screen, instead of using up space in the queue forever.

Reviewed By: fkgozali

Differential Revision: D3398105

fbshipit-source-id: 75ee40d06a872ae8e1cb57f02f9cad57c459143c
2016-06-09 09:58:31 -07:00
Philipp von Weitershausen e29350214a Correct semantics for XMLHttpRequest.responseText
Summary:
Accessing the `responseText` property when `responseType` is not `''` or `'text'` should throw. Also, the property is read-only.

**Test Plan:** UIExplorer example, unit tests
Closes https://github.com/facebook/react-native/pull/7284

Differential Revision: D3366893

fbshipit-source-id: a4cf5ebabcd1e03d6e2dc9d51230982922746c11
2016-06-02 18:13:23 -07:00
Nick Lockwood bdcdfb03d4 Fixed "Sending `didSendNetworkData` with no listeners registered" warning
Summary:
XMLHttpRequest was sending the request before registering any listeners, resulting in a warning from the native event emitter.

Since we weren't seeing widespread problems with XHR missing data, this was probably working OK in practice because the queuing of events meant that the listener would have been registered before the message was actually delivered.

Still, this was working more through luck than design. This diff fixes it by registering the listeners *before* sending the request.

Reviewed By: lexs

Differential Revision: D3371320

fbshipit-source-id: c688d4053a61f856eaacccd0106905edbefcc86a
2016-06-01 06:28:22 -07:00