Hey guys,
We're having problems with suspended chrome processes which affects the time to generate a PDF document from about 2 seconds per PDF to more than 20 seconds. We are generating about 6,500 documents so this blows out the time to process significantly. I am kicking off the process in Startup.cs using:
services.AddJsReport(new LocalReporting()
.UseBinary(JsReportBinary.GetBinary())
.KillRunningJsReportProcesses()
.AsUtility()
.Create());
And I have a PdfGenerator class which has the IJsReportMVCService passed in.
internal class PdfGenerator
{
private readonly IJsReportMVCService _jsReportMvcService;
private readonly HttpContext _httpContext;
private readonly RouteData _routeData;
private readonly HttpRequest _request;
public PdfGenerator(IJsReportMVCService jsReportMvcService, HttpContext httpContext, RouteData routeData, HttpRequest request)
{
_jsReportMvcService = jsReportMvcService;
_httpContext = httpContext;
_routeData = routeData;
_request = request;
}
internal async Task<Stream> RenderAsync(
string content,
Orientation orientation,
string header,
string footer,
decimal? marginTopCm = null,
decimal? marginBottomCm = null)
{
var displayHeaderFooter = !string.IsNullOrEmpty(header) || !string.IsNullOrEmpty(footer);
var report = await _jsReportMvcService.RenderAsync(new RenderRequest
{
Template = new Template
{
Recipe = Recipe.ChromePdf,
Engine = Engine.None,
Content = content,
Chrome = new Chrome
{
HeaderTemplate = header,
FooterTemplate = footer,
DisplayHeaderFooter = displayHeaderFooter,
Height = "29.7cm",
Width = "21cm",
MarginTop = displayHeaderFooter
? marginTopCm.HasValue
? $"{marginTopCm.ToString()}cm" : "4cm"
: "1cm",
MarginLeft = "1cm",
MarginRight = "1cm",
MarginBottom = displayHeaderFooter
? marginBottomCm.HasValue
? $"{marginBottomCm.ToString()}cm" : "2cm"
: "1cm",
Landscape = orientation == Orientation.Landscape,
MediaType = MediaType.Print
}
}
});
return report.Content;
}
}
However when I set up locally I am unable to reproduce this issue, it's only on our prod server. The dotnet application is running using IIS and the IIS version is 10.0.14393.0 running on windows 10 of the same version. It seems to get slower over time meaning it's likely that the number of suspended processes increases over time. Any ideas on this?