This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 151916

Summary: Editor very slow in rendering single line javascript/css files resulting in Netbeans hang
Product: editor Reporter: Sonali Kochar <sonali>
Component: Painting & PrintingAssignee: Miloslav Metelka <mmetelka>
Status: RESOLVED FIXED    
Severity: blocker CC: issues
Priority: P4 Keywords: PERFORMANCE
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 121357, 150204    
Bug Blocks:    

Description Sonali Kochar 2008-10-30 22:35:27 UTC
The HTTP Client monitor displays the HTTP response body in a JEditor. If the response body is not formatted i.e all the
content is in single line, then the editor has performance issues while rendering the files causing Netbeans to hang. 

Please see issue 148996 for:
1) Stack traces
2) Profiler call tree
3) Profiler hot spots
4) A sample project to reproduce the issue

Please note we implemented a workaround for issue 148996 so to see this issue you need to get version 104156 of
org.netbeans.modules.web.client.javascript.debugger.http.ui.HttpMonitorTopComponent.java

Please email me if you need any help in reproducing the issue
Comment 1 Jan Becicka 2008-11-03 08:39:13 UTC
Milo, please evaluate. Thanks
Comment 2 Miloslav Metelka 2008-11-03 14:25:04 UTC
I was able to reproduce the problem in current dev build.
There does not seem to be anything wrong but I will continue profiling of the highlighting layers to search for
improvements.
The single-line javascript has ~100K of text.
I personally don't see what's a benefit for the user to see 100K of text on a single line. IMHO the line should be
reformatted into a regular indented text so that the user can orient in it.
I'm downgrading to P3 since this is not a typical editing usecase.
Comment 3 Miloslav Metelka 2008-11-07 10:10:16 UTC
I have made some additional profiling. There are
1) 103389 chars in the js-script-min.js document.
2) 7 BaseDocument.insertString() invocations (there is a buffer with 16384 chars for insertions).
  These could be collapsed into a single insert by reallocating the buffer before the actual insert but I consider that
non-systematic.
3) 38804 tokens in the document.

I see two problems:
a) Since almost all the chars are on a single line each repetitive insertion in 2) causes re-measurement of the
particular line in the view hierarchy (DrawEngineLineView.getPreferredSpan() gets called leading to DrawEngine.draw()
called for measurements).
  - A new view hierarchy (issue 121357) should improve the situation considerably since the views will maintain their
span internally so there will be no additional re-measurements done.
b) Token hierarchy is updated after each sub-insert in 2) leading to repetitive updates of syntax highlighting layer.
  - This should be improved by switching the TH off before document loading and on after the loading - issue 150204
(planned for 7.0).

I have added some logging of syntax highlighting and token hierarchy events and views rebuilding:
http://hg.netbeans.org/main/rev/d29e247a6daa
Comment 4 Quality Engineering 2008-11-07 16:20:20 UTC
Integrated into 'main-golden', will be available in build *200811071401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/d29e247a6daa
User: Miloslav Metelka <mmetelka@netbeans.org>
Log: #151916 - Editor very slow in rendering single line javascript/css files resulting in Netbeans hang.
Comment 5 David Strupl 2012-10-25 13:39:16 UTC
Bug prior to 7.0, not touched for the last 2 years --> P4.
Comment 6 David Strupl 2012-10-26 13:35:55 UTC
I think this was fixed long ago by Mila.