Tuesday, July 28, 2009

I Found A Bug In LWUIT


Submitting issues to LWUIT is pretty easy but we still get a flood of duplicates and questions in the mailing list so I would like to just clarify this "how to" to hopefully improve the signal to noise ration of LWUIT.

First off there is a public issue tracker available for all to search, vote and submit at https://lwuit.dev.java.net/issues/ please use it to make sure the issue you have wasn't reported. If you think you found an issue in LWUIT follow these steps to submit:

  1. Make sure the issue was not reported, use Google search with the word LWUIT and a description of the issue, this often finds relevant discussions.
    Make sure to include relevant discussions with your post so we have an indication that you followed this step, this means we will treat your issue as more thoroughly researched.
  2. Make sure the issue occurs in current SVN, we don't accept issues for older versions of LWUIT.
  3. Reproduce the issue with minimal code, the more code we need to debug the longer it will take to resolve. If you can trace the issue yourself by going into LWUIT's code this would be even faster.
  4. If there is a stack trace related to the issue make sure to include it.
  5. Produce screenshots or even a video of the issue, I find tools like Jing to be very helpful. Its also very useful since it can annotate the issue and provide us a visual explanation even if your English isn't the very best.
  6. Apply for an Observer role for the lwuit project, you need to create a user at java.net and then request a project Observer role. I repeat *Observer* all other role requests are automatically denied and the constant developer requests are just plain annoying... Observer seriously... Just read the introduction at lwuit incubator if you want to contribute.
  7. Submit your issues and use the attachment feature to attach screenshots, video explanations (not too big), concise source examples etc.
    Don't submit too much information either, try to be concise and visual so we can understand your issue properly.

FYI the gradient colors are unrelated to LWUIT and relate mostly to the number of colors supported by the device...

