Volley DefaultRetryPolicy when Connectivity is Spotty - android-networking

I am using Android's Volley to retrieve JSON files and images. Overall the performance is fantastic. I set a progress indicator before starting the request using
getSherlockActivity().setProgressBarIndeterminateVisibility(true);
and turn it off when the request is complete (in onResponse() or onErrorResponse().
My problem is on the train, especially in a tunnel, where connectivity is spotty. Frequently, the progressbar will persist for what seems like 8 or 10 seconds. When using volley, I am setting the DefaultRetryPolicy as follows:
jsObjRequest.setRetryPolicy(new DefaultRetryPolicy(2500, 2, 1.0f));
requestQueue.add(jsObjRequest);
Are there any suggestions to exit quicker when connectivity is poor?

Related

Optimisation of React-Native app memory while fetching Data from network

I am working with a React-Native app and i have some FlatList Component inside it and it is using round bout 100MB of memory but the problem i am facing is when i make some network request and after getting response from network request it start using memory of near about 500MB but according to PostMan this service response size is 18.66KB I also have implemented pagination so when FlatList's scroll finishes i make another call but this time memory is not increasing rapidly as it was increasing previously.
I am using Redux-saga for state management and i also disptach and action in componentWillUnMount to clear the state of redux but app memory not clearing it at all.
and here is post man response time and size

Chrome DevTools Network Waterfall - gaps between requests?

I've been doing some refactoring on a slow running web application, and managed to reduce the number of requests and the size of the downloads to help improve the situation. Now the loading time is consistently shorter. However, consistently before there was hardly any time elapsed before the last 2 requests. Now consistently there is a gap.
Q1: What do these 'gaps' indicate in Chrome Network view?
Q2: Looking at the screenshots, the DOMContentLoaded time vs. the overall Finish time, are there any conclusions I can draw that could help me optimise further?
Record the page load in the Performance panel. See Get Started With Analyzing Runtime Performance to get the gist of how to use the panel. Understanding the network bottleneck can also help get you oriented.
However, you'll want to press the Reload page button (like Sam does in the "understanding the network bottleneck" video) instead of the Record button to record the page load performance, as the "get started with analyzing runtime performance" instructs you to do.
Once you've got a recording, the Main section shows you all of the main thread activity that occurs while the page is loading. The Network section shows you all of the Network requests. You'll probably be able to visually verify that there's a bunch of JavaScript work going on during the gap that you're seeing in your screenshots.
If it's still not clear to you, post a screenshot of your Performance panel recording and I'll help you decode the results.

libSpotify-based client slow, but Spotify's own client fast

I've run into some weird issues with libSpotify. It seems that any libSpotify-based client will take ages to process requests (sometimes 20 seconds for a simple search, seconds for loading one single image, etc..) sent to Spotify servers, whereas Spotify's own desktop client for Windows works extremely well on the same system, processing requests and loading images in near realtime.
Even the demo app provided with libSpotify, called spshell, exhibits massive problems:
Did anyone experience similar problems and/or knows the cause?
Magically works again since today, no clue why.

How to improve performance of application in iOS?

I have developed an application which works on iPhone-3GS, iPhone-4, iPhone-4S.
For start up process, it take 30 seconds on iPhone-4s , and take 50-55 seconds on iPhone-3gs. Tested on same network.(Its not an issue related to network or internet; In simulator it took only 5 second.)
In this start up process, App performs several actions like deletion of old data from Database, WebService calling and inserting response data into Database. Application calls almost 8 web service on main thread using performSelectorOnMainThread method(sequentially).
I am using SQLite and Compiled Query structure for insertion. I want to improve performance of application and want to reduce start up time taken by application.
Same back-end is used by Android team and they are also doing same thing. It takes 20 sec only on Galaxy note (Team android is using Object Relational Modal to communicate with Sqlite database ).
Is this the reason for faster performance ?
Is there anything that work same as ORM in Java for Objective-C to improve performance while dealing with Sqlite (processor specific , less time consuming)?
First thing is you should not be doing network operations (web service calls) on the main thread. That should be done on background threads. I don't know enough about using SQLite directly but with CoreData you can make "database" updates on background threads and just use the main thread for merging the two ManagedObjectContexts.
I imagine moving your WS calls to background threads (AFNetworking is a great framework btw), that you will see lots of improvement.
One example I have is a web-service based app that gets 7000 records from a SQL Server DB and creates an NSArray (data comes in as JSON) and that process takes 7-10 seconds. I further minimize the impact on the user by doing my auto-authentication process at the same time.
30 seconds is too long to have the user wait on something IMO.
14 best tips are available here Best Steps to increase performance of iOS App
In this tutorial, point 13 gives the info you required.

Async NSURLConnection performance issues

Been banging our heads on this for two weeks now. Any help will be greatly appreciated.
Problem:
I am using NSURLConnection to fetch JSON data from a RESTfull Web service, the requirement is such that I can't do lazy loading of data. It is one big chunk of data that needs to be processed on the 1st screen of the app every time the logged in user opens the app. I know its not a smart thing to do, but can't help it. The caching is being done in the local Sqlite DB. We are using Async NSURLConnection that is giving us a constant 3-4 sec hit on the performance.
We tried Sync NSURLConnection and figured out the Async NSURLConnection is taking around 3-4 sec extra to process the same request. But Sync NSURLConnection is not reliable at all, it fails to get the complete JSON more than half of the times. And the combination of Sync NSURLConnection with NSOperation will not help.
We tried making the call in a separate app just to observe the performance for that one particular request, and still got the same results.
So, currently we are getting an average execution time of the complete request to be around 6-8 sec. Which we feel I quite high for your first screen of the app. (please let me know if its not much, it feels like bad user experience to me).
Questions:
Isn't NSURLConnection the standard way for doing a request like this?
Is there a better and faster (reliable) way of doing this apart from NSURLConnection?
Can I optimize the performance of NSURLConnection? If yes, please point me to the right direction.
Has anyone tried CFHTTPStream? If yes, then is it better than NSURLConenction in terms of performance?
Thanks
#GoZoner Thanks a ton for the response. We tested in the below three ways
Since it is the 1st screen of the app, so there is no real case of the app doing anything else, still the results were different and a consistent 3-4 sec loss with Async.
We made a raw call in a separate test app, which did nothing but just that one web service call and still the results were same.
We tested on the device and on the simulator. On the device, as expected the results were worse, around 4 secs constant lag in an Async NSURLConnection call.
We were also surprised with the reliability issue as it makes very little sense that a Sync NSURLConnection is unreliable. But after running the tests a zillionth time we realized that it is actually not reliable, not because of something in the NSURLConnection library, but because the 3G or Wi-fi connections are not reliable so the call use to break mostly due to the connection(my assumption). This particular problem is handled beautifully by Async NSURLConnection since it keeps calling and appending data till the data received is complete.(This can sometimes take more than 10-12 attempts to append the data to complete the JSON). Since the Sync NSURLConenction is making only one attempt in getting the data, it fails miserably in the unreliable mobile network connectivity.
#Andrea Thanks for the response :) Will surely give YAJL a spin. But i believe that the problem is more with the connection rather than the parsing of the JSON, I may be wrong. Does YAJL have a reliable connection handling mechanism?
Looking forward to more responses, your suggestions and comments are actually very valuable :)
Thanks
try to use ASIHttpRequest the response time may be faster than the NSURLConnection.