在软糖Android应用性能比较问题 [英] Android App Perfomance Issues on JellyBean

查看:144
本文介绍了在软糖Android应用性能比较问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里,我们正在创建一个Android应用程序从服务器请求数据的用户设备上显示的(不知道有多少更多的背景信息,我可以给一个项目工作...会尽我所能,如果更多的是需要)。我们正在从支持姜饼(2.3)及以上(最高达最新4.2软糖)。

I am working on a project where we are creating an Android app that requests data from a server to be displayed on the user's device (not sure how much more background information I can give... will try my best if more is needed). We are supporting from Gingerbread (2.3) and upwards (up to latest JellyBean 4.2).

现在奇怪的是,该应用程序运行速度非常快,顺利地在运行2.3.x版本的手机(这是一般的,年龄稍大的设备,如LG擎天柱2X),而如果我们尝试和运行在相对的应用较新的设备(银河S3等),有软糖4.1及以上版本,应用程序运行缓慢,在性能成为一个可用性问题。这发生在屏幕上,从服务器中提取数据并显示它们。

Now the odd thing is that the app runs very fast and smoothly on phones that are running 2.3.x (these are in general, slightly older devices such as LG Optimus 2X), while if we try and run the app on relatively newer devices (Galaxy s3 etc.) that have JellyBean 4.1+, the app runs so slow that the performance becomes a usability issue. This occurs on screens that pulls data from the servers and displays them.

我也通过在模拟器上运行它证实了这一行为。

I have also confirmed this behaviour by running it on the emulator.

所以,我做基于这样的事实,我们得到LogCat中以下的只有4.1的一些研究+:

So I did some research based on the fact that we get the following in LogCat for only 4.1+:

06-29 23:11:17.796:I /编舞(691):跳过X展架!该应用程序可能会做它的主线程的工作太多了。

06-29 23:11:17.796: I/Choreographer(691): Skipped X frames! The application may be doing too much work on its main thread.

所以好像这个东西叫做舞蹈编排API拉特16,并将其坐标动画,投入和图纸时机。

So it seems like this thing called Choreographer was added for API lvl 16, and it coordinates timing of animations, inputs and drawings.

我不知道这是否是引起这个问题?似乎不太可能是硬件问题,我们的应用程序没有任何动画,我们没有单独的实现为2.3.x版本和4.1 +

I'm wondering if this is causing this issue? Seems unlikely to be a hardware issue, our app doesn't have any animations and we do not have separate implementations for 2.3.x and 4.1+

感谢

推荐答案

与冰淇淋三明治开始,默认行为的AsyncTask 已经从一个并行执行者转变为系列化之一。

Starting with Ice Cream Sandwich, the default behavior of AsyncTask has changed from a parallelized executor to a serialized one.

当你在一个批处理的AsyncTask 的(如被看见在评论)执行多个网络请求,这意味着你的应用程序等待空空前的previous请求响应下一个。

As you are executing several network requests in a batch of AsyncTask (as seen in comment), that means your application waits for the previous request response before lauching the next one.

您可以修改的的AsyncTask 使用此code执行人:

You can change the executor of an AsyncTask using this code:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    myTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
else {
    myTask.execute();
}

来源: AsyncTask的线程回归确认从CommonsWare博客。

Source: AsyncTask Threading Regression Confirmed from CommonsWare blog.

这篇关于在软糖Android应用性能比较问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