Reputation: 1810
My webapp allows the user to select an image, client-resize it via JS and then upload it (via HTTPS, for what is worth):
This is the relevant code:
var canvasData = canvas.toDataURL("image/jpeg");
canvasData = encodeURIComponent(canvasData);
var formData=new FormData();
formData.append("imagedata", canvasData);
$.ajax({
url : <my upload url>,
data : formData,
type : "POST"
dataType : "JSON",
contentType : false,
processData : false
})
If I save on the iPhone 6S Plus with iOS 9 an image such as this - 5616x3744 pixel, 2 MB and then upload it with Safari, the upload fails.
Since I'm using the iPhone remotely via BrowserStack, I've a console with an error:
POST <my upload url>, Could not connect to the server.
The HTTP request is fired, but the server log reveals that it's never received.
The rest of the webapp shows no problem with GET requests to the same host, and other form submissions without a file work OK too.
I cannot reproduce the problem with any other PC or Android browser.
What is even more puzzling is that the same upload code works great on the same iPhone with other images... and even Chrome for Safari has no problem dealing with every file i try the code with. Only Safari seems to display this odd behaviour.
So far I've excluded a memory exaustion issue because the image is south of 2 MB, the inspector reveals a data:image (probably from canvas.toDataURL
) with the photo perfectly readable and Safari doesn't crash/slows down.
jQuery Core 1.12.4.
The server is nginx/1.10.0 (Ubuntu 16.04) with PHP 7.0.4 via php-fpm. As stated, the connection is over HTTPS with a cert provided by Let's Encrypt. The server is on 0 load because the service is not open to the public yet.
Any idea? any bug+workaround I'm not aware of?
Thanks for your suggestions.
Upvotes: 2
Views: 1351
Reputation: 1810
I didn't found the issue and I still cannot understand how this is a solution, but when I disabled the HTTP/2 support form Nginx the issue vanishes.
Update: Lucas Rolff kindly replied to my question on the Nginx forum:
https://trac.nginx.org/nginx/ticket/979
https://trac.nginx.org/nginx/ticket/959
It's a known bug
At least now I know what's going on! Let's wait for a patch...
Upvotes: 2