Threading and Report Builder 12.05
Hi,
We have a proprietary reporting server which implements indy 10 and
report builder 12.05. We have an issue which appears randomly where
report builder generates an exception:
EInvalidOperation Canvas does not allow drawing followed by
EAccessViolation at address XXX in module 'RICHED20.dll'
While I understand that the VCL is not thread safe and requires
synchronization with the main thread, Is there a requirement for report
builder to be synchronized when calling TppReport.Print or are there
other specific settings within report build we need to configure so that
it remains thread-safe. Ideally we don't want to lock the main thread
during a synchronize while a large report is potentially being generated
this will defeat the purpose of handling multiple report requests.
I have found other posts which recommend disabling various options which
I have done as follows:
fReport.ShowCancelDialog := False;
fReport.ShowPrintDialog := False;
fReport.ShowAutoSearchDialog := False;
fReport.ModalCancelDialog := False;
fReport.ModalPreview := False;
fReport.EnableProcessMessages := False;
fReport.BackgroundPrintSettings.Enabled := False;
fReport.BackgroundPrintSettings.Active := False;
We have a proprietary reporting server which implements indy 10 and
report builder 12.05. We have an issue which appears randomly where
report builder generates an exception:
EInvalidOperation Canvas does not allow drawing followed by
EAccessViolation at address XXX in module 'RICHED20.dll'
While I understand that the VCL is not thread safe and requires
synchronization with the main thread, Is there a requirement for report
builder to be synchronized when calling TppReport.Print or are there
other specific settings within report build we need to configure so that
it remains thread-safe. Ideally we don't want to lock the main thread
during a synchronize while a large report is potentially being generated
this will defeat the purpose of handling multiple report requests.
I have found other posts which recommend disabling various options which
I have done as follows:
fReport.ShowCancelDialog := False;
fReport.ShowPrintDialog := False;
fReport.ShowAutoSearchDialog := False;
fReport.ModalCancelDialog := False;
fReport.ModalPreview := False;
fReport.EnableProcessMessages := False;
fReport.BackgroundPrintSettings.Enabled := False;
fReport.BackgroundPrintSettings.Active := False;
This discussion has been closed.
Comments
to generate. For a details check out the RBuilder help topic for Report
BackgroundPrintSettings. As you mentioned all dialogs need to be suppressed.
2. The error references RichEd20.dll, which is the MS RichEdit dll. RichText
requires a windows handle, make sure the same thread creates/destroys the
RichText. You can try some test with your server to determine whether it is
only reports with RichText that are having issues.
3. Try testing with RB 14.07, the latest release.
-
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
As a test, try setting the Report.PDFSettings.UseJPEGCompression
property to False (in code before printing) and see if that solves the
issue. I would like to see if the new JPEG processing is causing the
issue or if it's something else.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Just to correct my previous post I should have said we had the same
exception with a slightly different stack trace that ultimately led to
the same error.
Regards
Simon
For future reference, please send all attachments to
support@digital-metaphors.com.
The PDF device is widely used by out Server edition of ReportBuilder
which requires a thread safe environment. This device and other aspects
of RB are tested to be thread safe.
It is possible that your application is either leaking resources or
running out of resources during report generation. Try running your app
with a memory manager such as FastMM to see if there are any leaks. If
not, try to isolate the report component(s) that cause the problem. At
first glance, it appears an image may be causing the problem however you
mentioned that you are also using RichTexts as well.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
To clarify this is being produced by stress testing with the same
report.The image is coming from a blob field and is the same every time.
In addition this report can be produced hundreds of times before this
issue occurs.
We have Thoroughly tested for memory leaks while we did find 2 in
our code and consequently removed them the invalid handle issue still
persists.
We have also observed that there appears to be no cleanup when the
EOutOfResources error occurs since FastMM exposes that a
TMemoryStream,TppPDFImage, etc remain allocated. If this exception does
no occur the are no memory leaks noted by FastMM. Our coding is catching
the EOutOfResources error.
Below is a summary of what was reported by FastMM after the exception
occurred.
Regards
Simon
------------------------------------------------------------------------------------------
A memory block has been leaked. The size is: 8356
This block was allocated by thread 0xB8, and the stack trace (return
addresses) at the time was:
42D0CE [common\Classes.pas][Classes][TMemoryStream.Realloc][5619]
42D03C [common\Classes.pas][Classes][TMemoryStream.SetCapacity][5591]
42D130 [common\Classes.pas][Classes][TMemoryStream.Write][5639]
7069E1 [ppPDFUtils][TppPDFUtils.WriteLine]
707183 [ppPDFObject][TppPDFObject.WriteMSLine]
70F830 [ppPDFPageTree][TppPDFPageTree.StartPageTree]
7172A9 [ppPDFDevice][TppPDFDevice.StartJob]
643F93 [ppDevice][TppPublisher.GetDevice]
64338E [ppDevice][TppPublisher.TakeDeviceAction]
6435EA [ppDevice][TppPublisher.StartJob]
7282B3 [ppProd][TppProducer.InitializeReport]
The block is currently used for an object of class: Unknown
----------------------------------------------------------------------------------------
A memory block has been leaked. The size is: 20
This block was allocated by thread 0xB8, and the stack trace (return
addresses) at the time was:
403216 [sys\system.pas][System][@GetMem][2654]
40594D [sys\system.pas][System][@NewAnsiString][12429]
406001 [sys\system.pas][System][@LStrSetLength][13786]
405B98 [sys\system.pas][System][@LStrCat][12866]
6BCE6E [ppCtrls][TppCustomImage.PropertiesToDrawCommand]
6469DF [ppPrnabl][TppPrintable.Print]
72D537 [ppStrtch][TppStretchable.Print]
734C3A [ppBands][TppCustomBand.Print]
7346E0 [ppBands][TppCustomBand.Generate]
6A7B89 [ppEngine][TppEngine.GenerateBands]
6A876B [ppEngine][TppEngine.FinishPage]
The block is currently used for an object of class: AnsiString
------------------------------------------------------------------------------------------
A memory block has been leaked. The size is: 20
This block was allocated by thread 0xB8, and the stack trace (return
addresses) at the time was:
403216 [sys\system.pas][System][@GetMem][2654]
40481B [sys\system.pas][System][TObject.NewInstance][8807]
404BE2 [sys\system.pas][System][@ClassCreate][9472]
404850 [sys\system.pas][System][TObject.Create][8822]
70709F [ppPDFObject][TppPDFObject.Write]
70F807 [ppPDFPageTree][TppPDFPageTree.StartPageTree]
7172A9 [ppPDFDevice][TppPDFDevice.StartJob]
643F93 [ppDevice][TppPublisher.GetDevice]
64338E [ppDevice][TppPublisher.TakeDeviceAction]
6435EA [ppDevice][TppPublisher.StartJob]
7282B3 [ppProd][TppProducer.InitializeReport]
The block is currently used for an object of class: TMemoryStream
-------------------------------------------------------------------------------------
A memory block has been leaked. The size is: 20
This block was allocated by thread 0xB8, and the stack trace (return
addresses) at the time was:
403216 [sys\system.pas][System][@GetMem][2654]
40481B [sys\system.pas][System][TObject.NewInstance][8807]
404BE2 [sys\system.pas][System][@ClassCreate][9472]
700B86 [ppPDFImage][TppPDFImage.Create]
403232 [sys\system.pas][System][@FreeMem][2699]
405899 [sys\system.pas][System][@LStrClr][12226]
7069F6 [ppPDFUtils][TppPDFUtils.WriteLine]
712712 [ppPDFRendererImage][TppPDFRendererImage.CreateImage]
713396 [ppPDFRendererImage][TppPDFRendererImage.RenderToPDF]
70D797 [ppPDFRenderer][TppPDFRenderer.SetPageHeight]
717A81 [ppPDFDevice][TppPDFDevice.DrawToPage]
The block is currently used for an object of class: TppPDFImage
-------------------------------------------------------------------------------------
A memory block has been leaked. The size is: 20
This block was allocated by thread 0xB8, and the stack trace (return
addresses) at the time was:
403216 [sys\system.pas][System][@GetMem][2654]
40481B [sys\system.pas][System][TObject.NewInstance][8807]
404BE2 [sys\system.pas][System][@ClassCreate][9472]
4169BB [sys\sysutils.pas][SysUtils][Exception.Create][13910]
40594D [sys\system.pas][System][@NewAnsiString][12429]
405990 [sys\system.pas][System][@LStrFromPCharLen][12476]
4418BB [Graphics.pas][Graphics][GDIError][2954]
7C919FFA [Unknown function at RtlpUnWaitCriticalSection]
7C96FD90 [Unknown function at RtlpNtMakeTemporaryKey]
7C96FD74 [Unknown function at RtlpNtMakeTemporaryKey]
7C96F2D7 [Unknown function at RtlpNtMakeTemporaryKey]
The block is currently used for an object of class: EOutOfResources
-------------------------------------------------------------------------------------
A memory block has been leaked. The size is: 36
This block was allocated by thread 0xB8, and the stack trace (return
addresses) at the time was:
403216 [sys\system.pas][System][@GetMem][2654]
40594D [sys\system.pas][System][@NewAnsiString][12429]
405978 [sys\system.pas][System][@LStrFromPCharLen][12461]
4418A9 [Graphics.pas][Graphics][GDIError][2954]
7C919FFA [Unknown function at RtlpUnWaitCriticalSection]
7C96FD90 [Unknown function at RtlpNtMakeTemporaryKey]
7C96FD74 [Unknown function at RtlpNtMakeTemporaryKey]
7C96F2D7 [Unknown function at RtlpNtMakeTemporaryKey]
7C96FD74 [Unknown function at RtlpNtMakeTemporaryKey]
7C96FD74 [Unknown function at RtlpNtMakeTemporaryKey]
7C94B244 [Unknown function at LdrAlternateResourcesEnabled]
The block is currently used for an object of class: AnsiString
----------------------------------------------------------------------------------------
I will email an example I worked on today which demonstrates the
invalid handle issue. As requested I will send it to your support email.
It is a simple application which creates 10 concurrent threads for 200
reports.
Simon
I have further information regarding this issue. Using the example
we have sent to your support email I have noted that the problem is more
prevalent on Windows 7 than it is on XP. In addition I tried jpg, gif
and bmp formats all at varying bit settings. All produced the invalid
handle issue. In fact when using a 32bit bmp, the error returned was no
longer invalid handle it was Out of resources.
I hope this helps further your investigation with this matter.
Regards
Simon Schaumuller