從開發者角度談導致手遊加載緩慢的3大原因

原文作者:Joseph Lewis 譯者:Megan Shieh

遊戲上線以後,開發者就會陸續收到來自玩家的評論,在這些評論中可能會出現類似“這款遊戲加載太慢了”的字眼,這類抱怨較爲常見。遊戲的性能十分關鍵。大量的研究和實際經驗告訴我們:移動用戶在面對性能缺陷的時候,非常沒有耐心。此外,用戶對遊戲的第一印象至關重要。

但是如果有用戶抱怨你的遊戲太慢了,下一步該怎麼辦?是什麼在拖慢手遊的加載速度,我們該如何解決這個問題?

cut the rope(from vicffie.blogspot)

cut the rope(from vicffie.blogspot)

首先,我們得了解你所面臨的一些自然挑戰。大多數移動應用程序都仍在使用TCP,TCP是最常用的互聯網協議之一。雖然TCP對於30年前創建的有線網絡而言效果不錯,但是把它放到移動設備上的時候,卻存在嚴重的侷限性。TCP協議主要有三個缺點:一是傳輸效率低,二是不能有效地處理丟包問題,最後一點是它不能正確地處理IP地址的變化。

除了TCP的侷限性和無法控制的移動網絡條件之外,還有一些其他的因素會影響移動遊戲的性能,你可以而且應該修復這些問題。下面讓我們來看看一些最常見的問題,以及避免這些問題的方案。

1) 配置錯誤的緩存

雖然緩存可以幫助加快應用程序的用戶體驗,但你得配置對了才能真正帶來好處。簡單地說,遊戲緩存的內容同時也會附帶服務器的相關指令——從源服務器重新獲取副本之前,這些內容應該在用戶的設備中儲存多長時間。頻繁更改的內容應該儲存較短的時間(例如,週末促銷用的圖像只需要存一個週末就可以了),而不頻繁更改的內容則應該儲存較長的時間。

開發人員通常會將它們設置爲默認值,或者將所有內容都設置爲短時間儲存。這樣的話,往返原始服務器的次數就會更多,因而用戶等待內容的時間就會更長。

2) SDK

如今,平均每個安卓應用程序都安裝了15個不同的SDK。這些SDK都有用,它們可以提供各種各樣的服務,比如分析、崩潰日誌、支付處理等其他重要功能;但它們也會對應用程序的性能產生很大影響。

使用第三方服務的SDK是一種爲遊戲添加功能的簡便方法,但它們會使應用程序依賴於超出你的監督或控制範圍的服務器和服務。如果一項服務速度慢,或者掉線了,會給你的用戶帶來糟糕的體驗。用戶不會在乎出錯的是你還是第三方服務,他們會直接把責任歸咎到應用程序身上。SDK發出多個或頻繁的請求可能意味着更長的CPU時間,移動設備發送和接收數據的時間也會變得更長,這不僅會影響到性能和速度,還會影響到電池壽命和用戶的流量。精細化地管理安裝在應用程序中的SDK,以確保用戶擁有儘可能好的遊戲體驗。

一種特殊的常見SDK–廣告網絡SDK—會帶來一些特殊的難題。許多廣告網絡也是轉售商,這意味着你可能無法知道每個廣告的來源,或者你可能會意外地通過正在使用的同一個網絡來爲新的供應商提供廣告服務,從而導致了性能的突變。問問你的廣告網絡提供商,他們採取了什麼措施來保持最好的性能?如果有一個網絡正在持續地影響應用程序的速度,那麼嘗試着把這個SDK刪掉或者降低它的優先級,看看它是怎麼影響遊戲的整體性能的。

3) 處理內容的效率低

另一個常見隱患是,應用程序單次加載的內容量。它會因爲各種不同的原因而影響到程序的速度:可能是在加載尚未在屏幕上顯示的內容;也可能是在加載對移動設備而言,優化不佳的資源和圖像。例如,當移動應用程序正在請求超高分辨率的圖像時,就會發生加載緩慢的情況,因爲這些圖像最終也還是會在UI中被按比例縮減。市面上有這麼多款不同的設備,以及隨之而來的多種屏幕尺寸,確保你所提供的圖像與用戶的屏幕大小吻合,這點很重要。有許多的服務和解決方案可以幫助你處理這一問題。但重要的是要確保它們的配置正確,並且不要讓應用程序在移動設備上重新調整大小。

最重要的是,瞭解你的應用程序

