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 103017 - Big overhead during editing of an element name in a big xml file
Summary: Big overhead during editing of an element name in a big xml file
Status: RESOLVED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: Text-Edit (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Samaresh Panda
URL:
Keywords:
: 103018 (view as bug list)
Depends on: 91893
Blocks:
  Show dependency tree
 
Reported: 2007-04-30 18:48 UTC by Marek Fukala
Modified: 2008-07-09 23:12 UTC (History)
3 users (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-04-30 18:48:11 UTC
to reproduce:
1) open the OTA schema file attached to issue #87024
2) put the caret to the middle of name of an element somewhere at the begining
of the file
3) push a letter key and hold it for a while

=> CPU load is on 100% and the repaint is very slow

The cause of the problem is XMLSyntaxSupport.findMatchingBlock() being called
synchronously from the document change. The scan is very long in such case since
there isn't such element in the document so the scan goes to the end of the file
(or to the beginning if you edit and endtag).

I remembed there was an attempt to call the FMB asynchronously in the editor
infrastrucure, but it was reverted for some reason. Isn't it possible to do that
somehow now?
Comment 1 Vitezslav Stejskal 2007-05-02 02:15:25 UTC
I am not sure if we want to fix this in the old SyntaxSupport. We would like to
prepare a new SPI for braces/tags matching and it should solve this problem.
Comment 2 Marek Fukala 2007-05-02 09:37:33 UTC
OK, that would be cool. I suppose this won't happen in 6.0 right? In such case,
we should do a workaround in the xml editor (probably by extending the ExtCaret
class to use a postponed task to call FMB, and setting the ext. class in
XMLKit.createCaret())????
Comment 3 Vitezslav Stejskal 2007-05-02 10:14:10 UTC
I'm hoping to get it ready for M10, but if I can't make it then we'll have to do
the workaround you suggested.
Comment 4 Marek Fukala 2007-05-02 10:25:51 UTC
Super, thanks for the info. BTW, do you have an issue for that I could use to
watch the progress?
Comment 5 Marek Fukala 2007-05-02 13:26:35 UTC
*** Issue 103018 has been marked as a duplicate of this issue. ***
Comment 6 Marek Fukala 2007-09-26 09:03:48 UTC
still reproducible
Comment 7 Samaresh Panda 2008-02-08 06:18:59 UTC
What's the role of findMatchingBlock() inside a xml document? Is there a way to disable this?
Comment 8 Vitezslav Stejskal 2008-02-08 11:01:51 UTC
Don't use that. There is a new SPI in
http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-editor-bracesmatching/overview-summary.html. Let me know if
you have any problem with using it. Thanks.
Comment 9 Samaresh Panda 2008-02-08 16:00:48 UTC
Sorry, I should have asked differently. Currently, how does the findMatchingBlock() gets invoked in xml? I mean whats
the hook. I want to turn it off and see the improvement.
Comment 10 Marek Fukala 2008-02-10 12:13:13 UTC
just commenting the body out and returning null instead should be enought.
Comment 11 Vitezslav Stejskal 2008-02-11 08:38:25 UTC
The code in editor.bracesmatching looks for BracesMatcherFactory registerted for your document's mime type, if one is
found it's asked to create a BracesMatcher instance. If there is no factory for the given mime type the code falls back
to a default BracesMatcher implementation which tries to call ExtSyntaxSuport.findMatchingBlock if this method is
re-implemented for the document's kit. Otherwise the default matcher uses a simple algorithm for matching certain
characters (eg. brackets, etc).

So, I would say that if you register BracesMatcherFactory for text/xml the instance of BracesMatcher that the factory
returns will be used and ExtSytaxSupport.findMatchingBlocks will never be called again. You can then remove it.

Uh, I just looked at the docs and they seem to give wrong example of a factory registration, the correct way is shown
below. Please note the extra folder called 'BracesMatchers'.

<folder name="Editors">
  <folder name="text">
    <folder name="x-something">
      <folder name="BracesMatchers">
        <file name="org-some-module-BMFactory.instance" />
      </folder>
    </folder>
  </folder>
</folder>

I'll fix the docs asap. Sorry.
Comment 12 Samaresh Panda 2008-02-13 05:45:02 UTC
Thanks vstejskal, this is useful.
Comment 13 Samaresh Panda 2008-07-08 17:26:22 UTC
May be a reason for issue 139181, will try to fix it soon.
Comment 14 Samaresh Panda 2008-07-08 20:34:17 UTC
Part 1: http://hg.netbeans.org/main?cmd=changeset;node=bfd41ad8c781
Added new brach matcher, not enabled yet.
Comment 15 Samaresh Panda 2008-07-09 20:44:03 UTC
Part2: Enabled the new matcher
http://hg.netbeans.org/main?cmd=changeset;node=066d52715050.
Comment 16 Jesse Glick 2008-07-09 23:12:30 UTC
Caused

http://deadlock.netbeans.org/hudson/job/trunk/2706/testReport/org.netbeans.core.projects/ValidateLayerConsistencyTest/testFolderOrdering/

No warnings relating to folder ordering in [Editors/text/xml/BracesMatchers, Editors/BracesMatchers] expected:<[]> but
was:<[Not all children in / marked with the position attribute:
[org-netbeans-modules-xml-text-bracematch-XMLBraceMatcherFactory.instance], but some are:
[org-netbeans-modules-editor-bracesmatching-LegacyEssMatcher.instance,
org-netbeans-modules-editor-bracesmatching-DefaultMatcher.instance]]>