Maximum upload size on iOS / NSURLRequest / NSURLConnection - ios

I'm uploading multi-gigabyte files from iPhones/iPods, and I noticed that NSURLConnection and friends incorrectly use signed 32-bit integers for the number of bytes in the upload
(all of Apple's other API's use (long long) a.k.a. (int64_t) - allowing you to deal with any file that could exist)
When I try to upload files over 3GB, streamed from a file, I get overflows in the data coming back from Apple - but this could be a problem with anything in the chain (web proxy, cache, server). I'm still debugging this, but in the meantime....
Apple docs don't mention a size limit on uploads - is there one?
Bizarrely, I get no problems for uploads up to 3GB (even though the overflow ought to be at 2GB) - it's going over 3GB that always overflows. (I've triple-checked all my source that I'm not using 32bit types anywhere, so I'm fairly confident it's a problem somewhere between iOS and the server(s))

Related

How big can the payload be when sending data via WatchConnectivity?

When sending data using the WatchConnectivity framework, either from the phone to the watch or vice-versa, how big can the payload be before the framework gives me the WCErrorCodePayloadTooLarge error?
I couldn't find the answer on Apple's documentation, and there doesn't seem to be much information on this on the internet at this time (in fact, googling WCErrorCodePayloadTooLarge gives me just 4 results).
Has anyone tested to try to find the answer to this? If this question doesn't get an answer, I will try to do it myself and post the results.
So far, all the information I have is that it may be able to support files that are bigger than 30 MBs. I think this because I take a lot of raw photos on my iPhone, and they usually are ~36MB in size, and they always show up in my watch's Photos app.
For reference, WCSession's documentation has the following description of WCErrorCodePayloadTooLarge:
An error indicating that the item being sent exceeds the maximum size
limit. This type of error can occur for both data dictionaries and
files.
Available in watchOS 2.0 and later.
According to the private symbols WCPayloadSizeLimitApplicationContext, WCPayloadSizeLimitMessage, WCPayloadSizeLimitUserInfo, the limits (as of iOS 9.0.2) are:
65,536 bytes (65.5 KB) for a message
65,536 bytes (65.5 KB) for a user info
262,144 bytes (262.1 KB) for an application context
I don't know why Apple wouldn't document this, other than the fact that it can be difficult when sending dictionaries through WatchConnectivity to determine exactly how large they are. Certainly the acceptable sizes may change over time.
I couldn't find (and haven't personally observed) any maximum size limit when sending files, though I've noticed that it seems to get unreliable when you send large files (hundreds of MBs).

iPhone Downloading large size videos to Documents Directory(~300 mb)

Need your suggestions/advice on a scenario I am stuck into. I am developing an iPhone Application which has 12-15 videos. User can download any video and then play it on his iPhone. The problem is that I am writing the videos to the documents directory. It works well for small videos(~50 mb) but when the bigger ones are choosen(~250 mb) the app crashes, due to low memory warnings.
I know that the app is crashing due to increase in memory footprint. Is there any alternate way to download large files more efficiently(in chunks) with less memory utilization? Otherwise I am thinking to give download option only for small videos and only streaming option for large size videos.
1) Use an asynchronous NSUrlConnection object to download the video.
2) create a file to save the video beforehand, get the file descriptor, and set the F_NOCACHE flag on the open file so as to not consume memory in the disk cache.
3) as you get small chunks of data as NSData objects in the delegate call, append them to the open file.
4) when the download completes, close the file.
You may want to verify that the device has enough space to accept the download; there are posts here on how to do that.

ASIHTTPRequest download: Should I request a large file or many small size files?

I am using ASIHTTPRequest library for my iOS project. My app is about download a ebook (with 150+ jpg files). I have two options:
Zip all images and just request a single zipped file (around 200MB).
Request images each by each (it will become 150+ requests).
Which option is the best if I have more than 1000 users request the ebook simultaneously each day?
This is not exactly an 100% answer to your question, but speaking from experience, I believe you will find it helpful.
I did a somewhat similar app once where I was supposed to update (redownload) a very large number of xml files (up to a couple of thousands).
The one-by-one method was rather slow but with a good NSOperation and NSQueue management, it worked ok, with no UI freezes or crashes on the first iPad. I believe it took me at most 15-20 minutes for the max number of files (somewhere over 5000 operations, with 5 concurrent downloads each), on wifi connection.
When I tried the zip method, to see if it would be faster / better, it made the iPad 1 crash due to high memory usage. And the zip size was about 100 mega if I remember correctly
I would suggest you to go with the first option. 1000 requests per day is not such a high number and this way the user doesn't have to wait for the whole archive to be downloaded, but can read the already downloaded pages without delay.

File size limit iOS (5.1+)

The iOS app I'm working on handles very large files (largest being 2.7 gig in size), and some sqlite tables, after downloading the large I'm getting console messages like this one :
Aug 24 14:50:28 unknown TheAppName[1407] <Warning>: Error opening database: 14 unable to open database file
Also other issues that happen, loading a view (which has already been loaded and presented) will cause a crash saying "nib cannot be located".
The app can run without the large file just fine, but it is very useful to have. The question I have is this : Is the large file causing some sort of memory issue, or is there some sort of limit that iOS places on files? I've looked around at other places and I've been unable to find anything specific to this.
Does it work in the Simulator or do you also have the same issue there?
I suggest you run your app using Instruments with the ObjectAlloc tool. Its likely you have some leaks in the way you are managing the download. Or, is there free space on the device for this file?
Others have had success with downloading huge files as long as sufficient space exists on the flash. You can test for this - there are a few functions floating around that tell you how to determine free disk space.
Another idea: write your file to the disk with the "F_NOCACHE" (fcntl) flag set on the file descriptor. This will cause the writes to bypass the "uniform buffer queue", which is used to cache disk blocks and for other memory uses, and will greatly reduce stress on the system itself.
An iOS app's max size limit is 2GB, this is limit is causing all the errors and is why your app is crashing. I would recommend you upload your large size files to a file hosting site and stream them into the app when you need them.

iPad local data storage limit

Can anyone tell me what is the maximum size that can be download from the web
and can be stored locally.
The limit is 5 MB.
See also this S.O. post.
You could also have a look at this if you are interested in going beyond that limit.
EDIT: after your comment I see you are not referring to local web storage. Local web storage is a new possibility offered by HTML5 to store key-value pairs. This has got the limitation I was mentioning.
As to your case, I don't think that there is some restrictive limit on the amount of data you can download and store locally (in your Documents directory) in order to access it later. You can check this, where answers range from a minimum of 2GB of flash space to no limit at all. So you can be safe.
If you are referring to the limit in the total amount of data you can download over 3G connections (also called over-the-air download), this is 20MB. You are only allowed to download a larger file when using Wi-Fi.

Resources