Optimize speed on Android

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Optimize speed on Android

agm65
Hi all,

how to increase the speed on Android?
On ios my app runs nearly like native apps but on android its a bit to slow.
The hardware of my android device is not much worse than the ios device.

Setting up cpu/gup rendering does nothing.

Any suggestion or tipps?
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

Nemi
Can you find out, what or where it makes huge difference precisely? Maybe using Scout.
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

leokan23
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

agm65
thx alot!
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

After24
Hi,

You can optimize a bit more by setting the Color depth to 16 bit in the XML app descriptor.
  <colorDepth>16bit</colorDepth>

The gain is not huge but not neglictable if your app manipumates bitmap objects.

you can also set :

stage.frameRate to 60;
stage.quality to StageQuality.LOW;
Scroller.maxDragRate to 80 (Static property of the scroller component);

Use pure as3 item renderers and old flash TextField object whenever you don't need complexe text layout.

Vincent.
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

Lydecker
How to I set maxDragRate?

I can't target it on a Scroller instance as it's a static member?

Thanks



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

Erik J. Thomas
Scroller.maxDragRate = 30;

Being a static member just means you set it globally for all instances of the Scroller type in your app.

Erik

On Jun 25, 2018, at 6:48 AM, Lydecker <[hidden email]> wrote:

How to I set maxDragRate?

I can't target it on a Scroller instance as it's a static member?

Thanks



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/


Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

Lydecker
Thanks for the reply - I literally just figured this out before you replied!

Thanks for taking the time to respond.




--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

Erik J. Thomas
No problem. I'm interested to know if you are able to improve scrolling on android with this setting. Please let me know your results and the setting you like, if you don't mind.

Thanks!


On Jun 25, 2018, at 11:36 AM, Lydecker <[hidden email]> wrote:

Thanks for the reply - I literally just figured this out before you replied!

Thanks for taking the time to respond.




--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/


Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

Lydecker
Yea - will do.

I've created a business app (a lot of data processing and SQLite calls).
Worked perfectly on iOS no issues or noticeable lag.

As soon as I put it on a Galaxy S8 - slow as f***!

(and I've been doing sensible renderers from the start: cacheAsBitmap,
ContentCache, no nested MXML, opaquebackground etc....).

I've made 4 changes just now:

stage.frameRate = 60 (was on 24)
stage.quality = "low" (was on medium)
Scroller.maxDragRate = 80 (was on 30)
<colorDepth>16bit</colorDepth> (was on 32bit)

And it's had a MASSIVE difference.

the render choice is a hard one. on iOS - auto (/cpu) is great.

on Android (with the above improvements) I am finding:
*direct *- useless! But am I correct in thinking that direct and Flex don't
play well?
*auto/cpu *- really punchy with the data loading / swapping between views,
however animations are painful to watch.... (anything being animated has
cacheAsBitmap = true)
*gpu* - animations are almost seemless, however the data processing is
painful - very slow compared to cpu and it takes 2-4 seconds to load a new
view (that's with no data processing or binding taking place until
viewActive function). Also finding itemRenderers with a small height of 1 or
pixels are not being rendered.

I'm not using cacheAsBitmapMatrix as I'm only ever animating in x plane and
never rotating or scaling.

I'll get some specs when I have time to properly benchmark with Scout in the
next few days and report back.

Also I assume the Spark List component inherits the Scroller component, so
the Scroller.maxDragRate will impact the perceived scroll smoothness of a
List?




--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

Erik J. Thomas
Wow, you're really testing some great stuff to share with the community. Please let us know your conclusions on best combination of settings. You're in territory it never occurred to me to dive into.

And yes, the spark List component includes a "scroller" property and that too will use the Scroller static setting for max drag rate.

On Jun 25, 2018, at 12:24 PM, Lydecker <[hidden email]> wrote:

Yea - will do.

I've created a business app (a lot of data processing and SQLite calls).
Worked perfectly on iOS no issues or noticeable lag.

As soon as I put it on a Galaxy S8 - slow as f***!

(and I've been doing sensible renderers from the start: cacheAsBitmap,
ContentCache, no nested MXML, opaquebackground etc....).

I've made 4 changes just now:

stage.frameRate = 60 (was on 24)
stage.quality = "low" (was on medium)
Scroller.maxDragRate = 80 (was on 30)
<colorDepth>16bit</colorDepth> (was on 32bit)

And it's had a MASSIVE difference.

the render choice is a hard one. on iOS - auto (/cpu) is great.

