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 114359 - SemanticHighlightLayer causes the HL to be refreshed multiple times after an editor change
Summary: SemanticHighlightLayer causes the HL to be refreshed multiple times after an ...
Status: RESOLVED FIXED
Alias: None
Product: obsolete
Classification: Unclassified
Component: languages (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@obsolete
URL:
Keywords: PERFORMANCE
Depends on:
Blocks: 110302
  Show dependency tree
 
Reported: 2007-08-31 12:35 UTC by Marek Fukala
Modified: 2007-09-24 15:33 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Fukala 2007-08-31 12:35:27 UTC
When dealing with issue #112464 and #110302 I found that SHL fire multiple highlight changes to the HL infrastructure.
This leads to unnecessary calls to highlight layers which is along with the problem of issue #112464 quite a big
performance problem.

1) SemanticHighlightLayer.parsed method fires the HL change even when the parsing just started. The method should IMHO
fire only when parsed, or at least when the parser state != PARSING:

        public void parsed (State state, ASTNode root) {
+            if(state != State.PARSING) {
                fireHighlightsChange (0, document.getLength ());
+            }
        }

2) there are multiple instancies of SemanticHighlighLayer (I am seeing three) and each of them fires the events to the
HL which seems to be completely unnecessary.

+) when debugging the whole stuff I also found that there are more instancies of EditorParser (4) and each of them hold
different instance of j.t.s.Document !!! Two instancies are empty and two contains the real data.
Comment 1 Daniel Prusa 2007-09-03 10:36:04 UTC
We should reduce change event fires in SHL as well as the multiple instances of SHL and EditorParser.
Comment 2 Jan Jancura 2007-09-20 14:01:06 UTC
1) fixed
2) This is editor issue, looks like some bug in HighlightingManager or HighlightingDrawLayer. HighlightingDrawLayer
Creates one instance of GLFHighlightsLayerFactory. But it calls GLFHighlightsLayerFactory.createLayers three times and
it created three instances of SemanticHighlightsLayer for one document.
+) I am not able reproduce it.
Comment 3 Vitezslav Stejskal 2007-09-20 15:36:00 UTC
re #2: Highlighting layers are recreated whenever a new document is set in JEditorPane or when coloring settings change.
It's a known issue that when opening a file three document instances are set on the JEditorPane created for the file.
Only the last Document instance holds the loaded text. The unnecessary documents and highlighting layers should be GCed
soon after that. And they normally are, at least in our unit tests. I'll have a look if this is true for
GLFHighlightsLayerFactory layers as well.
Comment 4 Vitezslav Stejskal 2007-09-24 15:31:20 UTC
re #2: The primary problem was in SemanticHighlightsLayer and TokenHighlightsLayer, which were hard referenced from
Highlighting and ParserManager through their PropertyChangeListeners.

Checking in SemanticHighlightsLayer.java;
/cvs/languages/engine/src/org/netbeans/modules/languages/features/SemanticHighlightsLayer.java,v  <-- 
SemanticHighlightsLayer.java
new revision: 1.10; previous revision: 1.9
done
Checking in TokenHighlightsLayer.java;
/cvs/languages/engine/src/org/netbeans/modules/languages/features/TokenHighlightsLayer.java,v  <-- 
TokenHighlightsLayer.java
new revision: 1.3; previous revision: 1.2
done
Comment 5 Vitezslav Stejskal 2007-09-24 15:33:43 UTC
Should be fixed now. The listeners are weak and the unused layers are garbage collected soon after their creation.