|
Replies:
6
-
Last Post:
Jun 18, 2009 12:05 AM
by: Shai Almog
|
|
|
|
|
|
|
Tip to make LWUIT paint/display/scroll lists faster
Posted:
Jun 16, 2009 4:08 AM
|
|
|
Hi all,
I'd like to share an optimization tip I used to make my lists scroll at least 50 times faster (literally) than they did, which was especially noticeable on Blackberry Storm, HTC etc etc where tap-flicking was terribly slow. My List(s) had excessive use of labels and images and so the list would take literally a second or two to change focus and to scroll.
After a bit of profiling I noticed LWUIT was spending most of its time in Font.stringWidth, wasting precious cpu cycles on basically the same strings again and again (with a new repaint after every scroll-step/focus change). The solution was to subclass Font, add a 'String Width Pool' that keeps track of, say, 30 strings at most and their widths. You then use this cache to return width of strings you're already aware of. This single change has now made scrolling/flicking on the same devices *much* *much* and *much* faster. On a Nokia E61 a focus change repaint now went down to less than 0.2 seconds from almost 1.5 seconds.
I think this optimization should be made part of the Font class by default.
|
|
|
|
|
|
|
Re: Tip to make LWUIT paint/display/scroll lists faster
Posted:
Jun 17, 2009 3:03 AM
in response to: gw1921
|
|
|
I am very interested in seeing your implementation of this. Are you working on the latest build of lwuit, or are you using a binary?
Im using the 221208 binary, and are not going to use a newer version of lwuit until a new stabil binary is released.
|
|
|
|
|
|
|
|
Re: Tip to make LWUIT paint/display/scroll lists faster
Posted:
Jun 17, 2009 3:10 AM
in response to: gw1921
|
|
|
Hi, thanks. We have long been aware of the slow performance of stringWidth on some devices, hence some of the patches we did in TextArea.java to allow faster line breaks (that is also part of the reason why we don't have multi-line labels etc.).
The proper way to implement a patch like you suggest is via the LWUITImplementation by extending GameCanvasImplementation, which would not require you to change LWUIT source code (hence requiring you to contribute your changes).
> Hi all, > > I'd like to share an optimization tip with I used to make my lists scroll at least 50 times faster (literally) than they did, which was especially noticeable on Blackberry Storm, HTC etc etc where tap-flicking was terribly slow. My List(s) had excessive use of labels and images and so the list would take literally a second or two to change focus and to scroll. > > After a bit of profiling I noticed LWUIT was spending most of its time in Font.stringWidth, wasting precious cpu cycles on basically the same strings again and again (with a new repaint after every scroll-step/focus change). The solution was to subclass Font, add a 'String Width Pool' that keeps track of, say, 30 strings at most and their widths. You then use this cache to return width of strings you're already aware of. This single change has now made scrolling/flicking on the same devices *much* *much* and *much* faster. On a Nokia E61 a focus change repaint now went down to less then 0.2 seconds from almost 1.5 seconds. > > I think this optimization should be made part of the Font class by default. > [Message sent by forum member 'gw1921' (gw1921)] > > http://forums.java.net/jive/thread.jspa?messageID=351369 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net > For additional commands, e-mail: users-help@lwuit.dev.java.net > >
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net For additional commands, e-mail: users-help@lwuit.dev.java.net
|
|
|
|
|
|
|
|
Re: Tip to make LWUIT paint/display/scroll lists faster
Posted:
Jun 17, 2009 3:35 AM
in response to: Shai Almog
|
|
|
Ah yes that sounds great - I didn't realize the calls of course end up with LWUITImplementation. Where/how can I submit patches?
I'm using the latest SVN code (binaries are too old for use) and non-stable code doesn't bother me. I'm in fact glad we're able to get latest changes/fixes via SVN!
|
|
|
|
|
|
|
|
Re: Tip to make LWUIT paint/display/scroll lists faster
Posted:
Jun 17, 2009 3:43 AM
in response to: gw1921
|
|
|
You need to read the LWUIT-Incubator project home page, essentially we need you to email a scanned/signed SCA to lwuit (at) sun (dot) com so we can look at code contributions from you. > Ah yes that sounds great - I didn't realize the calls of course end up with LWUITImplementation. Where/how can I submit patches? > > I'm using the latest SVN code (binaries are too old for use) and non-stable code doesn't bother me. I'm in fact glad we're able to get latest changes/fixes via SVN! > [Message sent by forum member 'gw1921' (gw1921)] > > http://forums.java.net/jive/thread.jspa?messageID=351621 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net > For additional commands, e-mail: users-help@lwuit.dev.java.net > >
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net For additional commands, e-mail: users-help@lwuit.dev.java.net
|
|
|
|
|
|
|
|
Re: Tip to make LWUIT paint/display/scroll lists faster
Posted:
Jun 17, 2009 4:51 AM
in response to: Shai Almog
|
|
|
Thanks - I've submitted the SCA along with the patches to the email address. For those interested, I've submitted code to support Variable Sized Cells in Lists along with other optimizations to improve painting/refreshes (such as reduced stringWidth calls, reduced rectangle obj creation etc etc)
|
|
|
|
|
|
|
|
Re: Tip to make LWUIT paint/display/scroll lists faster
Posted:
Jun 18, 2009 12:05 AM
in response to: gw1921
|
|
|
Thanks. I did check a "naive" implementation of this ignoring the multiple-font issue. I ran this on my E61 device with the LWUIT demo and measured the home screen/scroll demo responsiveness and saw no noticeable difference in speed.
I am curious if others have seen a noticeable improvement? > Thanks - I've submitted the SCA along with the patches to the email address. For those interested, I've submitted code to support Variable Sized Cells in Lists along with other optimizations to improve painting/refreshes (such as reduced stringWidth calls, reduced rectangle obj creation etc etc) > [Message sent by forum member 'gw1921' (gw1921)] > > http://forums.java.net/jive/thread.jspa?messageID=351636 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net > For additional commands, e-mail: users-help@lwuit.dev.java.net > >
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net For additional commands, e-mail: users-help@lwuit.dev.java.net
|
|
|
|
|