on Android (with the above improvements) I am finding:
*direct *- useless! But am I correct in thinking that direct and Flex don't
play well?
*auto/cpu *- really punchy with the data loading / swapping between views,
however animations are painful to watch.... (anything being animated has
cacheAsBitmap = true)
*gpu* - animations are almost seemless, however the data processing is
painful - very slow compared to cpu and it takes 2-4 seconds to load a new
view (that's with no data processing or binding taking place until
viewActive function). Also finding itemRenderers with a small height of 1 or
pixels are not being rendered.

I'm not using cacheAsBitmapMatrix as I'm only ever animating in x plane and
never rotating or scaling.

I'll get some specs when I have time to properly benchmark with Scout in the
next few days and report back.

Also I assume the Spark List component inherits the Scroller component, so
the Scroller.maxDragRate will impact the perceived scroll smoothness of a
List?




--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/


Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

After24
In reply to this post by Lydecker
Hello,

Going beyond 60 for maxDragRate will not improve dragging performance. This
parameter has no effect on the scrolling after the user releases his touch
on the screen and the view continues to scroll due to the inertia.

Using AS3 item renderers instead of mxml with flash displayObjects only
(Textfield, bitmap, graphics API) has a significant effect on scrolling
smoothness.

It's hard to achieve "native performances" on Android without setting
renderMode to gpu.

Vincent.









--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

Lydecker
Thanks for the info - I only set 80 as that is what you recommended in your
post above. But what you say about 60 makes sense.

The Android thing is weird.

On a Nexus 5X - everything is super smooth.
Same app on a Samsung S8 - not smooth.

I'm currently using MXML renderers - however following the best practice
guides (no nested elements, using setLayoutPosition, no binding,
opaquebackground, cacheAsBitmap etc)

You're correct - GPU performance is much better, however although the
animations and scrolling improve to 'native' levels, the data processing
speeds take a HUGE dive to unacceptable levels. Trying to write a chunk of
data to a database with transitions takes 4 times as long. Switching views
(even with nothing in the init/creationComplete function) takes 2 times as
long.....



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

After24
Hello,

I also noticed that performance vary significantly on android between
devices, even between devices with comparable hardware.

I don't have any explanation for the  data processing performance
degradation when renderMode is set to gpu.

Complicated views can take a while to initialize, you can leverage the
destructionPolicy property if you don't want a particular view to be
destroyed when the user navigate to another one. The application memory
print will increase but I don't think that it is still a problem on modern
devices.

Did you set useVirtualLayout to false on your list ?
CacheAsBitmap improve scrolling performance but the visual content of your
item renderers must be "still" (Except when the data property change)
because the item renderer as a displayObject is cached every time its
content changed.

If you want to try on your samsung S8, I have an application on the play
store with a demo mode that contains various list with as3 item renderers :  
https://play.google.com/store/apps/details?id=air.net.after24.Studius
<https://play.google.com/store/apps/details?id=air.net.after24.Studius>  

Vincent.



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

Lydecker
Thanks for your response.

(P.S I've found your posts really insightful on these forums)

> I already use destructionPolicy=never on my views. It's just that initial
> start up which is a killer! I might try making includeinlayout=false for
> all my MXML on the view, then set them to true in viewActive once the view
> is loaded....

> I don't use useVirtualLayout (so useVirtualLayout=false on all my lists).
> If it is set to true then my custom renders play up and don't render
> properly after scrolling past the first screen. *I assume this is normal
> behaviour when using a custom renderer?* Are you saying I SHOULD have
> useVirtualLayout=true on my lists?

> I should also mention - I am struggling more with using things like
> <s:Move/> (so spark animations) - e.g the user clicks a button and an
> <s:BitmapImage cacheAsBitmap=true/> on the screen moves on the x plane to
> off the screen. That is really stuttering - more then the Lists/Scrollers.
> Would you recommend using a custom animation library (like Tweener or
> TweenLite?). I'm wondering if it is because I am using an exponent
> transition rather then something more simple like a linear one? In a worse
> case scenario I plan to just disable animations on Android devices (which
> I don't want to do).

If I were to move across to pure actionscript for my renderers - which would
you recommend as a starting point:

Extending the UIComponent

OR

Extending the LabelItemRenderer

I assume the LabelItemRenderer Extends the UIComponent but just adds a
StylableTextField?

Thank you for pointing me to your App. I will download tonight and try on my
S8 test device. I'll let you know how I get on.

Thanks





--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

After24
Lydecker,

I would recommend to use UIComponent instead of LabelItemRenderer to make
your item renderers as lightweight as possible.

In My case, I create a MobileItemRender base class that extends UIComponent
and implements the required interface IItemRenderer.

Vincent.



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

Lydecker
That's what I was going to go with, thanks.

Any recommendations re animations? Do you use any external libraries - or
just Spark animate components in your apps (for example when you fade
alpha)?

Thanks



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Optimize speed on Android

After24
I use exclusively the Greensock TweenLite library for animation.

Vincent.



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/