MiG InfoCom

Extreme validate/repaint/draw/display times
Page 1 of 1

Author:  Karlovsky120 [ Thu Apr 04, 2013 3:07 am ]
Post subject:  Extreme validate/repaint/draw/display times

I have MiGLayout 4.2

I have a program (Java 1.7) that displays a strucutred Document made out of several layers of JPanels (about 5-8 layers) and JTextAreas.

The creation of such Document is fast, but when it comes to adding it to another component and drawing it on screen, process takes way more time to than it should (several seconds for 60ish JTextAreas).

Using VisualVM 1.3.5, I have found out that net.miginfocom.swing.SwingComponentWrapper.getLayoutHashCode() takes very long to execute and that it makes excesive number of calls to net.miginfocom.swing.MigLayout.checkParent(java.awt.Container).

It is also possible that this has something to do with getWidth()/getHeight() methods in net.miginfocom.swing.SwingComponentWrapper package being called recursively.

If you want to test it out by yourself, I have uploaded my program here:
File comment: My program (Java 1.7). It requres iText 5.3.1 to be able to test it. I needs to be run as an Eclipse project.
src.rar [31.22 KiB]
Downloaded 1005 times

Parts of program relevant to the problem are pscript.gui.elements package, pscript.gui.windows.Open dialog class, pscript.gui.processing.Opener class and pscript.gui.Gui class.

In order to test it, you can File->Open a pdf I have here with my program:
File comment: The test file.
testFile.pdf [7.51 KiB]
Downloaded 1059 times

It should populate about two and a half pages of my document. The JTabbedPane.addTab(String name, JScrollPane scrollPane); or documentSelector.addTab(counter+"", document); in my program, Class Gui, line 37) is the one that takes a bunch of time to execute.

I have both samplerSnapshot and profilerOutput of the VisualVM for opening the given file. Notice that net.miginfocom.swing.MigLayout.checkParent(java.awt.Container)) was called over 160 000 times:
File comment: Sampler and profiler results of VisualVM
VisualVM output.rar [10.2 KiB]
Downloaded 1053 times

I believe it's a bug related to painting a bunch of components when their size is not defined. It seems like the layout is expanding the components pixel by pixel until it reaches the appropriate size. But that's just my guess. Thank you for your help in advance.

Author:  MiG Support [ Fri Apr 05, 2013 3:04 pm ]
Post subject:  Re: Extreme validate/repaint/draw/display times


Can you test if ML 5.0 fixes the problem it would be good. Otherwise I will check it out.

I have attached the two jars.


Archive.zip [88.33 KiB]
Downloaded 1029 times

Author:  Karlovsky120 [ Fri Apr 05, 2013 4:46 pm ]
Post subject:  Re: Extreme validate/repaint/draw/display times

Thank you for your time! =)

I have tried the Snapshot you provided, but the problem still persists.
However, there were some differences. With MigLayout 4.2, net.miginfocom.swing.MigLayout.checkParent(java.awt.Container) was called 203 463 times, but with the new 5.0 version 205 253 times. Yet again, for a number this big, 1 790 call number difference might be irelevant...

I was using the testFile.pdf attached in the first post for testing with VisualVM 1.3.5.

Author:  MiG Support [ Fri Apr 05, 2013 6:08 pm ]
Post subject:  Re: Extreme validate/repaint/draw/display times

Unfortunately I don't use Eclipse or VisualVM (IDEA and JProfiler).

But, if you are using relative sizes (like a percentage of parent) without setting the size of the parent explicitly these kinds of things happen. Basically the layout isn't "stable" and need continuous recursion until it stabilizes. This is very hard problem to get around for all cases.


Author:  Karlovsky120 [ Sun Apr 07, 2013 1:07 am ]
Post subject:  Re: Extreme validate/repaint/draw/display times

I'm sure then that the problem is what you just said.

Could you, if it's not to big of a hassle, give me some tips on fixing the problem or at least give me some links that may hold more info on the topic?

Thank you.

Author:  Karlovsky120 [ Sun Jul 07, 2013 5:21 am ]
Post subject:  Re: Extreme validate/repaint/draw/display times

Okay, I have an idea.

Is it possible to specify the exact height or width a component has to have when drawn, but to then keep it flexible and adjustable to any changes made to it that would require it to change it's size? So, the same thing I was doing, but to tell it what size it's supposed to be so it doesn't have to recall that method 250k times.

I asked on several other pages, but people either didn't want to or knew the answer...

Page 1 of 1 All times are UTC + 2 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group