Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET ReportViewer Google Chrome CPU usage

We have found an interesting issue between ASP.NET 3.5 and ReportViewer with Google Chrome. Our set of pages work fine until a ReportViewer control displays a report.

Google Chrome then eats up 50% of the CPU doing nothing it seems.

I've extracted the ReportViewer control to a blank Web Forms project to confirm its that control and not a rogue bit of my code.

I'm using ReportViewer in local mode (RDLC file) so I presume its the 2005 version?

Anyone seen this before and have a solution?

Phil

Edit: Google Chrome 3.0.195.33 on Vista Business x64

Edit 2: Added bounty for help fixing this

like image 248
Phil Avatar asked Nov 23 '09 17:11

Phil


2 Answers

The solution is actually some of the ReportViewer JavaScript causes an infinite loop in Chrome, I am posting the source code on how to solve this issue by making a custom version of the ReportViewer control and fixing the broken JavaScript (I've lost the link to the solution, but I didn't write this, just used it :))

I can confirm that now we have upgraded to the newest ReportViewer in Visual Studio 2010, the Chrome CPU issue no longer exists and this work around isn't required.

public class MyReportViewer : Microsoft.Reporting.WebForms.ReportViewer
{
    protected override void Render(HtmlTextWriter writer)
    {
        using (StringWriter sw = new StringWriter())
        {
            HtmlTextWriter tmpWriter = new HtmlTextWriter(sw);
            base.Render(tmpWriter);
            string val = sw.ToString();
            val = val.Replace(@"!= 'javascript:\'\''", @"!= 'javascript:\'\'' && false");
            writer.Write(val);
        }
    }
}
like image 89
Phil Avatar answered Sep 22 '22 14:09

Phil


There's a thread on the Google Chrome forums talking about this. I don't know if it's possible for you to run the report on the server instead of locally, which seems to fix the issue. Here's the thread: ReportViewer rendering maxes out thread CPU usage

like image 23
jvilalta Avatar answered Sep 20 '22 14:09

jvilalta