Timeout when using Aspose.SVG.Drawing.SkiaSharp, Version=25.12.0, .NET

I am attempting to convert SVG images to compressed JPG images.
I started by using Aspose.SVG, and implemented a method to do just that.
It is rather slow, but it did manage to make some decent jpg compressions. However, when I tried to get the code through my build pipeline, it failed because it is running on Linux. So I replaced the Aspose.SVG package with the Aspose.SVG.Drawing.SkiaSharp package, which resolves issues in the build pipeline, but introduces a breaking issue when executed locally on my windows machine.

Specifically, it seems that the svg.RenderTo(imageDevice); method is hanging until the thread is destroyed. I tested my rendering options one by one and eventually found that if I removed the “PageSetup” parameter completely, it would work (although the resulting image would be incorrect visually):

using Size = Aspose.Svg.Drawing.Size;
using Aspose.Imaging;
using Aspose.Imaging.ImageOptions;
using Aspose.Svg;
using Aspose.Svg.Drawing;
using Aspose.Svg.Rendering.Image;
            using var svg = new SVGDocument(svgStream, options.ImageUrl);

            var renderingOptions = new ImageRenderingOptions(ImageFormat.Jpeg)
            {
                BackgroundColor = options.BackgroundColor,
                HorizontalResolution = options.TargetDpi,
                VerticalResolution = options.TargetDpi,
                UseAntialiasing = options.UseAntialiasing,
                //PageSetup = { AnyPage = GetSvgPage(svg, options.TargetDpi, options.SourceDpi) },
            };

      private static Page GetSvgPage(SVGDocument svg, int targetDpi, int sourceDpi)
      {
          var viewBox = svg.RootElement.ViewBox.AnimVal;
          var widthInPixels = (int)Math.Ceiling(viewBox.Width * targetDpi / sourceDpi);
          var heightInPixels = (int)Math.Ceiling(viewBox.Height * targetDpi / sourceDpi);
          if (widthInPixels == 0 || heightInPixels == 0)
          {
              return new Page();
          }
          var pixelSize = new Size(
              Unit.FromPixels(widthInPixels),
              Unit.FromPixels(heightInPixels)
          );
          return new Page(pixelSize, new Margin(0));
      }

I have made no other change than the replacement of the package.
The input options for my test case are a targetDpi of 300 and source dpi of 96. Final image is 3508 pixels tall.
I would love to see this being fixed, as it is blocking progress on a project.
I would also like to hear about performance changes that could be made to speed this up, as it currently takes a very long time to render and compress these (admittedly large) images - which might be why it hangs without throwing exceptions.

@chbod

  1. Issue Summary:
    You are experiencing a timeout or hang when using Aspose.SVG.Drawing.SkiaSharp version 25.12.0 on Windows, specifically when the PageSetup parameter is included in ImageRenderingOptions. Removing the PageSetup allows rendering to proceed, though it results in an incorrect visual output .

  2. Root Cause Observation:
    The issue may be related to how the Aspose.SVG.Drawing.SkiaSharp rendering engine interacts with the PageSetup configuration, particularly when combined with specific rendering options such as resolution settings or page sizing logic . Switching from Aspose.SVG to Aspose.SVG.Drawing.SkiaSharp was intended to resolve Linux build pipeline issues, but introduced this unexpected hang .

  3. Workaround:
    As a temporary workaround, you can remove the PageSetup configuration from ImageRenderingOptions, although this leads to incorrect sizing of the rendered image . Ensure that all size calculations in GetSvgPage() produce valid dimensions (non-zero width and height) to avoid invalid page setups that might contribute to the hang .

  4. Performance Considerations:
    Rendering large SVGs (such as your 3508-pixel-tall image) can be resource-intensive. To improve performance:

  • Reduce the target DPI if possible.
  • Avoid unnecessary antialiasing or high-quality smoothing modes unless required.
  • Consider rendering at a lower resolution first and then scaling up if needed.
  1. Next Steps:
    Given that this appears to be a bug tied to the interaction between PageSetup and the SkiaSharp engine in version 25.12.0, we recommend reporting this issue to Aspose support for further investigation. Please include a minimal reproducible example along with your environment details .

If you need assistance crafting a minimal reproduction case or exploring alternative rendering approaches, feel free to ask.