現在我們已經知道了導致遊戲加載緩慢的一些原因。那麼,在影響用戶體驗之前,我們如何能夠實時地檢測性能問題並排除故障呢?有效跟蹤移動應用程序性能的一種方法是:使用“移動應用性能監測工具”(Mobile Application Performance Monitor,APM)。市面上有多種APM可供選擇,最好是選一個專門針對移動應用程序的APM,它還需要帶有警報系統和基本的控制功能。監測應用程序的實時性能,瞭解哪些URL在導致錯誤,更好地排列它們的優先級,這是管理應用性能的最佳方法之一。它還能幫助你提前發現問題,避免用戶差評。早早發現問題,早早解決。

本文由遊戲邦編譯,轉載請註明來源,或諮詢微信zhengjintiao

You’ve finally done it. After all your effort and hard work, your mobile game is live. At last, gamers are going to experience with your creation. But then it happens. The user reviews start coming in, and they aren’t pretty. “This game loads too slow!” is a common complaint, but you don’t have any insight or metric to help determine WHY it’s slow.

Performance matters. A growing mountain of research and real-world experience tells us what you can probably already guess: mobile users are very impatient when it comes to performance, and you really only get one shot at a first impression.

But if your users say your game is slow, what next? What makes a mobile game load slow, and what can be done to fix the problem?

The first step is to understand some of the natural challenges you’re up against. Most mobile apps are still using TCP, one of the most commonly used internet protocols. While TCP is perfectly fine for wired networks that were created 30 years ago, it has serious limitations when used for mobile devices. TCP has three main drawbacks: It uses available network bandwidth inefficiently, it handles packet loss ineffectively, and lastly, it can’t handle a change of IP address properly. All of these are common issues on mobile networks and require a different, mobile-centric approach.

Beyond the limitations of TCP and uncontrollable mobile network conditions, there are other factors that can compromise a mobile game performance, which you can and should fix. Let’s take a look at some of the most common issues, and what you can do to avoid them.

1. Incorrectly Configured Caching

While caching can help speed up your app’s user experience, it needs to be properly configured in order to actually confer a benefit. In simple terms, content being cached comes with instructions for the server about how long a copy should be cached before it needs to be re-fetched from the origin server. For content that changes frequently, this should be an appropriately short value (the images for a weekend sale or similar event need only be cached for the length of the event, for example) while content that doesn’t change frequently should have a longer value.

Often, developers leave these values set as a default, or use the same, shorter time for all their content. This results in more round-trips overall to the origin server, which translates to more waiting for content for your users. You can find more detailed information on caching and how to configure it in this blog post.

These days, the average Android application has 15 different SDKs installed. These SDKs are useful, providing valuable services like analytics, crash reporting, payment processing, and other important functions, but they can also have a big impact on application performance.

SDKs that make use of 3rd party services are a convenient way to add functionality to your game, but they leave your app relying on servers and services beyond your oversight or control. If a service is slow, or goes offline, it can lead to a poor experience for your users, who don’t care if the problem is with your app or some 3rd party service used by your app. SDKs making multiple or frequent requests can mean more CPU time, and more time that the mobile device is transmitting and receiving data, which can impact not only performance and speed, but also battery life and your user’s data plans. Careful management of the SDKs installed in your application is an important part of ensuring your users have the best possible experience with your game.

One specific and common type of SDK – advertising network SDKs – come with their own specific sets of challenges. Many ad networks are also resellers, meaning you may not always know for sure where the ads in your game are coming from, or you may suddenly be serving ads from a new provider through the same network you’ve been using, leading to sudden shifts in performance. Ask your ad network provider what measures they’re taking to keep performance at a maximum, and if a network continues to affect your app’s speed then try removing their SDK or reducing its priority and seeing how it affects your overall game performance.

3. Inefficient Asset Handling

Another common pitfall affecting app performance is simply how much content the app is loading at a time. This can happen for a number of reasons. It might be loading content that isn’t displayed on the screen yet, or it might be loading images and resources that are poorly optimized for mobile devices. This happens when apps are requesting desktop-resolution images that are going to be scaled down in the UI anyway, for example. With so many different devices and the myriad of screen sizes that comes with them, it’s important to make sure that you’re serving images that are an appropriate size for the screens that will be displaying them. There are a number of services and solutions that can handle this for you, but it’s important to make sure they are configured correctly, and that your solution isn’t handling the resizing on-device.

Most Importantly, Know Your App

Now that we know some of the causes for game slow load times, we’re back to the question: how can you detect the performance issues and troubleshoot them in real-time, before they affect your app’s user experience? One way to easily gain insight into your mobile app behavior is to utilize a Mobile Application Performance Monitoring (APM) tool. There are a lot of options available, but here, too, it’s essential to utilize a mobile-first APM and look for one that offers alerts and basic control features. Knowing how your app behaves in real-time, what url’s are causing errors, and how to prioritize them better is one of the best ways to start getting a handle on your app’s performance. It will also help you find out about problems faster, before you start hearing about them in negative app store reviews. (Source:www.gamasutra.com