2013年3月6日 星期三

薑餅與冰淇淋三明治不同的地方?!Learn about the technical differences between Gingerbread and ICS [Updated]

薑餅與冰淇淋三明治不同的地方?!

可能大家都吃過薑餅,也曾吃過夾心冰淇淋,但是有沒有想過他們不同的地方?今天,讓我們來探討一下差異吧!

本文技術相關與對比資料皆來自Sony官方開發者部落格,所以相關的資料與內容也將以Sony為出發點。
對於冰淇淋三明治與薑餅,Android使用者該如何選擇?其實從Android 4.0出來開始,有人讚賞有人討厭,全新的介面也不只是換了皮而已,Sony工程師對於自家的薑餅(Android 2.3)非常的自豪,也覺得如果使用者追求的只是穩定並不一定要升級到ICS。
ICS本身其實是一套更強更聰明的作業系統,但是隨著Google移動服務的進化,還有許多應用程式的更新,其實都正在使用更多的CPU效能並且吞噬更多的RAM,這也是許多用戶覺得突然變得非常耗電的主要原因之一。但是,ICS全新的介面卻非常地吸引人!
若純論使用者介面,ICS帶來了許多新功能,並且換上了嶄新的介面,一個明亮且充滿科技感的使用介面;但,這也同時對會為自家產品換上Custom UI的廠牌來說是個麻煩,要能留下冰淇淋三明治的特色就勢必要花更多的時間與精神去重新設計,若只是沿用過去的風格,除非內容獨到,不然也很難吸引其他仍在觀望的消費者。而Sony的工程師也表示他們修改了超過一千個圖標,盡可能的建立了許多有Sony特色又有ICS色彩的圖標、桌布還有小工具,Sony這樣更新方式雖然成本極高,但是對愛嘗鮮的使用者來說卻是非常有吸引力的,也能讓舊有的用戶感覺到升級的「價值感」。
冰淇淋三明治不僅有著全新的外表,應用程式管理也更勝薑餅。Android一路玩下來的使用者一定了解,前期的Android必須要很愛用「Task Killer」,然而到了Android 2.3(薑餅) 之後這個「必備的狀況」就變得不是那麼必備,而ICS將「運作中程式列表」加入在使用者操作的介面之中,對於一些不熟Android而忽略Task Killer的生手來說,不必在忍受那記憶體飽和的「卡桌椅」,無論是哪種使用者,都僅需在螢幕上輕輕地劃過,便可關閉不需要使用的程式了。冰淇淋三明治還有另一個非常吸引人的功能-臉部辨識解鎖,這項技術也成了一些Android手機即使更新ICS後也無法嚐到的特色之一,不過至少去年發表的許多手機都有將前置攝影鏡頭加入,也似乎成了Android硬體的必備啦!聯絡人清單也有著許多改變,甚至是社群網站,而許多人愛用的日曆功能也加入了注目顏色同時也可以放大,甚至還有全新型態的語音信箱,Android 4.0確實是變得更聰明更方便了!
但是對於許多廠商還有開發者來說,薑餅進入冰淇淋三明治其實並不是改個版本號碼那麼簡單,有很大的困難因子是來自硬體上的進化。Android 4.0的示範手機 Galaxy Nexus 就是一款具備了雙核心且擁有1GB RAM的嶄新高效能智慧型手機,對於市場上普遍是單核心配上512MB RAM的智慧型手機來說,要吃夾心冰淇淋口感的順暢度可能不如薑餅來的好,其中有許多重要的差異,Sony在面對硬體規格普遍較弱的2011年Xperias將這些差異一一的排除,解決這些問題的工程師功不可沒。
更多RAM的使用一般,我們說的RAM是手機的工作記憶體,而進行運算時使用的是快閃記憶體。當然,這只是一個簡單的說法,而在”設定”的項目下你可以找到關於Android目前的記憶體使用狀況。前面提過Android 4.0是在1GB RAM的硬體下而生的,那對於普遍的512MB硬體來說呢?將有340MB被用作Linux user space(Linux使用者空間),而將僅剩下三分之一做為一般的使用。而許多ICS的運用程式,比起薑餅都會占用更多記憶體空間,像是瀏覽器就比薑餅上的多了20~30MB之譜。
當可用RAM過低時,這通常是40MB左右,應用程式管理系統將開始依據優先級關閉程式,從閒置的背景應用開始,一直到正在運行的程式,詳細的優先順序見下表。
而當被關閉的程式被使用者再次開啟時,管理系統將會關閉其他在背景的系統,甚至是桌面的小工具。例如大家應該都有經驗,當你打開一個非常吃效能的遊戲,然後遊戲後關閉他可能就會看到桌面的小工具全部重新啟動了一次,這就是應用程式管理介入了記憶體管理所造成的,但這也是不可避免的問題..。
與SQL資料庫連接過慢另一個冰淇淋三明治與薑餅的最大差別:Google將更多東西交給了SQL處理。讀取與寫入SQL的時間,會導致應用程式變慢,許多應用程式啟動時執行了很多SQL的操作,從而影響了啟動時間。
一個良好的做法,HTTP請求與資料庫操作並不應該在主要的使用中進行,但Sony的工程師發現ICS有不少這種狀況,不斷的在主要的工作中操作資料庫,這可能會導致其他的工作變慢。此外,根據目前許多不滿意的使用者的說法,我們可以支看到許多對於應用程式與遊戲上的問題。如果應用程式的讀取浪費太久的時間,將可能會出現Application Not Responding (應用程式沒有回應,ANR)。ANR的狀況會發生在應用程式沒有回應任何資訊,或是沒在限定的時間內回應。
這段的總結是,過長的系統反應時間還有容易出現ANR,都將會讓許多使用者更新到ICS之後使用起來變慢且不穩定的感覺特別明顯…。
完整的硬體加速
但是ICS並非一無是處,在圖形硬體加速這塊上,系統預設對所有的應用程式為API(應用程式介面) Level 14。 對於一些低API的應用程式,可以打開android:hardwareAccelerated=”true”指令。但是硬體加速也代表將使用GPU進行圖形渲染以換取更順暢的使用者介面,而這代表了某些應用程序將需要掛載更多的圖形庫,也就得消耗更多的RAM。
在一些實驗中,發現開啟硬體加速消耗的記憶體多了1-2MB,且比起沒有啟用浪費了更多的時間。而且如果使用者不是使用畫面非常強大的應用軟體的話,將看不出任何的差別。硬體加速的另一個問題是,他會更快的消耗光你的電池。特別是一個例子:撥放影片,硬體加速透過GPU運作,處理了每一格畫面,這比起沒有開啟硬體加速讓系統消耗了更多的電力。
對於兩個彷彿血脈相傳的系統下,Sony工程師將ICS的問題一一的點了出來,但是仍不可否認ICS的全新介面是充滿吸引力的,許多人對於薑餅與冰淇淋三明治的差異簡化為好與不好,這我想還是由使用者來想吧。面對更多改變甚至可能目前是陣痛期的ICS來說,他提供的更簡單且更聰明的操作是非常棒好的想法,然而Sony部落格這位工程師的血淚筆記,同時也點出了「薑餅」與「冰淇淋三明治」不同的地方…

