I have a problem with report generating. We use HTML5 report viewer and basic implementation of ReportsControllerBase on server.
I've noticed that we have the CPU/memory recourse consumption after immediately pressing Stop Rendering button. The time of consumption recourses is the same as time without cancelling(about 18-20 second in my example)
There is log with calls of report generating. Last one with cancelling, previous without.
*** ReportProcessor.ProcessReport DONE in 00:00:16.1918150 ***
*** ReportProcessor.ProcessReport DONE in 00:00:16.8522950 ***)
I've investigated how cancelation is working.
The Stop Rendering button send DELETE request to ReportsControllerBase.DeleteReport endpoint. It does something and set IsDeleted flag for document.
Then DocumentCancellationController.ThrowIfCancellationRequested() is called in some specific places in app. You can see that method in log.txt, so it was called after pushing the button.
I've profiled the hot path of generation of report. See hotpath.png.
The most CPU intensive work happens in ReportProcessor.ProcessRepourtSource()...
Pay attention to rendering calls.png - the first red dot here - ReportProcessor.ProcessRepourtSource() call.
The second - where the exception and actual cancelation happens.
I'm expecting it should happen much earlier and cancellation of generation of document(and resources consumption) will finish ASAP.
By the way, I see some cancelation checks in ReportProcessor.ProcessRepourtSource() as well - see throwIfCancellation.png
But cancelation request came after these check and most intensive CPU works already started.
Is it possible to fix that?