Free Support Forum - groupdocs.com

Long conversion time or exception when rendering certain PPTX to HTML in .NET

Hi,

I’m getting the following exceptions when converting one of the attached files to HTML.

GroupDocs.Viewer.Exceptions.GroupDocsViewerException: 'Exception has been thrown by the target of an invocation.'

Slow PPTX Viewing.zip (3.0 MB)

It worked on the first attempt, but somehow it stopped working.
If you check the document, you will see that this is a bit of an edge case… I didn’t even know such thing works with GroupDocs (which is great :+1:)
image.png (73.4 KB)

The PPTX has various Word and Excel documents embedded. (double click on one to edit)
Because of that it probably has to invoke Word or Excel and therefore I get the invocation error?

Also memory consumption was pretty high with 3 GB and more.
I was using GroupDocs Viewer 21.4.1 for .NET with any special options:

        HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources("result_{0}.html");
        using (Viewer viewer = new Viewer(documentPath))
        {
            viewer.View(viewOptions);
        }

@Clemens_Pestuka

We’ve failed to reproduce the exception 'Exception has been thrown by the target of an invocation.' with sample_app.zip (3.0 MB) when targeting .NET Framework 4.8 or .NET Core 3.1 and running on Windows 10 machine. Possibly the issue is related to the environment, could you please share details about the app you’re running (web, console), targeting framework, and OS?

It could be a reason for long conversion time as each of the objects embedded into a page is rendered to an image.

@vladimir.litvinchik

I was using .NET Framework 4.7.2 on Windows 10.
It might be related to memory usage on my system.
For the 5 pages pptx “ENG_PPT_5.pptx” it was working again now.
But I could not get the bigger ones to convert.
image.png (52.5 KB)

Did you also test with the 50 pages file “ENG_PPT_50.pptx” on your system?

@Clemens_Pestuka

Yes, I did test all the files including ENG_PPT_50.pptx. It can be a memory-related issue. We’ll try reproducing it on another system and update you.

@vladimir.litvinchik

Thank you for the effort.
I created a new project (same machine, same .NET Frame work and same GroupDocs versions) and it works there…
(The new project was a console app now, maybe that was it)

Sorry for wasting your time on this.
I was now also able to check the rendering speed, which was about 4-5 seconds per page.
I think this is acceptable for this complex page.
Memory consumption stayed also around 2 GB now.

@Clemens_Pestuka

No problem, so when running the same code in WinForms app there is an exception, right?

@vladimir.litvinchik

Yes exactly, it seems to be only related to WinForms.
I’ve created a new WinForms project in Visual Studio with minimal code if you want to take a look.
GroupDocs_WinForms.zip (10.1 KB)

@Clemens_Pestuka

Thank you for attaching sample application. The behavior the same as you’ve described in your first comment in this topic. We’ll continue investigating why it’s happening and update you.

@vladimir.litvinchik

I’m happy to hear that :slight_smile:
Thank you!

@Clemens_Pestuka

It looks like the issue is related to the nature of the Windows Forms apps where the UI thread should be responsive. When running long running task it is recommended to use BackgroundWorker to run the application on another thread instead of running it on UI thread.
To keep the example simple I’ve updated the GroupDocs_WinForms_1.zip (11.5 KB) to run Viewer in the new thread - the app is running without exceptions now and the memory consumption is stable.

1 Like

@vladimir.litvinchik

:grimacing: yeah that makes total sense… I should have gone with the Console app for testing.
Thanks a lot for figuring out :+1:

1 Like

@Clemens_Pestuka

Thank you, it would be quite hard to find out the issue without your help.

Have a nice day!

1 Like