21 comments:

  1. Is lwuit make slower application ?
    This is what i experienced when i tried wiht LWUIT SDK.

    ReplyDelete
  2. I'm receiving NullPointerException every time I launch the application. Do you have an idea how to solve this problem?
    Thanks

    startApp threw an Exception
    java.lang.NullPointerException
    java.lang.NullPointerException
    at com.sun.lwuit.Form.initFocused(+19)
    at com.sun.lwuit.Form.show(+28)

    ReplyDelete
  3. @AJAY. No.

    @Alexandre: make sure you are using the EDT to interact with LWUIT

    ReplyDelete
  4. I'm creating a form with two labels, two textfields and one text area (the textarea is not focusable and not editable). In that form, I set the UUID of the textarea to "Label".

    In startApp, if I set a theme for the application, NullPointerException is thrown every time I try to show the Form.

    However, if I remove the textarea from the form, the NullPointerException is not thrown and the application starts normally with the theme. Sometimes, removing the theme from the application, it starts normally even with textareas. So, it's a bit strange the behavior of my application with textAreas. By the way, I'm using LWUIT 1.2.

    Do you have any idea?
    Thanks

    ReplyDelete
  5. In startApp, I'm just setting the theme, creating the form and then calling the show method (NullPointerException is thrown).

    ReplyDelete
  6. @Alexandre you have a race condition. Remember that startApp is NOT the EDT. Use callSerially

    ReplyDelete
  7. @Alok: You don't need to zip the resources. The res file must be packaged in the JAR file as is.

    ReplyDelete
  8. Hi,

    iam trying to apply a theme to my application but i get some error,

    this is the error:

    java.lang.NullPointerException
    at
    java.io.DataInputStream.read
    java.io.DataInputStream.readUnsignedShort(+4)
    java.io.DataInputStream.readShort(+4)
    com.sun.lwuit.util.Resources.openFile
    com.sun.lwuit.util.Resources.init
    com.sun.lwuit.util.Resources.open
    login.loginscreen.startApp

    java.io.IOException
    at com.sun.lwuit.util.Resources.open
    login.loginscreen.startApp

    I wrote it in the function startApp like this:

    Resources res = Resources.open("src/myTheme.res")

    All the build process do it well in fact, the application runs but, it doesnt load the Theme.

    Please help me to figure out whats going on.

    you told Alexandre that have a race condition what is that?, and that use callSerially,

    how do i use this ?

    Thanx.

    ReplyDelete
  9. When i tried to build the LWUITDemo application in netbeans with new version of LWUIT 1.3 i got an error
    java.lang.NoSuchFieldError: VALUE_TEXT_ANTIALIAS_GASP


    Can any one help me in this regards...

    ReplyDelete
  10. Hello
    I am using LWUIT_1_3 Designer ,and I create res for my project.
    -after I create the .res file I enter the following code in the stratApp() :
    try {
    r = Resources.open("/src/theme.res");
    UIManager.getInstance().setThemeProps(r.getTheme(r.getThemeResourceNames()[0]));
    UIManager.getInstance().setThemeProps(r.getTheme("SecureTheme"));
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    -The errors that I get:
    Running with storage root D:\Documents and Settings\dpinto\j2mewtk\2.5.2\appdb\DefaultColorPhone
    Running with locale: Hebrew_Israel.1255
    Running in the identified_third_party security domain
    java.lang.NullPointerException
    at java.io.DataInputStream.read(+4)
    at java.io.DataInputStream.readUnsignedShort(+4)
    at java.io.DataInputStream.readShort(+4)
    at com.sun.lwuit.util.Resources.openFile(+23)
    at com.sun.lwuit.util.Resources.(+31)
    at com.sun.lwuit.util.Resources.open(+19)
    at NewLotto.startApp(+5)
    at javax.microedition.midlet.MIDletProxy.startApp(+7)
    at com.sun.midp.midlet.Scheduler.schedule(+270)
    at com.sun.midp.main.Main.runLocalClass(+28)
    at com.sun.midp.main.Main.main(+80)
    java.io.IOException
    at com.sun.lwuit.util.Resources.open(+42)
    at NewLotto.startApp(+5)
    at javax.microedition.midlet.MIDletProxy.startApp(+7)
    at com.sun.midp.midlet.Scheduler.schedule(+270)
    at com.sun.midp.main.Main.runLocalClass(+28)
    at com.sun.midp.main.Main.main(+80)
    java.lang.OutOfMemoryError
    Execution completed.
    4182332 bytecodes executed
    343 thread switches

    -Can you advise me.
    Thank you David

    ReplyDelete
  11. I have the same NullPointer while loading resource
    in the stratApp() :

    try {
    Resources r=Resources.open("/src/theme.res");
    } catch (IOException e) {
    e.printStackTrace();
    }

    ReplyDelete
  12. The trouble with NullPointer disappeared, when I cahnged my code to load Resources after Display.init(this);

    so the code

    Display.init(this);
    Resources r = Resources.open("/res/LWUITtheme.res");
    works fine!

    ReplyDelete
  13. There are several blog entries as well as the developer guide discussing LWUIT performance which is usually superior to LCDUI/canvas code.
    The problem people are having is with misuse of the EDT, using a really heavy theme etc. Remove the theming code and build a clean test case to see how fast LWUIT is, then apply the theme in iteration until you find the resource that is slowing you down.

    ReplyDelete
  14. LWUITSpeed benchmark database..

    hey mate, check out this, i dont think anyone has done it yet so i thought would be useful.. hope im not breaking any rules

    http://www.alphasoftware.org/lwuit/

    ReplyDelete
  15. it appears to be form.show() that is taking the time, i removed all the themes, transparent images etc, but form,show still takes around 0.8secs even on WTK - i didnt write the code though so its hard to figure out why

    ReplyDelete
  16. i have an one error when i set the font property using LWUIT.
    error:
    startApp threw an Exception
    java.lang.NullPointerException
    java.lang.NullPointerException
    at com.sun.lwuit.Font.(Font.java:135)
    at com.sun.lwuit.Font.createSystemFont(Font.java:262)
    at com.sun.lwuit.util.Resources.loadTheme(Resources.java:858)
    at com.sun.lwuit.util.Resources.openFile(Resources.java:147)
    at com.sun.lwuit.util.Resources.(Resources.java:114)
    at com.sun.lwuit.util.Resources.open(Resources.java:471)
    at demo.startApp(demo.java:30)
    at javax.microedition.midlet.MIDletProxy.startApp(MIDletProxy.java:44)
    at com.sun.midp.midlet.Scheduler.schedule(+270)
    at com.sun.midp.main.Main.runLocalClass(+28)
    at com.sun.midp.main.Main.main(+80)


    plz help me.

    ReplyDelete
  17. I will be recommending that we move away from LWUIT unfortunately due to the inexplicably bad performance from form.show() which makes our app crawl, and I cant find any source of help or reasoning on this issue.

    ReplyDelete
  18. Hi Shai, sorry I tried to log into lwuit mailing list many times but it simply wont let me in. I have tracked our major slow down to the fact that getListCellRendererComponent() is *constantly* called for each visible item on the list - this is very slow as you can imagine, is there something I must set/call to make sure this only gets called once? there is no need to repaint constantly I wouldnt imagine, just one per keypress.. please let me know, thanks.

    ReplyDelete
  19. It appears that even when going into a list there are 8 repaints to set up the list (each repaint in my tests takes 700ms, so 8x700 is very slow, surely there is only one needed?).. each navigation of a list takes 2 full repaints (2x700)... im not sure if this is lwuit or the app coders themselves [its not my app ive been tasked with speeding it up], but there is certainly too many repaints going on, im quite new to lwuit id love to know some ways to find or cancel out all of these repaints.. ??

    ReplyDelete
  20. That last link is broken, at least for me.

    ReplyDelete
  21. Java.net forum changes:
    http://www.java.net/forum/topic/mobile-embedded/lwuit/getlistcellrenderercomponent-called-many-times

    LWUIT tries to be "clever" about showing forms/dialogs and sync back to the EDT for cases such as form.show() invoked from startApp(). That never worked well for all cases but we left it there because the alternative would be a much less intuitive hello world.

    Blocking the startApp might work on some devices but usually doesn't. Some MIDP devices separate the rendering/event thread from the lifecycle thread. LWUIT will work regardless (since it has its own thread) but if the rendering/event thread of the native VM is blocked nothing will be shown.

    ReplyDelete