Welcome Guest Search | Active Topics | Sign In | Register

HtmlToPdf.MaxConcurrentTaskCount Exception Help Options
lucianchen
Posted: Tuesday, June 3, 2025 10:08:30 AM
Rank: Newbie
Groups: Member

Joined: 6/3/2025
Posts: 6
Hi Team,

We got a lot of exceptions due to the following exceptions on our PROD environment.
EO Nuget package version we're using: 2025.1.6

```
22:40:36 Exception: Can not create additional conversion task. Please increase HtmlToPdf.MaxConcurrentTaskCount. at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo) at System.Environment.get_StackTrace() at EO.Base.BaseException..ctor(String ltc, Exception ltd) at EO.Pdf.HtmlToPdfException..ctor(HtmlToPdfErrorCode ace, Int32 acf, String acg, Exception ach) at EO.Pdf.HtmlToPdfException.ispm() at EO.Internal.dpty.hkpn(mwhd bto, dptw& btp) at EO.Internal.dpub.scdw() at EO.Internal.dpub..ctor(mwhd btr, HtmlToPdfOptions bts) at EO.Pdf.HtmlToPdfSession.gvjq(HtmlToPdfOptions aaw, WebView aax) at EO.Pdf.HtmlToPdfSession..ctor(HtmlToPdfOptions aas, WebView aat, HtmlToPdfSession aau, ResourceHandler aav) at EO.Pdf.HtmlToPdfSession.Create(HtmlToPdfOptions options, ResourceHandler resourceHandler) at EO.Pdf.HtmlToPdf.ehdk(HtmlToPdfOptions adz, frtk`2 aea, Boolean aeb) at EO.Pdf.HtmlToPdf.ehdj(HtmlToPdfOptions adx, frtk`2 ady) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc) at
```

We see there was an old post discussing this topic:
https://www.essentialobjects.com/forum/postst12082_HtmlToPdfMaxConcurrentTaskCount-Error.aspx

And we confirm that we're using the default concurrent task count number (25).
The backend service in which it invokes the `EO.Pdf.HtmlToPdf.ConvertUrl` function is using a 8 max thread pool so it's less than the 25 concurrent tasks count set by EO as default value.

After the library threw this error aggressively, it stopped working until we restarted the service.
We checked out service log and found there were 33 EO exceptions before it repeatedly throw the MaxConcurrentTaskCount exception for ALL subsequent invocations to `EO.Pdf.HtmlToPdf.ConvertUrl`.

And 33(the exceptions we see before MaxConcurrentTaskCount failures took over) = 25(default EO max concurrent task count) + 8(our service concurrent task account).
This makes us think is it possible that the max concurrent task count somehow didn't decrease after exceptions happened.



The other exceptions we see before the MaxConcurrentTaskCount exepctions are:

"Exception: WebView is closed. Reason: EngineCrash at System.Environment.GetStackTrace": 21 times.

Exception: WebView is closed. Reason: EngineCrash at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo) at System.Environment.get_StackTrace() at EO.Internal.gtmo..ctor(Engine acy, String acz, Exception ada) at EO.Internal.dptv.faoi(String btb, Exception btc) at EO.Internal.dptv.faoh() at EO.Internal.dptv.hczd() at EO.Internal.dpub.scdw() at EO.Internal.dpub..ctor(mwhd btr, HtmlToPdfOptions bts) at EO.Pdf.HtmlToPdfSession.gvjq(HtmlToPdfOptions aaw, WebView aax) at EO.Pdf.HtmlToPdfSession..ctor(HtmlToPdfOptions aas, WebView aat, HtmlToPdfSession aau, ResourceHandler aav) at EO.Pdf.HtmlToPdfSession.Create(HtmlToPdfOptions options, ResourceHandler resourceHandler) at EO.Pdf.HtmlToPdf.ehdk(HtmlToPdfOptions adz, frtk`2 aea, Boolean aeb) at EO.Pdf.HtmlToPdf.ehdj(HtmlToPdfOptions adx, frtk`2 ady) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc)

`InnerException: Failed on command 4: at System.Environment.GetStackTrace`: 9 times

"The request was canceled": 2times

"Operation timed out while waiting the page to be loaded": 1 time



Based on the above observation, we have a few questions:

1. Should the task count not decrease upon exception?
2. Can you expose a public property for the current task count in later EO versions?
3. What does the Engine crash mean?
4. What would be a suggestion to help us mitigate this error?

Thanks!

eo_support
Posted: Tuesday, June 3, 2025 10:54:20 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,388
Hi,

