RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.09k stars 10.35k forks source link

Attempt to upload animated gif image file with size +5Mb gives POST response 504 - Gateway Time-out #31405

Open ArielGMachado opened 8 months ago

ArielGMachado commented 8 months ago

Description:

When I try to upload an animated gif file, if it is 5.2Mb the POST fails with error 504 Gateway timeout.

If I try to upload a smaller animated gif, like 2 or 4Mb, the upload goes without issues, in the same way that if I try to upload a 9Mb .jpg image there is also no problem.

It seems that there is a specific problem with +5Mb gif files.

See video (be patient, the video not freezes on (pending) it takes a while to show the timeout): UploadAnimatedGif5 2Mb

Storage Type: Filesystem Maximum File Upload Size (in bytes): 10485760 (10mb) Nginx configuration client_max_body_size 10mb

Steps to reproduce:

  1. Try to upload an animated .gif file with 5.2Mb

    Expected behavior:

File sucessfully uploaded: POST to https://server/api/v1/rooms.upload/ returns 200 - OK

Actual behavior:

Upload fails: POST to https://server/api/v1/rooms.upload/ returns 504 - Gateway Time-out

Server Setup Information:

Client Setup Information

Sayan4444 commented 8 months ago

@ArielGMachado can you provide a gif with 5mb+ size as I am having a hard time to find one

ArielGMachado commented 8 months ago

Hi @Sayan4444 here I send a gif altered from the original with which I can also reproduce the problem. Some frames were deleted in the gif to anonymize some information, but it is still a valid gif. WFOInfoAsAddon2.zip

Thanks

Sayan4444 commented 7 months ago

Hi @ArielGMachado sorry for such a late response. The error message getting thrown is this Error: Input file has corrupt header: gifload: Excessive number of frames [ufs: cannot upload file]

I am curious if its happening for this gif or all gif above 5mb. I would love if you could provide me some more gifs for demonstration purpose as its really hard to find GIF of such large file size.Thanks a lot

ArielGMachado commented 7 months ago

Hi @Sayan4444 this gif file is generated by a screen recorder tool for Linux called Peek https://github.com/phw/peek A have this settings: image

Not all gifs generated that exceed 5Mb produce this error. I've already uploaded 7Mb files without a problem, but they may have been recording a larger area of the screen but of shorter duration, which should generate larger file sizes but with fewer frames, not causing the uloading error.

The gif file of the screen recording that gave an error has a duration of aprox 3:52 minutes, the resolution of w:1107 x h:803 with 5561 frames. The 5561 for a ~3:52 minutes matches the framerate of 24 frames per second configured in Peek settings.

To count the number of frames a gif file has you can use the Linux utility identify: identify -format "%n\n" video.gif | head -1

I hope this helps you have better data and ideas on how to reproduce the problem. Thanks!