*********************************************************

Learn about the technical differences between Gingerbread and ICS [Updated]


Ever thought about how Gingerbread (GB) and Ice Cream Sandwich (ICS) platforms differ on a technical level? In this blog post, we’ll describe some of the technical differences between GB and ICS, and what the differences in the user experience might be. This way you can decide if ICS is right for you, or if you prefer to stay on Gingerbread. Maybe you will prefer the new UI in ICS, or do you give a higher priority to the extreme stability of the Gingerbread platform? Read more after the jump!
Now as you might have seen, we’ve continuously kept you updated on our work with the ICS upgrade, and we started by telling you about what we do to get the latest software release from Google working on our Xperia™ smartphones in the article Ice Cream Sandwich – from source code release to software upgrade. Then we released ICS alpha and ICS beta versions of the coming software upgrade.
However, although ICS is new and compelling in many ways, we would like all of our users to make an informed decision when selecting what Android™ software to use. We are actually proud to say that our Gingerbread software is very stable and has great performance, so it’s not a bad idea to stay on this release. Ice Cream Sandwich is more intensive, for example in terms of resource usage. As smartphones become more capable, our own applications, as well as the Google Mobile Services (GMS) applications, are becoming more advanced, which means that they require more CPU power, run more network activities and use more RAM. On the other hand, ICS brings a refined UI and some nice new features as described below.
Comparison of the look and feel in Gingerbread (left) and Ice Cream Sandwich (right).
New features in ICSFrom a UI perspective, ICS is based on a new look and feel, the Holo theme. In order to accommodate the new look of Android, we decided to do an extensive touch up of our own assets, since the graphical assets of the Holo theme cannot be changed in any way as stated in the Android Compatibility Definition Document (CDD). New looks have been added in the platform layer as well as in the application layer. All in all, well over a thousand icons have been modified. In addition, we have deployed new wallpapers and application backgrounds, which harmonise more with the flatter graphical structures of ICS.
In ICS, the activity manager has a completely new UI, where all running apps are shown as thumbnails in a list. To close an activity, you can simply swipe it out of the list. ICS also introduces a face recognition app as a way to unlock the phone, called Face Unlock. Face Unlock uses the front-facing camera and advanced object recognition algorithms. It is included in our ICS upgrade for all phones that have a front-facing camera.
The contact list will show more information about the contacts, including updates from social networks. In the calendar, colour coding has been added and it is now possible to zoom. There is also support for a new type of voicemail that is more visual, offering transcriptions of voice messages.
When it comes to ICS, it’s a major upgrade of Android™, and there are a lot of things that have changed compared to the Gingerbread release. Some of these changes affect the performance and stability of the system, for example by using more CPU power and RAM. ICS was developed with Galaxy Nexus in mind, which is based on a TI platform with dual-core processor and 1GB RAM. We are now adapting ICS to run on our 2011 Xperia™ smartphones, which are all built on a Qualcomm platform with single core and 512 MB RAM. This means that in some cases, the resource usage in ICS is heavier on the system compared to Gingerbread. The following sections identify some key areas where there is a  difference between ICS and Gingerbread.
Increased RAM usageIn general, it can be said that the RAM is the working memory in the phone, used by running processes in contrast to the flash memory, which is mainly used to store things. As you might understand, this is a simplified explanation and might not be entirely true in all cases. However, it can serve as a help to understand the difference between the RAM and the flash memory of the phone. To see how much RAM is currently used, go to Applications in the Settings app of your Xperia™ phone.
Now, let’s look at how the RAM is used. Out of our 512MB RAM, about a third is used for functions that require a dedicated memory slot to operate fast enough. For example, this is the case for certain multimedia functions. The remaining space, which is at least 340MB, is reserved for the Linux user space, as required in the Android Compatibility Definition Document (CDD). Within the Linux user space, functions like the activity manager and Home screen app are running.
Another interesting thing is that many apps use slightly more RAM in ICS. For example, the web browser is quite intensive, and our measurements indicate that it uses 20-30MB more in ICS compared to Gingerbread. All in all, there are a lot of changes that together result in greater RAM requirement.
Illustration of the RAM usage.
When running low on RAM, typically with less than approximately 40MB left, the activity manager will start to close processes according to priority. At first, idle background activities are killed. The last thing to be closed down is the foreground activity. We have described this briefly in the table below. For more information, check out Android developers. (Please note that all figures mentioned about RAM usage are approximations and will differ depending on phone model and use case.)
Table showing different types of processes. When running out of RAM, the activity manager starts shutting down processes from the bottom and up, so that the last things to close are foreground and persistent activities.
Processes that are closed will obviously have to be restarted when the user enters the app again, which takes time and slows the system down. For example, when running a heavy game that uses all available RAM, the activity manager will be forced to kill all processes running in the background. This might include vital functions like the dialler and even the Home screen application. When you exit your game, there is a risk that the phone is perceived as slow, since the Home screen app will have to be restarted, just like every other activity you access afterwards.
Slower interaction with the SQL databaseAnother change in ICS compared to Gingerbread is that Google has moved a lot of the SQL handling from the native to the Java layer. In our internal studies, we have seen that read and write operations to the SQL database takes longer time, which slows down the apps. Many applications perform a lot of SQL operations when started, which greatly impacts the start-up time.
According to good practice, database operations or http requests should not be performed in the main thread. However, we know that there are quite a few applications that perform these kinds of operations directly in the main thread, which might cause them to hold up other operations. Also, when reading feedback on ICS software out on the market now, we’ve seen comments about people having problems with some applications and games.
If an operation takes too long, there is a risk of getting an Application Not Responding (ANR) as a result. An ANR occurs when an application doesn’t answer an intent, or responds to an input event, within a certain time limit. In case of intent, the time out is set to five seconds. For the input event, such as screen touch or button click, it’s ten seconds.
This can result in a user experience that is perceived as slower and less stable, due to longer response times and increased ANRs.
Introducing full hardware accelerationYet another change in ICS, is that the graphics hardware acceleration is on by default for all apps from API level 14. For apps at lower API levels, it can be turned on in the manifest with the attribute android:hardwareAccelerated=”true”. Hardware acceleration means that the GPU is used to render graphics, which enables a smooth user interface. However, it also results in at need to load additional graphic libraries for certain apps, which makes them use even more RAM.
When we performed internal tests on our applications, we saw that the Settings app consumed 1-2MB more RAM, and actually took longer time to start with HW acceleration, compared to without. Once the app is running, the UI is HW accelerated, but unless the app performs advanced graphics, the user will not see the difference.
Another effect of the hardware acceleration is that it can make the battery drain faster in some cases. An example of this is video playback, where the hardware acceleration requires every video frame to be run through the GPU, thus making the system use more power than it would have without HW acceleration.
As a developer, you should therefore evaluate if HW acceleration is required or not, as it comes with a cost in terms of RAM usage, start-up time and possibly even battery duration which can have negative effects on the user experience. You can read more about hardware acceleration in Ice Cream Sandwich on the Android Developers blog.
So, what will be your platform of choice? We hope this article clarifies some of the aspects to consider when making the decision. As always, we are eager to hear your opinion, so drop us a comment below and let us know! For more details on timing and practicalities on the ICS upgrade, check out this latest post on the Sony Xperia™ Product Blog.
Updated – comment from the Developer World team:
We we would like to clarify that above mentioned “challenges” have already been addressed by our SW engineering teams. For instance, we have not only optimised the RAM management by making the RAM usage for internal apps as good as possible, but we will also introduce a Performance assistant at start up when running ICS. In this Performance assistant, you can enable and disable certain services that you might not want to run on your phone, in order to optimise the performance of your phone.
We have also worked with quite a few partners in regards to architecture optimisations for SQL handling. In addition, we have also optimised the hardware usage. And as a result of this article, a number of app developers have notified us that they are evaluating if HW optimisation will be needed or not for their apps.
The aim of this article was to share our knowledge regarding the different characteristics for ICS and Gingerbread in an open way, as we strive to have an open communication with the developer community. All in all, we would like to point out that it’s our clear aim to deliver an as good ICS update as ever possible. As you might have seen on the Sony Xperia Product Blog, we’re not far from releasing it now. Thanks for all the feedback!
More information

沒有留言:

張貼留言