An exception occurred during transition paint this might be valid in case of a resize in the middle of a transition

53 views
Skip to first unread message

Gareth Murfin

unread,
Oct 24, 2016, 5:14:17 AM10/24/16
to CodenameOne Discussions
Ive come back to an app I have not touched in around 2 months. Suddenly it is freezing and it is very hard to pin point. I just updated the libs to see if it had been fixed, after that it does give me an exception, can anyone explain whats going wrong here?

An exception occurred during transition paint this might be valid in case of a resize in the middle of a transition
java.lang.StackOverflowError
at com.codename1.ui.geom.GeneralPath$Ellipse._addToPath(GeneralPath.java:971)
at com.codename1.ui.geom.GeneralPath$Ellipse._addToPath(GeneralPath.java:968)
at com.codename1.ui.geom.GeneralPath$Ellipse._addToPath(GeneralPath.java:969)

Gareth Murfin

unread,
Oct 24, 2016, 5:43:45 AM10/24/16
to CodenameOne Discussions
Note, I do use general path and drawshape:

private void drawCircleBar(Graphics g, int pullToTheLeftPixels, int angleToStartOn, int angleToEndOn, int colour)
    {
        GeneralPath pathDynamic = new GeneralPath();
        strokeWidth= myWidth/17;
        g.setColor(0xffffff);
        
        if (stroke == null)
        {
            stroke = new Stroke(strokeWidth, Stroke.CAP_BUTT, Stroke.JOIN_ROUND, 1f);
        }              
        
        //for testing
        /*
        if (progress++>=100)
        {
            progress=0;
        }*/
        
        //debug:
        //g.drawRect(getX(),getY(), myWidth, myHeight);
        //draw in centre so we can see where it is
        //g.drawRect( getX()+(myWidth/2)-5,getY()+(myHeight/2)-5, 10, 10);
        
        g.setFont(f);
        g.setAntiAliased(true);        
        int pixelsToMoveTextAndImageDown = getHeight()/14;
        
        //draw full arc        
        int sideAngle = 50; //the amount of degrees less than a semi circle (180)
        double startAngle       = Math.toRadians(angleToStartOn+sideAngle);//180 for perfect semi circle, but it isnt, so 220
        double angleComplete    = Math.toRadians(angleToEndOn-sideAngle);                  
        int circleW = myHeight;
        if (circleW>myWidth)
        {
            circleW=myWidth;
        }
      /////no need  circleW-=strokeWidth*2;
        circleW+=strokeWidth*3;
        
        int circleH = circleW;                
        int xPos = getX()+((myWidth/2)-(circleW/2))-pullToTheLeftPixels;
        int yPos = getY()+(myHeight/4);//getY()+myHeight/2;//getY()+strokeWidth;

        pathStatic.arc(xPos, yPos, circleW, circleH , startAngle, angleComplete);
        g.drawShape(pathStatic, stroke);                

        //_("progress:"+progress+" which is "+(progress*3.6));
        String percentageStr = ""+progress+"%";
        int stringWidth = f.stringWidth("XXX");        
        
        Image thumbImage = thumbsUp;
        Image thumbImageSelected = thumbsUpSelected;
        switch (myPos)
        {
            case PROGRESS_BAR_LEFT:                    
                break;
            case PROGRESS_BAR_RIGHT:
                pullToTheLeftPixels = -(int)(stringWidth/1.1f);//so it sits a bit more right
                thumbImage = thumbsDown;
                thumbImageSelected = thumbsDownSelected;
                pixelsToMoveTextAndImageDown = thumbsUp.getHeight()/3;
                break;
        }       
        //tweaks for different rews, 
        
        int yForThumb = f.getHeight()/3+yPos+thumbsUp.getHeight()/2;//(((getY()+myHeight/2)-f.getHeight()*2))-thumbsUp.getHeight()/2;//-thumbsUp.getHeight()/3)+pixelsToMoveTextAndImageDown;
        //thumbsUp or down        
        g.drawImage(thumbImage, (((getX()+myWidth/2)-thumbsUp.getWidth()/2)-pullToTheLeftPixels)+stringWidth/3, yForThumb );
        
        if (isSelected) //draw the pressed version if we know we have pressed it.
        {
            g.drawImage(thumbImageSelected, (((getX()+myWidth/2)-thumbsUp.getWidth()/2)-pullToTheLeftPixels)+stringWidth/3, yForThumb );
        }
        
        switch (myPos)
        {
            case PROGRESS_BAR_LEFT:     
                pixelsToMoveTextAndImageDown = thumbsDown.getHeight();//-thumbsDown.getHeight()/8;
                break;
            case PROGRESS_BAR_RIGHT:
                pullToTheLeftPixels = -(int)(stringWidth/1.1f);//so it sits a bit more right
                pixelsToMoveTextAndImageDown = -((thumbsDown.getHeight()/3)+f.getHeight()/4);//*2; // the text is above the thumb
                break;
        }   
        //add +stringWidth/3 here to nudge it to the right a touch, same with thumbs up image (since the circle is pulled left and we dont want 
        //this stuff to loook too close to edge
        g.setColor(0xffffff);
        g.drawString(percentageStr, (((getX()+myWidth/2)-stringWidth/2)-pullToTheLeftPixels)+stringWidth/3, yForThumb+pixelsToMoveTextAndImageDown);//(getY()+myHeight/2)+pixelsToMoveTextAndImageDown);
        
        //blue progress bit
        float progressAngle = (float)((progress*1.3f));
        angleComplete = Math.toRadians(progressAngle);
        g.setColor(colour);
        pathDynamic.arc(xPos, yPos, circleW, circleH , startAngle, angleComplete);
        //draw actual progress arc
        g.drawShape(pathDynamic, stroke);

Shai Almog

unread,
Oct 24, 2016, 10:44:55 PM10/24/16
to CodenameOne Discussions
It looks like this is triggered by one of the arc paths can you log these calls and see which arguments trigger this?

Gareth Murfin

unread,
Oct 25, 2016, 5:56:50 AM10/25/16
to CodenameOne Discussions
Looks like it happens when you pass something like this

pathStatic.arc(xPos, yPos, circleW, circleH , 180, 180); // ie the same start and complete angle

Turned out to be a bug in my logic as I should not have been passing the same value like that, but I think that still maybe qualifies as a bug somewhere :)

Shai Almog

unread,
Oct 25, 2016, 9:47:36 PM10/25/16
to CodenameOne Discussions
Sounds like a bug, I also think this method accepts radians but I don't recall for sure. Steve?
Reply all
Reply to author
Forward
0 new messages