Hanging & memory leak issues with Aspose.HTML

We’ve found that the following, very basic, HTML causes Aspose.HTML (v20.9) to hang whilst memory quickly leaks.

<html>
  <head>
  </head>
  <body>
	<img src="C:\temp\image001.png" height="1024">
  </body>
</html>

Here is our conversion code that hangs on renderer.Render()…

public override ConversionResultStream Convert(Stream sourceStream, ConversionContext context)
    {
        var pdfOptions = new PdfRenderingOptions();

        var width = Unit.FromMillimeters(210);
        var height = Unit.FromMillimeters(297);
        var a4Size = new Size(width, height);
        var margin = new Margin(Unit.FromMillimeters(20));

        pdfOptions.PageSetup.AnyPage = new Page(a4Size, margin);

        using (var sourcePdfStream = this.GetStream("HtmlConvert"))
        {
            using (var pdfDevice = new PdfDevice(pdfOptions, sourcePdfStream))
            {
                using (var renderer = new HtmlRenderer())
                {
                    using (var htmlDocument = new HTMLDocument(sourceStream, ""))
                    {
                        renderer.Render(pdfDevice, htmlDocument, Config.HtmlConversionTimeout);
                    }
                }

                pdfDevice.Dispose();
            }
            var result = new ConversionResultStream(GetStream());
            result.ResultMetadata = ConvertPdfToArchiveFormat(sourcePdfStream, result.Result, result.ConversionLog);

            return result;
        }
    }

We can remove the height attribute and it works as expected.

Also note: the timeout passed into the renderer.Render() method doesn’t appear to be honoured either.

Can someone confirm the same results?

1 Like

@Drammy

We were able to reproduce the issue in our environment. It seems like it is due to the conflict between the size of image and size of the page of PDF being exported. For further investigation, we have logged a ticket as HTMLNET-2829 in our issue management system. We will further look into its details and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi @asad.ali, thanks for the response. Are we doing something unusual or using the api in a way it wasn’t intended?

I don’t understand how a height attribute can cause this problem and I’m left wondering if there’s a workaround we can implement in the meantime?

@Drammy

The method which you are using for conversion seems fine. However, we need to properly investigate the whole scenario in order to determine the actual causes behind this issue. We are afraid that we cannot offer any workaround at the moment before investigating the ticket completely. We will however certainly inform you as soon as we have some definite updates regarding ticket resolution. We greatly appreciate your patience in this regard.

We apologize for your inconvenience.

@asad.ali Is there any news on this please? Its quite a problem not being able to include a height attribute on an image tag…

@Drammy

We are afraid that the earlier logged ticket is not yet resolved. It is currently under the investigation phase and as soon as it is fully analyzed, we will be able to share updates with you. We have recorded your concerns and will certainly inform you as soon as we have some news about ticket fix or ETA. Please give us some time.

We apologize for the inconvenience.

The issues you have found earlier (filed as HTMLNET-2829) have been fixed in Aspose.HTML for .NET 21.1.