Skip to main content

'Offline' painting to initialise Form at application start ?

5 replies [Last post]
drdth
Offline
Joined: 2003-06-16
Points: 0

Driven by some short delays on the initial display of a form with multiple components (tabs, combos, textfields etc.) I am wondering if there is a way to initialise the form completely during startup, e.g. by drawing it 'offline' (invisibly) while showing a splash screen ?

This way the existing processes occurring in the first call to show() would not have to be changed but would occur unnoticed as part of the initial application start. The first 'real' call to 'show()' after this would perform as well as all the following ones ;-)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shai Almog

Hi,
not that I can think of. However since we send an event when switch
tabs you can only create the first tab and create the rest lazily as
the user moves between them...

> Driven by some short delays on the initial display of a form with
> multiple components (tabs, combos, textfields etc.) I am wondering
> if there is a way to initialise the form completely during startup,
> e.g. by drawing it 'offline' (invisibly) while showing a splash
> screen ?
>
> This way the existing processes occurring in the first call to show
> () would not have to be changed but would occur unnoticed as part
> of the initial application start. The first 'real' call to 'show()'
> after this would perform as well as all the following ones ;-)
> [Message sent by forum member 'drdth' (drdth)]
>
> http://forums.java.net/jive/thread.jspa?messageID=317827
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

drdth
Offline
Joined: 2003-06-16
Points: 0

Hmm, well the lazy loading is exactly what I am trying to replace with 'pre-caching'.

How about patching LWUIT so the EDT Thread doesn't call paint() / do anything if an 'offline' flag is set ? Would this still do all the layout initialisations etc to a repaint() level but then no paint() would update the dirty components ? (Hmmm, what happens once offline is switched off again...)

Does this sound like a reasonable approach ?

Shai Almog

Did you benchmark the code, if there is a specific bottleneck I would
attack that rather than trying a prefetching.
Assuming you want to do something like this still you can just look
at the code within Display.setCurrent. Just set the form size to the
right size and revalidate the component tree before showing. You can
set form visibility to true if you haven't called setCurrent this
should have no effect and theoretically you can call
form.initComponent which will do all the rest although this is risky.

Personally on mobile devices I always go with lazy fetching over
eager, the memory constraints are just much more problematic than the
performance constraints in the target devices I usually go for.

> Hmm, well the lazy loading is exactly what I am trying to replace
> with 'pre-caching'.
>
> How about patching LWUIT so the EDT Thread doesn't call paint() /
> do anything if an 'offline' flag is set ? Would this still do all
> the layout initialisations etc to a repaint() level but then no
> paint() would update the dirty components ? (Hmmm, what happens
> once offline is switched off again...)
>
> Does this sound like a reasonable approach ?
> [Message sent by forum member 'drdth' (drdth)]
>
> http://forums.java.net/jive/thread.jspa?messageID=318016
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

drdth
Offline
Joined: 2003-06-16
Points: 0

> Did you benchmark the code, if there is a specific
> bottleneck I would
> attack that rather than trying a prefetching.

Well, I'd prefer to see LWUIT as a black box, as much as possible.
One bottleneck are CustomFonts and I've already raised this in bugzilla.
But most of the time is just spent setting up layouts and initialising components,
so it all seems justified.

> Assuming you want to do something like this still you
> can just look
> at the code within Display.setCurrent. Just set the
> form size to the
> right size and revalidate the component tree before
> showing. You can
> set form visibility to true if you haven't called
> setCurrent this
> should have no effect and theoretically you can call
>
> orm.initComponent which will do all the rest although
> this is risky.

Thanks for the pointers, I will look into these options.

> Personally on mobile devices I always go with lazy
> fetching over
> eager, the memory constraints are just much more
> problematic than the
> performance constraints in the target devices I
> usually go for.

Well, in this particular case it's not so much
about choosing between speed and memory,
it's more about choosing when the work is done.

In my case, a fast GUI response is crucial, as it enhances the
user experience. I'll keep on digging, thanks.

drdth
Offline
Joined: 2003-06-16
Points: 0

I guess the answer is 'not via the API'. But Lwuit can be easily modified to provide this functionality. Simply add a static flag somewhere (e.g. Display) and if enabled, skip paint calls in Graphics, and a few other calls in Form and Implementation. Just in case somebody else needs this as well ;-)