Internally our HTML to PDF converters runs a pool of browser engines to load/render the HTML file. "Engine crash" means one of the browser engine has crashed. Our converter is designed to be able to recover from such crash by recreating the engine. However you might have run into a case where there is something in your HTML that triggers a bug inside the browser engine so even if it tries to recover it still fails. This could ultimately leads to the converter exhuasting all available engines in the pool thus gives you the "Can not create additional conversion task" error.

We did recently fix an issue that could trigger browser engine crash and we expect the new build with the fix to be posted later this week. So I would recommend you to wait for that build and then switch to it. If you continue to see the problem with the new build, please collect both crash log and runtime log and send it to us:

https://www.essentialobjects.com/doc/common/crash_report.html
https://www.essentialobjects.com/doc/common/collect_logs.html

The crash log helps us to locate where the engine crashed. The runtime log might provide additional information on how it got to that point. After we have the logs we will look into it and see what we can find.

Thanks!
lucianchen
Posted: Tuesday, June 3, 2025 10:57:37 AM
Rank: Newbie
Groups: Member

Joined: 6/3/2025
Posts: 6
Thanks for the prompt reply! We'll keep an eye on the new version and try it out, and reach out if we still see the issue.
Also do we know if the new version will also fix the concurrent task count issue?
Meaning if we encounter the crash or other exceptions, is there a way to free the thread and put it back to the poo to avoid exhausting?
eo_support
Posted: Tuesday, June 3, 2025 2:08:02 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,388
Hi,

We don't know that for sure yet. That's why if you continue to see the problem, we will need the logs in order to investigate further. You do not need to do anything to free the thread and put it back to the pool. The library supposes to do that automatically. That would be another issue that we may need to investigate if we have a way to reproduce it here once the new build is out.

Thanks!
lucianchen
Posted: Wednesday, June 4, 2025 9:36:22 AM
Rank: Newbie
Groups: Member

Joined: 6/3/2025
Posts: 6
Thanks for the update!
We will collect the logs and upload after we tried with the new version, thanks!
lucianchen
Posted: Tuesday, July 8, 2025 9:54:10 AM
Rank: Newbie
Groups: Member

Joined: 6/3/2025
Posts: 6
Hi support team,

We're seeing higher volume of this error after upgrading, as we're enabling the diagnostic log collection, meantime is there a recommended way to mitigate this error?

After below `Engine Crash` error occurs, the thread pool exhaustion error happens very frequently and eventually all failed.
Is there a way to reset the context without relaunching the app? thanks!

Exception: WebView is closed. Reason: EngineCrash at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo) at System.Environment.get_StackTrace() at EO.Internal.qtoa..ctor(Engine add, String ade, Exception adf) at EO.Internal.fesr.dssl(String bta, Exception btb) at EO.Internal.fesr.dssk() at EO.Internal.fesr.tkjd() at EO.Internal.fesx.qfqd() at EO.Internal.fesx..ctor(uxmx btq, HtmlToPdfOptions btr) at EO.Pdf.HtmlToPdfSession.dmak(HtmlToPdfOptions aay, WebView aaz) at EO.Pdf.HtmlToPdfSession..ctor(HtmlToPdfOptions aau, WebView aav, HtmlToPdfSession aaw, ResourceHandler aax) at EO.Pdf.HtmlToPdfSession.Create(HtmlToPdfOptions options, ResourceHandler resourceHandler) at EO.Pdf.HtmlToPdf.oubv(HtmlToPdfOptions aeb, xetv`2 aec, Boolean aed) at EO.Pdf.HtmlToPdf.oubu(HtmlToPdfOptions adz, xetv`2 aea) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc)
eo_support
Posted: Wednesday, July 9, 2025 2:53:30 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,388
Hi,

The corresponding context is designed to reset automatically after a conversion fail. Specifically, once you receive an exception during the conversion, that conversion task is automatically removed from the internal active conversion list. This means it will no longer be counted against MaxConcurrentTaskCount. We have reviewed the code and we are not able to find or reconstruct any case where a conversion failure would not decrease the concurrent task count.

Is there anyway you can reproduce this problem in a separate test application? If you can reproduce it you can send it to us and we will debug it here to see what we can find. See here for more information on how to send test project to us:

https://www.essentialobjects.com/forum/test_project.aspx

Additionally, you can send us the logs and we will look into that as well.

Thanks!
lucianchen
Posted: Wednesday, July 9, 2025 3:07:44 PM
Rank: Newbie
Groups: Member

Joined: 6/3/2025
Posts: 6
Thanks for checking the code!
We will be working on reproducing this in a non-production environment and sending over logs.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.