Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 322762 - BIRT always hangs when render rptdocument file to MS word document
Summary: BIRT always hangs when render rptdocument file to MS word document
Status: RESOLVED NOT_ECLIPSE
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.5.2   Edit
Hardware: PC Windows XP
: P3 blocker (vote)
Target Milestone: 3.7.0   Edit
Assignee: Birt-ReportEngine-inbox@eclipse.org CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-16 05:23 EDT by Alex Chen CLA
Modified: 2011-05-26 13:32 EDT (History)
5 users (show)

See Also:


Attachments
The rptdocument file (220.01 KB, application/x-zip-compressed)
2010-08-16 05:28 EDT, Alex Chen CLA
no flags Details
the patch (974 bytes, text/plain)
2010-08-18 05:42 EDT, Alex Chen CLA
no flags Details
the patch (1.42 KB, text/plain)
2010-08-18 05:43 EDT, Alex Chen CLA
no flags Details
the new report document (217.43 KB, application/x-zip-compressed)
2010-08-24 06:16 EDT, Alex Chen CLA
no flags Details
the report library which removed script (1.13 MB, application/octet-stream)
2010-08-24 06:18 EDT, Alex Chen CLA
no flags Details
The original report library (1.14 MB, application/octet-stream)
2010-08-24 06:20 EDT, Alex Chen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Chen CLA 2010-08-16 05:23:28 EDT
Build Identifier: 2.5.2

I use BIRT report engine API to generate MS word, when I upgrade to BIRT 2.5.2 release(org.eclipse.birt.report.engine_2.5.2.v20100210.jar), BIRT always hangs when render rptdocument to MS word.

I used to use BIRT org.eclipse.birt.report.engine_2.2.2.r22x_v20080107.jar, it works fine for us.

I will upload rptdocument file for your debugging.

