View unanswered posts | View active topics It is currently Fri May 26, 2017 6:02 pm



Reply to topic  [ 6 posts ] 
 Extreme validate/repaint/draw/display times 
Author Message

Joined: Sat Jan 19, 2013 12:15 am
Posts: 5
Post 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:
Attachment:
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:
Attachment:
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:
Attachment:
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.


Thu Apr 04, 2013 3:07 am
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Extreme validate/repaint/draw/display times
Hello,

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.

Cheers,
Mikael


Attachments:
Archive.zip [88.33 KiB]
Downloaded 1027 times
Fri Apr 05, 2013 3:04 pm
Profile WWW

Joined: Sat Jan 19, 2013 12:15 am
Posts: 5
Post 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.


Fri Apr 05, 2013 4:46 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post 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.

Cheers,
Mikael


Fri Apr 05, 2013 6:08 pm
Profile WWW

Joined: Sat Jan 19, 2013 12:15 am
Posts: 5
Post 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.


Sun Apr 07, 2013 1:07 am
Profile

Joined: Sat Jan 19, 2013 12:15 am
Posts: 5
Post 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...


Sun Jul 07, 2013 5:21 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.