Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

[iOS] Synchronized tables, separated requests and network logic and other... #636

Open
wants to merge 32 commits into
base: 0.11.0
Choose a base branch
from
Open

[iOS] Synchronized tables, separated requests and network logic and other... #636

wants to merge 32 commits into from

Conversation

chrusart
Copy link

@chrusart chrusart commented Jan 15, 2018

Hi,

this PR came from crashes we still get (some description):
wcandillon/react-native-img-cache#95

...but evolved.

Whole RNFetchBlobNetwork class actually do two things:

  • keeping tasks references to cancel them, change their progress config etc.,
  • session and requests logic.

I moved session and requests logic into separate file, now it's more clean what do what.
NSMapTable seemed to be used incorrectly or just it's (weak) features not used (it seems from log NSLog(@"object released by ARC."); that it should or was used), anyway, it's now instantiated with NSMapTableWeakMemory option for objects, so requests will be released, default in NSMapTable is to use strong references.

sharedInstance is used instead tables and dictionaries instances created on load. This pattern is used all around but please give me a feedback why previous is better solution, maybe I missed something.

Other things done in this PR when implementing:

  • checkExpiredSessions didn’t find anywhere, removed from header
  • __block storage type not needed, variables not used in blocks in scope
  • extern storage type not used in .m files
  • nullability type in RNFetchBlobNetwork, should be checked and applied for method arguments in other classes
  • unimplemented + (void) enableProgressReport:(NSString *) taskId, + (void) enableUploadProgress:(NSString *) taskId, - (void) sendRequest method declarations removed
    unused fileTaskCompletionHandler and dataTaskCompletionHandler properties and synthesizers removed
  • other small warning messages fixes
  • every single request is created on new RNFetchBlobNetwork instance so taskQueue.maxConcurrentOperationCount seems not work as expected -> made taskQueue instantiated per RNFetchBlobNetwork instance.

I can't find any place where actually something is added to expirationTable.

Does HTTPMaximumConnectionsPerHost = 10 have any impact as new session is created for every request (except defaultSessionConfiguration)? In docs it says that it applies to all sessions '...based on this configuration', what actually this means, the same instance, identifier or some comparison???

I'm aware of few fixes that are in 0.10.9 not included here.

TODO:

  • subclass RCTEventEmitter to send events
  • expired task logic?

This is WIP, works for now for us, but didn't test everything and any feedback or testing would be great.

wkh237 and others added 27 commits March 27, 2017 22:28
createJSModules was removedin React Native 0.47.0 and results in the attached Build Error.
removing @OverRide fixes build (didn't remove function because I don't know if it should be kept for downard compatability?)

```
node_modules/react-native-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobPackage.java:23: error: method does not override or implement a method from a supertype
    @OverRide
    ^
1 error

Incremental compilation of 1 classes completed in 0.219 secs.
:react-native-fetch-blob:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.
```
@chrusart
Copy link
Author

chrusart commented Jan 16, 2018

I added it at the end of the day quickly, fixing sharedInstance access now.

@chrusart
Copy link
Author

What about applying:
http://google.github.io/styleguide/objcguide.html
I agree with that code guideline mostly.

@chrusart chrusart changed the base branch from master to 0.11.0 January 16, 2018 11:02
@chrusart chrusart changed the title [iOS] (WIP) Synchronized tables, separated requests and network logic and other... [iOS] Synchronized tables, separated requests and network logic and other... Jan 19, 2018
@chrusart
Copy link
Author

https://github.com/flatfox-ag/react-native-fetch-blob/tree/exception_fixes 2 days already in production, no exceptions yet.

This branch have all these fixes:
#619
#499

and all changes from:
https://github.com/flatfox-ag/react-native-fetch-blob/tree/synchronized

DOES NOT HAVE wkh237:0.11.0 commits listed in this PR!

feel free to:
"react-native-fetch-blob": "github:flatfox-ag/react-native-fetch-blob#exception_fixes",

As we use it in production I removed WIP note.
Stuff in TODO will come in different PRs I guess.

@chrusart
Copy link
Author

Week without crashes on production, fixes confirmed :)

@lll000111
Copy link
Contributor

FYI

react-native-fetch-blob has a new maintained location. Check out the README.

Please consider submitting your PR there, this repository is unmaintained.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants