Page 1 of 1

GUI slowdowns

PostPosted: 02 Aug 2012, 21:55
by Max mtg
Investigating further game slowndowns I have come across mutiple repainting of PlayArea.
To see that, consider placing this code at the beginning of forge.view.arcane.PlayArea.wrap(CardStackRow, List<CardStackRow>, int)

Code: Select all
    private int cntRepaints = 0;
    private int wrap(final CardStackRow sourceRow, final List<CardStackRow> rows, final int insertIndex) {
        // The cards are sure to fit (with vertical scrolling) at the minimum
        // card width.
        final boolean allowHeightOverflow = this.cardWidth == this.getCardWidthMin();

        System.err.format("[%d] @ %d - Repaint playarea%n", new Date().getTime(), cntRepaints++);
I have started a match (ai won the coin) and played only a land. By that time there already were 2666 repaints in at least one of instances. The repaint counter bursts when phases are switched or any kind of animation happens.
I also ran profiler to play a number of turns in a match - there were some 146k calls to wrap(...), that summed up took 5 seconds.

There should not be that many repaints. Who knows what causes them?

Re: GUI slowdowns

PostPosted: 03 Aug 2012, 22:44
by Max mtg
What I've learnt - doLayout of playarea iterates from maxCardWith till 50 until it finds a value when cards fit into playarea size. Each iteration include arraylist creation and other kind of collection management.

I have changed some code so that the costly method wrap is called 20 times less often. Expect low-end PCs to benefit from this change.