umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.41k stars 2.66k forks source link

Large GIFs cause Umbraco on Azure Web App to restart when resizing in media section #16940

Closed karltynan closed 1 week ago

karltynan commented 3 weeks ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.4.1

Bug summary

I have an Umbraco website running on Azure Web App (Linux). When I upload a large GIF image to the media section, the website crashes and restarts. I think this is because the media section resizes for previewing media items, as I do not allow GIFs to be resized on the front-end.

I have also tested this on Azure Web App (Windows) to see if it is Linux-specific or Umbraco-specific. I can confirm the issue is also on Windows.

  1. Is there a known issue for this?
  2. Perhaps there is a workaround to stop it resizing of GIFs in the media section?
  3. Can I restrict media image types allowed to upload?

Specifics

Steps to reproduce

  1. Publish an Umbraco 13.4.1 website to an Azure Web App (Linux)
  2. Try to upload a GIF that is quite large (or view a previously uploaded GIF that caused a restart) in media section
  3. App crashes/restarts

Expected result / actual result

The Umbraco website should not crash or restart when uploading large GIF images to the media section, or when previewing large GIFs in the media section.

github-actions[bot] commented 3 weeks ago

Hi there @karltynan!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

karltynan commented 3 weeks ago

I have done a brief trial using Azure Web App (Windows) and it seems be the same issue. I have also compared using blob storage and media directory - both have the same issue.

Migaroez commented 2 weeks ago

Hey Karl, could you provide the 2 test images you used?

karltynan commented 2 weeks ago

examples.zip Attached 2x images.

karltynan commented 2 weeks ago

The issue starts in the media section when the GIF is requested like such: /umbraco/backoffice/umbracoapi/images/GetBigThumbnail?originalImagePath=xxx

Migaroez commented 1 week ago

Did some local testing

The memory allocation goes up to about 19GB for the biggest image you supplied (9MB) This seems to be solely from running the image trough ImageSharp when the cropUrl is resolved for the first time.

Regarding your questions

  1. We know Imagesharp can have a large memory footprint, I personally did not realize it would be this bad.
  2. You could Copy the ImageSharpImageUrlGenerator class we provide and add a check inside the GetImageUrl method to return the raw url if it concerns a gif file. The unregister ours and register your IImageUrlGenerator in a composer. I would not recommend this as you would then have to keep your implementation up to date with ours. But it is a workaround where you will still see the GIF inside the media preview just not resized.
  3. Yup: https://docs.umbraco.com/umbraco-cms/reference/configuration/contentsettings