-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory overload when downloading large files. #27
Comments
Just start unsecured server with .serveDirectory on iPad and get file using URLSession from 'http://localhost:9000/big.pdf'. The same picture on macOS. Seems it load the whole file into memory for every downloading session. |
Hi @aplekhanov, Yes big files are fully loaded in memory. The implementation of the file handler is pretty basic. Unfortunately to properly send big files to your client you need chunked transfer encoding, I haven't implemented that in the HTTP classes. I'm not really sure how much work it would be to add it to the framework, I haven't explored the topic in too much detail yet. Perhaps I can have a look at it in the weekend. |
Hi @Zyphrax, But right now I need to finish A LOT OF other interesting work. Let's say it is not high priority and most important thing is that it could be realized by you, by me or by someone else in future 🍻 |
I've just pushed a commit that adds support for range requests on files. That might help in some cases and for example allows for streaming video on iOS. It contains FileHandle code to read parts of the files. However this does not resolve the memory issue yet. To fix that we need to build in proper streaming, for example by adding something like a bodyStream variable to HTTPResponse. I will probably add that later on. The problem is that the socket layer (CocoaAsyncSocket) makes it difficult to implement this. I'll probably have to replace that first. |
Great to hear it! Have you dig into a new Network framework? |
Yeah, I'm working on a wrapper for the Apple Network framework and a DispatchIO implementation for iOS 11 and lower versions. The SSL implementation is going to be a nightmare, but I'll try 😅 |
@Zyphrax I am interested to hear whether or not you decided to pursue this. Not an urgent feature for me, but would be nice to have 😄. |
Hi @JUSTINMKAUFMAN. Darwin sockets are quite complex and especially the SecureTransport SSL layer is going to be a challenge. I'm still working on it, but haven't had much time to spend on it. As soon as I have a unified network layer, I'll dive into proper buffering for large files. |
Hey Do you have a progress with this issue? PS |
I'm checked Kitura and Vapor for big files transfering Vapor support streams for files ChannelResponseBodyStream in BodyStreamWriter in |
Welp ran into a road block for one of my apps thinking I could do something like this feature request to stream a on device decrypted mp4 file. I can decrypt the file but because it has to wait for the whole file to be processed before responding which makes the app feels super slow. Having the ability to write to the output as it decrypts chunks of a mp4 file would be incredible because the video could start playing while decryption is still occurring. Not sure how I could write to the response piece by piece but that functionality would be phenomenal. |
Hello,
I keep challenging your great product and found recently that when I try to download a large file (like ~150 Mb for instance on screenshot below) from the server, the debug navigator shows that it makes a huge impact to device memory. Moreover, it multiplies on number of simultaneous downloads.
Well, is it a bug or architecture pitfall? I mean is it possible to fix it?
Thanks and happy coding!
The text was updated successfully, but these errors were encountered: