×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Cracow, Poland
    Posts
    50

    Serious BUG in Nokia phones!!!

    Hi all,

    I've been developing for a while for Nokia devices and some time ago I encountered a bug that causes some of the Nokia Series 40 phones to restart!

    The problem is at least on Nokia 6610 (firmware v.4.18) and 7210 (I don't know the firmware).

    As far as I investigated it the problem is in repaint(x, y, width, height) method. If called several times it crashes when x = getWidth() - 1 i.e. x = 127 for Series 40.

    Here is the midlet that exploits the bug:

    http://www.ganimedes.pl/java/nokiabug.jad
    http://www.ganimedes.pl/java/nokiabug.jar

    Try to run it, after a few seconds (if the bug is on your phone) the screen gets black and after a few seconds the phone restarts. The paint might be empty as the bug is related to repaint only...

    I wonder if the bug is on Series 60 or another Nokia phones, as I had possibility to test it on few phones...

    And here goes the source:

    Code:
    public class NokiaBug extends MIDlet {
    
      private Display display = null;
    
      protected void startApp() throws MIDletStateChangeException {
        if (display == null)
          display = Display.getDisplay(this);
        setDisplayable(new BuggyCanvas());
      }
    
      protected void pauseApp() {
      }
    
      protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
        setDisplayable((Displayable) null);
        display = null;
      }
    
      protected void setDisplayable(Displayable _displayable) {
        display.setCurrent(_displayable);
      }
    
      public void exit() {
        try {
          destroyApp(false);
        } catch (MIDletStateChangeException msce) {
          //do nothing
        }
        notifyDestroyed();
      }
    }
    
    class BuggyCanvas extends FullCanvas {
    
      private Timer timer = new Timer();
      private volatile int x = 0;
    
      protected void paint(Graphics g) {
        g.setColor(0x00ff00);
        g.fillRect(0, 0, getWidth(), getHeight());
        g.translate(getWidth() >> 1, getHeight() >> 1);
        g.setColor(0x000000);
        g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL));
        g.drawString(String.valueOf(x), 0, 0, Graphics.HCENTER | Graphics.BASELINE);
      }
    
      protected void showNotify() {
        timer.schedule(new TimerTask() {
          public void run() {
            repaint(x, 0, getWidth() - x, 10);
            serviceRepaints();
            x++;
            if (x == getWidth())
              x = 0;
          }
        }, 0, 50);
      }
    }

  2. #2
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Cracow, Poland
    Posts
    50
    Is there anyone who could confirm this is a bug, or not?...

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    1
    Can't install in my 6600. (either jad or jar file)

  4. #4
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Cracow, Poland
    Posts
    50
    What's wrong? Are you installing via OTA or Infrared?

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    5

    this bug...

    60...not problem. 3650...other problem(loading and bufferImg..)
    40..
    6610..bug.. other many bug..media,Image,array...bug. too many.

    6800 not problem( i dont know..issue bug)
    Last edited by lhg96; 2003-12-19 at 10:17.

  6. #6
    Registered User
    Join Date
    Jul 2003
    Posts
    5

    nokia pone version confirm

    *#0000# - press

  7. #7
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Cracow, Poland
    Posts
    50
    Hi,

    This is exactly what I can see after pressing *#0000# on my Nokia 6610:

    V 4.18
    07-12-02
    NHL-4U
    (c) NMP.

    Bart

  8. #8
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    87
    My advice is to only use getWidth() and getHeight() at the beginning of your program. Just set some variables at the start and use them.

    I have no idea why that is happening but you might as well avoid it (easily) rather than spend time solving it.

    Good luck.

  9. #9
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Cracow, Poland
    Posts
    50
    Thanks,

    But it's not because of the getWidth() - I used it in this example just to point out the problem... Anyway I solved that case by avoiding repainting areas narrower than 1 pixel ;-)

  10. #10
    Registered User
    Join Date
    Mar 2003
    Location
    Paris, FRANCE
    Posts
    9
    I have the same problem, the phone reboots with a graphical midlet.
    I only display one background image and I add on top of it a scrolling text.
    When the text is completely out of the screen on the left, my Nokia 7210 reboots.
    Here is its software version :
    v3.02
    02-10-02

    I have no problem on other phones or emulators. I've debugged it by adding beeps inside my code, like that:
    AlertType.ERROR.playSound(display);
    Thread.sleep(1000);

    It crashes just before, or just after a call to repaint with the folling values :
    repaint(0, paintY, eraseWidth, paintHeight);
    in this case :
    repaint(0, 40,1,16);
    I have a serviceRepaints(); just after and I can't be sure wether or not it is called.
    But what is sure is that paint is not called after the repaint, the phone crashes before.
    If instead of painting with a width of 1, I put a width of 2, the phone doesn't crash.

    So my conclusion is that there is a bug in my relase of the Nokia firmware, and it seems to be the same bug in this thread :
    repaint with a width of 1 reboots the phone.

    Hope this helps

    Thibaut REGNIER


    I add an extract of my code, I can give more on request (just ask in this thread):

    /**
    * Paint the Canvas on the screen.
    * @see javax.microedition.lcdui.Displayable#paint(javax.microedition.lcdui.Graphics)
    */
    protected void paint(Graphics g)
    {
    //TODO double buffer

    //TODO debug à retirer
    if (bip)
    {
    AlertType.INFO.playSound(Display.getDisplay(tastePhone));
    try
    {
    Thread.sleep(2000);
    }
    catch (InterruptedException e)
    {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }

    // We use this value two times, so we cache it in a local variable.
    final int TOP_LEFT= Graphics.LEFT | Graphics.TOP;

    // Draw the background image, the clipping (included in g) will draw only the needed part
    g.drawImage(immutableBackgroundImage, 0, 0, TOP_LEFT);

    // Drawing of the scrolling string
    g.setFont(currentFont);
    g.setColor(0);
    g.drawString(scrollingText, xText, yText, TOP_LEFT);
    }



    /**
    * Make the text scroll on the screen, with a background thread;
    * @see java.lang.Runnable#run()
    */
    public void run()
    {
    int paintX, paintY, paintWidth, paintHeight;
    final long WAITING_TIME= 200;
    final int X_MOVEMENT= 2;
    //TODO debug à retirer
    System.err.println("Départ animationThread");
    Display display= Display.getDisplay(tastePhone);
    try
    {

    /* Run while our thread is referenced by animationThread */
    while (animationThread == Thread.currentThread())
    {
    long beginTime= System.currentTimeMillis();

    paintX= xText;
    paintY= yText;
    paintHeight= scrollingTextHeight;

    xText -= X_MOVEMENT;
    if (xText + scrollingTextWidth <= 0)
    {
    //TODO debug à retirer
    AlertType.ERROR.playSound(display);
    Thread.sleep(1000);
    bip= true;

    // if everything would be out of the screen on the left, go back to the right
    int screenWidth= getWidth();
    xText= screenWidth - X_MOVEMENT - 1;

    int eraseWidth= scrollingTextWidth + paintX;
    if (eraseWidth <= 0)
    eraseWidth= 1;
    //TODO DEBUG
    System.err.println(
    "BUG? "
    + 0
    + ","
    + paintY
    + ","
    + eraseWidth
    + ","
    + paintHeight);
    addCommand(
    new Command(
    paintY + "," + eraseWidth + "," + paintHeight,
    Command.SCREEN,
    1));
    // erase the old text on the left by a redraw (paintX is negative)
    repaint(0, paintY, eraseWidth, paintHeight);

    //TODO debug à retirer
    AlertType.ERROR.playSound(display);
    Thread.sleep(1000);

    // We force the repaint now,it will just clear the small part requested before
    serviceRepaints();

    //****BUG never get there, reboots before

    //TODO debug à retirer
    AlertType.ERROR.playSound(display);
    Thread.sleep(1000);

    // we compute the position for redraw below which will add text on the right of the screen.
    paintX= xText;
    paintWidth= X_MOVEMENT;

    switch (hColorCode)
    {
    case CODE_RED :
    hColorCode= CODE_BLUE;
    vColorCode= CODE_RED;
    bColorValue= 255;
    break;
    case CODE_GREEN :
    hColorCode= CODE_RED;
    vColorCode= CODE_BLUE;
    bColorValue= 128;
    break;
    case CODE_BLUE :
    hColorCode= CODE_GREEN;
    break;
    }
    // As the colors have changed, redraw the whole backGroundImage

    //TODO debug à retirer
    AlertType.ERROR.playSound(display);
    Thread.sleep(1000);

    paintBackgroundImutable();

    //TODO debug à retirer
    AlertType.ERROR.playSound(display);
    Thread.sleep(1000);

    //TODO DEBUG
    System.err.println("BUG? repaint total");
    repaint();

    //TODO debug à retirer
    AlertType.ERROR.playSound(display);
    Thread.sleep(1000);

    }
    else
    { // normal case, the text has just moved of X_MOVEMENT pixels

    if (xText < 0)
    {
    paintX= 0;
    paintWidth= scrollingTextWidth + X_MOVEMENT + xText;
    // xText is negative and is the width of the text out of the screen on the left.
    }
    else
    {
    paintX= xText;
    paintWidth= scrollingTextWidth + X_MOVEMENT;
    }

    int screenWidth= getWidth();
    if (paintX + paintWidth > screenWidth)
    {
    paintWidth= screenWidth - paintX;
    }

    }
    //TODO DEBUG
    System.err.println(
    "repaint "
    + paintX
    + ","
    + paintY
    + ","
    + paintWidth
    + ","
    + paintHeight);
    repaint(paintX, paintY, paintWidth, paintHeight);
    serviceRepaints();
    // forces to wait for the completion of the paint.

    long elapsedTime= System.currentTimeMillis() - beginTime;
    if (elapsedTime < WAITING_TIME)
    {
    try
    {
    //TODO Debug à retirer
    System.err.println(
    "Je dors " + (WAITING_TIME - elapsedTime) + "ms");
    Thread.sleep(WAITING_TIME - elapsedTime);
    }
    catch (InterruptedException e)
    { // we ignore the exception
    }
    }
    }
    //TODO debug à retirer
    }
    catch (Throwable t)
    {
    }
    System.err.println("Arrêt animationThread");
    }
    Last edited by tregnier; 2004-03-28 at 21:57.

  11. #11
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Cracow, Poland
    Posts
    50
    Thanks for your post!

    At least one confirmed that bug!!! I solved that case a while ago exactly in the same way you did - instead of using width = 1 I used 2 ;-)

    Best regards,
    Bart

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×