Jerky form transition

77 views
Skip to first unread message

Bryan Buchanan

unread,
Nov 22, 2014, 11:55:25 PM11/22/14
to codenameone...@googlegroups.com
I had two apps (call them A and B) which did different stuff. My customer wanted to combine them, so I merged the themes and code and it all works as it should except in one form transition. App B is made up of  (1) a form with list -> (2) form with list -> (3) detail form with some containers in a BoxLayoutY.

Every form transition works fine except the last to the detail form. If I use the default slide, very occasionally the form gets stuck mid transition. Fade also has a noticable lag. If I set the transition to "empty", it's super fast and there is no issue.

I'm testing on a Huawei Y300 with Android 4.1.1 - not a super powerful device. I'm thinking that the fact there was no issue when app B was standalone, it feels like it might be a garbage collection "problem".

Any ideas on what I can look at. (I'm OK with no transitions, so it's not a show stopper).

Shai Almog

unread,
Nov 23, 2014, 1:18:34 AM11/23/14
to codenameone...@googlegroups.com
Usually when things like that perform badly its due to using gradients, or many small images (e.g. border cut too narrowly).

Bryan Buchanan

unread,
Nov 28, 2014, 4:30:40 AM11/28/14
to codenameone...@googlegroups.com
I've just re-compiled another app, which had slide form transitions, and a side menu, which all previously worked flawlessly. Now with just a re-compile, the side menu sometimes only half opens, and the form slide doesn't always complete (i.e. half of the old and half of the new form are visible).

Pretty much the app is unusable in the current state.

Wondering if anyone else has had any recent performance issues.

Shai Almog

unread,
Nov 28, 2014, 11:26:52 AM11/28/14
to codenameone...@googlegroups.com
Did you disable the new Android pipeline? Was it an app you did before that was introduced?

Bryan Buchanan

unread,
Nov 28, 2014, 2:35:46 PM11/28/14
to codenameone...@googlegroups.com
Works perfectly with old pipeline. Is this my problem or yours ? Is there anything I need to change in my code ? I'm not doing any paints myself and only using standard CN1 stuff.

Shai Almog

unread,
Nov 29, 2014, 1:29:42 AM11/29/14
to codenameone...@googlegroups.com
Do you have any gradients, multiple layers of drawing/translucency etc.?
You should fix your code to work better with the new pipeline otherwise it will perform badly on newer super high DPI devices.

Bryan Buchanan

unread,
Nov 29, 2014, 1:35:41 AM11/29/14
to codenameone...@googlegroups.com
None of those. Form has a background image (640x640) image_scaled_fill and the app consists of a few forms which are mainly Lists with a custom cell renderer and one form with a few regular components, all of which are styled using the normal CN1 themeing.

Bryan Buchanan

unread,
Nov 29, 2014, 6:41:55 AM11/29/14
to codenameone...@googlegroups.com
It's got me beat. I've tried a few things (like removing image borders) but still get problems with the new graphics pipeline. Attached are a couple of screen shots where the form transitions have just hung between forms. Also an Android monitor dump showing the app using lots of CPU when in that state.

Shai Almog

unread,
Nov 29, 2014, 10:25:39 AM11/29/14
to codenameone...@googlegroups.com
I'm guessing the custom renderer which I assume does some low level graphics might be the root of it.
I would also suggest to always use a multi image for the background rather than a fixed size image which might not be appropriate for all device resolutions.

Bryan Buchanan

unread,
Nov 29, 2014, 2:56:33 PM11/29/14
to codenameone...@googlegroups.com
The renderer does nothing out of the ordinary:
public class CelectOptionsRenderer extends Container implements ListCellRenderer {

    Label title;
    Label focus;

    public CelectOptionsRenderer(Resources res) {

        title = new Label();
        title.setUIID("MyLabel");
        
        int h = Display.getInstance().convertToPixels(8, false);
        setPreferredH(title.getPreferredH() < h ? h : title.getPreferredH());

        setLayout(new BorderLayout());
        addComponent(BorderLayout.WEST, title);
        setUIID("Underline");

        focus = new Label("");
        focus.setUIID("UnderlineSelected");

    }

    public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
        EngineModel emodel = (EngineModel) value;
        title.setText(emodel.model);

        return this;
    }

    public Component getListFocusComponent(List list) {
        return focus;
    }
}

Bryan Buchanan

unread,
Nov 29, 2014, 6:04:53 PM11/29/14
to codenameone...@googlegroups.com
Solved !

I had a form with 4 containers, each container had a Label and TextArea. I styled the Label with a background that was GRADIENT_LINEAR_HORIZONTAL. Once I changed this to GRADIENT_LINEAR_VERTICAL it works fine. A bit weird, but there you go. I'm wondering if in general is it better performance wise to use an image rather than a linear gradient for backgrounds ?

Shai Almog

unread,
Nov 30, 2014, 1:25:21 AM11/30/14
to codenameone...@googlegroups.com
I suggest removing the gradient completely and using a background image. Gradients are REMARKABLY slow on all platforms see http://www.codenameone.com/how-do-i---improve-application-performance-or-track-down-performance-issues.html
Reply all
Reply to author
Forward
0 new messages