Reproducible: Always
Comment 1 Alex Chen CLA 2010-08-16 05:28:21 EDT
Created attachment 176661 [details]
The rptdocument file
Comment 2 Xiaoying Gu CLA 2010-08-18 03:27:44 EDT
(In reply to comment #1)
> Created an attachment (id=176661) [details]
> The rptdocument file

Hi,

I can not reproducing this issue using ReportEngine 2.5.2 release.

Commandline I was using:
E:\test\Release Build\2_5_2\ReportEngine>genReport.bat -m render -f doc -o test.
doc "Config A.rptdocument"

The document was rendered into 10 doc files successfully.
Comment 3 Alex Chen CLA 2010-08-18 05:42:29 EDT
Created attachment 176877 [details]
the patch
Comment 4 Alex Chen CLA 2010-08-18 05:43:25 EDT
Created attachment 176878 [details]
the patch
Comment 5 Alex Chen CLA 2010-08-18 05:45:34 EDT
Hi Xiaoying,

Thanks very much for your quickly response!

Where did you get genReport.bat? can I download it from BIRT site?

Actually, I use a 2.5.2 BIRT engine with two patches by ourselves
1. https://bugs.eclipse.org/bugs/show_bug.cgi?id=316239
2. https://bugs.eclipse.org/bugs/show_bug.cgi?id=316240

I will upload those patches, and source/binary BIRT engine patched with those two patches.

1. bugzilla-316239-patch.txt
2. bugzilla-316240-patch.txt
3. org.eclipse.birt.report.engine.zip : the source code of BIRT report engine, patched with those two patches.
4. org.eclipse.birt.report.engine_2.5.2.v20100805.jar : the binary one we use.


Thanks again,
--Alex
Comment 6 Alex Chen CLA 2010-08-18 05:47:38 EDT
Hi Xiaoying,

The last two source/binary of BIRT engine are two big for bugzilla, I can't upload them as attachment.

I will send you by email, thanks for understanding.

Thanks,
--Alex
Comment 7 Alex Chen CLA 2010-08-18 22:53:30 EDT
I can generate ms doc success with my own binary patched BIRT report engine using BIRT runtime, so I think the hanging issue maybe cause by some options I use in our render code.

Seems this bug relate to: https://bugs.eclipse.org/bugs/show_bug.cgi?id=308155

Thanks,
--Alex
Comment 8 Xiaoying Gu CLA 2010-08-18 23:09:47 EDT
(In reply to comment #5)
> Where did you get genReport.bat? can I download it from BIRT site?

genReport.bat is shipped in birt-runtime package. You can find it under ReportEngine directory.
Comment 9 Jun Ouyang CLA 2010-08-18 23:22:48 EDT
Alex,

Can you show us the render options you set? Can you reproduce this problem on latest BIRT?
Comment 10 Alex Chen CLA 2010-08-18 23:29:06 EDT
Hi, 

Below is the code I used to render rptdocument, but unfortunately, I still hangs during render even I comment out all those doubtable options.

Thanks,
--Alex




	public void doPresentation(IProgressMonitor monitor){
		if(status == IStatus.ERROR) return;
		IReportDocument doc = null;
		try {
//			doc = engine.openReportDocument(docFile);
			doc = ReportDocument.getInstance(engine, docFile, toc);
		} catch (EngineException e1) {
			PublishDocPlugin.getDefault().getLogger().logError(e1);	
		}
		renderTask = engine.createRenderTask(doc);
		RenderOption option = new RenderOption();
//		option.setOption(PDFRenderOption.FIT_TO_PAGE, true);
//		option.setOption(PDFRenderOption.PAGEBREAK_PAGINATION_ONLY, false);
//		option.setOption(PDFRenderOption.HTML_PAGINATION, false);
		output = options.getOutputFilename();
		option.setOutputFileName(output);
		if(options.getOutputFormat()==PublishDocOptions.OUTPUT_FORMAT_PDF)
			option.setOutputFormat(IRenderOption.OUTPUT_FORMAT_PDF);
		else if(options.getOutputFormat()==PublishDocOptions.OUTPUT_FORMAT_MSWORD)
			option.setOutputFormat("doc"); //$NON-NLS-1$
		option.setSupportedImageFormats("JPG;PNG;BMP;SVG"); //$NON-NLS-1$
//		option.setOption("htmlPagination", Boolean.TRUE); //$NON-NLS-1$
		renderTask.setRenderOption(option);
		monitor.subTask(PublishingDocResource.renderingReport);		
		renderTask.setAppContext(new HashMap());
		Runnable runnable = new Runnable(){				
			public void run() {					
				try {
//					Context.enter();
					renderTask.render();
//					Context.exit();
				} catch (EngineException e) {						
					PublishDocPlugin.getDefault().getLogger().logError(e);				
				}				
			}							
		};						
		Thread th = new Thread(runnable);			
		th.start();						
		while(renderTask.getStatus()==IEngineTask.STATUS_NOT_STARTED || 					
				renderTask.getStatus()==IEngineTask.STATUS_RUNNING){				
			if(monitor.isCanceled()){					
				renderTask.cancel();				
			}				
			try {					
				Thread.sleep(100);				
			} catch (InterruptedException e) {					
				PublishDocPlugin.getDefault().getLogger().logError(e);					
			}			
		}
//		renderTask.close();
		doc.close();
		if(renderTask.getStatus()==IEngineTask.STATUS_SUCCEEDED)
			status = IStatus.OK;
		renderTask = null;
	}
Comment 11 Alex Chen CLA 2010-08-19 01:26:57 EDT
Hi Xiaoying/Jun,

Use the function I provide to render the rptdocument I attached, BIRT always hangs.

Please test it.

Thanks much,
--Alex
Comment 12 Alex Chen CLA 2010-08-19 01:57:24 EDT
1. Use the method I provided, BIRT render will hang at:

Class: /org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/html/HTMLPageLM.java

lines: boolean hasNextPage = layoutNodes( );

********************************************************
	public boolean layout( ) throws BirtException
	{
		if ( context.getCancelFlag( ) )
		{
			close( );
			isLastPage = true;
			return false;
		}
		start( isFirstPage );
		boolean hasNextPage = layoutNodes( );
		if ( isChildrenFinished( ) )
		{
			isLastPage = true;
		}
		isFirstPage = false;
		end( isLastPage );
		context.initilizePage( );
		return hasNextPage;
	}
*********************************************************

2. If open the comment in my method 

line: option.setOption(PDFRenderOption.HTML_PAGINATION, false);

Then the render will be OK.

3. Could you please explain the HTML_PAGINATION to me? and is it a BIRT bug?

Thanks,
--Alex
Comment 13 Alex Chen CLA 2010-08-19 01:59:11 EDT
Sorry, the above item 2 should be:

2. If open the comment in my method 

line: option.setOption("htmlPagination", Boolean.TRUE);

Then the render will be OK.
Comment 14 Alex Chen CLA 2010-08-19 05:32:04 EDT
option.setOption(PDFRenderOption.HTML_PAGINATION, false);

and 

option.setOption("htmlPagination", Boolean.TRUE);

are the same thing.

If I set
option.setOption(PDFRenderOption.HTML_PAGINATION, true);
Then I can render ms doc correctly, but I still failed on render to pdf.

Could you guys help me on this?

Thanks,
--Alex
Comment 15 Alex Chen CLA 2010-08-19 06:11:39 EDT
I check the different between /org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/ReportRunner.java and my code, the different is ReportRunner only create doc/pdf page by page, but my code generate a whole doc/pdf.

For example:

		try {
			renderTask.setPageRange(1);
			renderTask.render();
		} catch (EngineException e) {
			e.printStackTrace();
		}

works for me, both pdf and doc.

but

		try {
			renderTask.setPageRange("ALL");
			renderTask.render();
		} catch (EngineException e) {
			e.printStackTrace();
		}

didn't work.

If I set option.setOption(PDFRenderOption.HTML_PAGINATION, true), then doc works, but pdf still doesn't work.

Thanks,
--Alex
Comment 16 Yu Chen CLA 2010-08-19 07:18:28 EDT
The onRender( ) script of text item( id="1427114657") causes the endless loop.
Comment 17 Yu Chen CLA 2010-08-19 07:19:22 EDT
sorry, the text item id is 1427112705.
Comment 18 Alex Chen CLA 2010-08-19 08:46:02 EDT
Hi Albert,

Thanks for response, do you have any idea on how to fix it? since I can generate rptdocument correctly, I don't think it's an issue of our report design, right?

Cheers,
--Alex
Comment 19 Alex Chen CLA 2010-08-19 08:51:35 EDT
Also, this is an regression issue, because it works well on Eclipse 3.3.2 , and right now we upgrade our product to Eclipse 3.5.2.

--Alex
Comment 20 Wei Yan CLA 2010-08-19 13:54:41 EDT
Alert,

Which statement in the onRender causes the endless loop? Is it a BIRT API or call or user's scripts? If it is BIRT API, we need fixed in 2.6.1.

If it is the user's script, can you investigate what changes cause the issue?
Comment 21 Yu Chen CLA 2010-08-20 05:03:17 EDT
It's the user's script leads the endless loop. 

It seems it occurs around here: 

while(itor!=""){
	for(var i=0;i<count;i++){
		if(itor==guids[i]){
			sortedResult[c]=PNames[i]==""?names[i]:PNames[i];
			c++;
			activityNum=c;
			itor=superActivities[i];
		}
	}
}

Alex, could you check the logic of the script? Because the same report document works well if you try to render it page by page.
Comment 22 Alex Chen CLA 2010-08-20 05:34:02 EDT
Hi Albert,

1. I will check our rptlibrary.

2. Could you please explain why the option below will cause different result when render to ms doc?

option.setOption(PDFRenderOption.HTML_PAGINATION, true);  ---> success
option.setOption(PDFRenderOption.HTML_PAGINATION, false);  ---> fail

3. why the render works well under Eclipse 3.3.2?

Thanks,
--Alex
Comment 23 Alex Chen CLA 2010-08-24 06:13:43 EDT
(In reply to comment #21)
> It's the user's script leads the endless loop. 
> 
> It seems it occurs around here: 
> 
> while(itor!=""){
>     for(var i=0;i<count;i++){
>         if(itor==guids[i]){
>             sortedResult[c]=PNames[i]==""?names[i]:PNames[i];
>             c++;
>             activityNum=c;
>             itor=superActivities[i];
>         }
>     }
> }
> 
> Alex, could you check the logic of the script? Because the same report document
> works well if you try to render it page by page.

Hi Albert,

I've removed the row from our report library which contains the script you indicated, but the pdf generating still hangs.

Please see the attached report library and report document.

thanks,
--Alex
Comment 24 Alex Chen CLA 2010-08-24 06:16:59 EDT
Created attachment 177294 [details]
the new report document
Comment 25 Alex Chen CLA 2010-08-24 06:18:37 EDT
Created attachment 177295 [details]
the report library which removed script
Comment 26 Alex Chen CLA 2010-08-24 06:20:12 EDT
Created attachment 177296 [details]
The original report library
Comment 27 Yu Chen CLA 2010-08-25 02:00:08 EDT
This time it hangs at the onRender script of text item 1427112717.

Actually, this section of script has many copies in the report. Since it will not cause endless loop if the report is rendered page by page, is the pagination affects the value of the variables in the script? Could you debug into the two cases, and find out the difference of the variable value?
Comment 28 Alex Chen CLA 2010-08-25 22:49:57 EDT
(In reply to comment #27)
> This time it hangs at the onRender script of text item 1427112717.
> 
> Actually, this section of script has many copies in the report. Since it will
> not cause endless loop if the report is rendered page by page, is the
> pagination affects the value of the variables in the script? Could you debug
> into the two cases, and find out the difference of the variable value?

Thanks Albert, I will investigate and post you the result.

Cheers,
--Alex
Comment 29 Alex Chen CLA 2010-09-01 03:04:25 EDT
Hi BIRT guys,

This issue has been fixed, it caused by the endless loop in javascript code of our report library.

thank very much for all of your help!!
--Alex
Comment 30 Yu Chen CLA 2010-09-01 03:11:01 EDT
Since the issue is resolved, close the bug.