Skip to content
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

Unexpected behavior when an image can't be optimized in Sync mode #68

Closed
mzizka opened this issue Jun 9, 2020 · 1 comment
Closed

Comments

@mzizka
Copy link

mzizka commented Jun 9, 2020

Environment

  • Dianoga 5.0.0
  • Environment: All environments (tested locally with SC 8.2.5 and Azure PaaS with SC 9.0.1)

Configuration:

  • Sync strategy
  • Lossless JPEG (progressive) optimization
  • Lossless PNG optimization

Description:

When certain errors occur during optimization using Sync strategy, instead of rendering the original image, an error is returned. Locally, the resulting "yellow page" gives the following output:

[ObjectDisposedException: Cannot access a closed stream.]
   System.IO.__Error.StreamIsClosed() +59
   System.IO.MemoryStream.get_Length() +30
   Sitecore.Resources.Media.Streaming.RangeRetrievalResponse.WriteFullContent(HttpContext context, Stream fileContent) +105
   Sitecore.Resources.Media.MediaRequestHandler.DoProcessRequest(HttpContext context, MediaRequest request, Media media) +451
   Sitecore.Resources.Media.MediaRequestHandler.DoProcessRequest(HttpContext context) +1574
   Sitecore.Resources.Media.MediaRequestHandler.ProcessRequest(HttpContext context) +57
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +790
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +88

This has me worrying that any error using Sync setup will result in a 500 error, instead of just letting Sitecore take over.

How to reproduce:

I have two files. One is actually a WEBP with the .jpg extension. The other is a deliberately corrupted image (but which can still render, partially, in most tools).

This is meant to reproduce issues that we have noticed in the past in our Media Library. Since we have many contributors, it's not always easy to track down the reason for such issues, or to prevent them from happening.

To reproduce:

  1. Upload both files to Media Library, one at a time (not using Upload Advanced). Sitecore will give you an error with the corrupted image, but if you refresh, you will see it is there.

  2. Publish the images.

  3. Open the images in browser with Dianoga configured as above. This will result in an error.

  4. Remove the Dianoga configs and try again. Without Dianoga, the images are rendered in the browser.

Other logs

Here is the Dianoga log output for each image:

test1-webp.jpg:

ERROR Dianoga: Unable to optimize /test1-webp due to a processing error! It will be unchanged.
Exception: System.InvalidOperationException
Message: "C:\inetpub\wwwroot\sc825\Website\App_Data\Dianoga Tools\mozjpeg_3.3.1_x86\jpegtran.exe -optimize -copy none -progressive -outfile "C:\WINDOWS\TEMP\tmp5765.tmp" "C:\WINDOWS\TEMP\tmp5764.tmp"" exited with unexpected exit code 1. Output: Not a JPEG file: starts with 0x52 0x49

test2-corrupted.jpg:

ERROR Dianoga: Unable to optimize /test2-corrupted due to a processing error! It will be unchanged.
Exception: System.InvalidOperationException
Message: "C:\inetpub\wwwroot\sc825\Website\App_Data\Dianoga Tools\mozjpeg_3.3.1_x86\jpegtran.exe -optimize -copy none -progressive -outfile "C:\WINDOWS\TEMP\tmpCF49.tmp" "C:\WINDOWS\TEMP\tmpCF48.tmp"" exited with unexpected exit code 1. Output: Unsupported marker type 0x20
Corrupt JPEG data: premature end of data segment
@markgibbons25
Copy link
Collaborator

Thank you for the excellent report. It made it easy to identify and fix the issue. This is fixed in 5.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants