Skip to main content
December 20, 2012
Windows Phone Developer Blog

Network Monitoring for Windows Phone Apps



This blog post was authored by Rahul Bagaria, a program manager on the Windows Phone developer tools team.

Jonathan


Consumers and businesses are increasingly becoming dependent on the continuous connection of smartphones to networks. However, there is a side effect that stems from such pervasive network connectivity, which is often termed as bill shock for smartphone users. Users are frequently billed unexpectedly high connection fees due to their bandwidth use, which most of the time is a result of using apps that download data that is not necessary and are frequently bandwidth inefficient. It leads to a bad user experience, which is going to increase as more enterprises integrate apps in workplace operations. Additionally, the emergence of 4G will compel users to stay permanently connected.

High bandwidth usage is not the only network problem experienced by users; let’s look at some of the other problems stemming from poorly designed apps:

  • Continuously pinging the network and performing redundant downloads, as well as other inefficient network use impacts high energy consumption and leads to quick battery drain, sometimes twice as fast as that of similar apps with proper design.
  • Apps are slow to load pages or are unresponsive to user actions due to heavy download in low speed or poor quality networks

As a developer, it makes sense to design network-efficient and energy-efficient apps, which ultimately leads to good user experience and better ratings and reviews. It means a user should be able to run these apps without any worry of it draining the battery unexpectedly, or leading to bill shock or unresponsiveness. Here I present a new tool called Network Monitoring which will allow you to visualize how network efficient your apps are and optimize them to efficiently consume fewer resources.

Network monitoring

Before we go into further detail, let’s review our typical photo app which, we had seen when exploring Simulation Dashboard (check out the PhotoSlydr app which was optimized using the following steps):

  1. On the Debug menu, select Start Windows Phone Application Analysis or press Alt+F1.
  2. In the Application Analysis screen, choose Monitoring and press Start Session.
  3. The app will be started on the chosen target, and the Application Monitoring tool will gather data in background.
  4. Exit the app by pressing the Back key; the monitoring session will end and a Summary Report will be generated.

I just ran the app, selected an album, and explored it on the next page. I tried using both 3G and Wi-Fi using the Simulation Dashboard to understand the difference in user experience and network information. Here are the results:

clip_image002

The information we can glean from the summary is that our app downloaded 6.44MB of data just for browsing a photo album, which will be extremely heavy on the pocket of a budget-conscious user and will take loads of time to download on low-speed networks. Clicking the Alerts section, we come to the Graphs page:

clip_image004

As you will notice, there is a Network data transfer graph (5th graphic in the image above) that displays the network usage of the app in both uploads (purple) and downloads (green). There are also some network markers in the External events section at the top, which are distinguished by their blue color. These markers identify user-triggered Network Simulation Changes (in this case we had first 3G Good and then Wi-Fi Good in the scenario.) It is clear that the download speed was low during the 3G scenario, which immediately increased as we switched to Wi-Fi.

As first steps, we can easily identify and use smaller resolution images from the Flickr API to download thumbnail images, which are sufficient for browsing the album. Later on, we can also customize our code using Data Sense APIs to adapt to the device network type and choose higher resolution images for Wi-Fi networks to provide a better experience. When I made these enhancements and ran the app again on a simulated 2G network, I could clearly see how the app performed efficiently, even at such low speeds:

clip_image006

Data downloaded decreased to 0.77MB, which was a significant improvement that led to lower battery and memory use. Users can effectively use the app over 2G networks too!

clip_image008

An upload scenario

As another example, let me show you a different app published in the Windows Phone 7.5 Marketplace called Artify (used to convert images into ASCII Artwork). When I upgraded to Windows Phone 8.0 and ran under App Monitoring, it gave me the following graphs:

clip_image010

The Network data transfer spikes that are shown in the graph represent the stage in the scenario when I tried to upload an artwork on my SkyDrive account after authentication. Hence, you will see purple spikes in the second half of the graph, indicating actual uploads to the server. The largest spike occurred because of an actual upload (also indicated by the external event marker at top, which says that I performed a Tap on the Upload button).

Some common issues leading to network inefficiency

By recognizing common issues found in typical apps that need to connect to the Internet to transfer data or use web services, you can identify the same issues in your apps and solve the issues efficiently. The following list provides common network issues:

  • Apps performing multiple data downloads at small intervals can cause the network interface to be up for a long amount of time due to tail states, which can be avoided by batching the downloads in chunks to save on Network Power.
  • Apps undertaking periodic transmissions of small packets of data for housekeeping or pinging purposes constantly shift network interfaces to full power and can be optimized to save on up to 40–50% of the battery consumption.
  • Apps using Data Virtualization download data as and when required, which consumes high network energy. The total data size involved should be analyzed, because there are tradeoffs, and pre-fetching the data at start is often more efficient and not impact user experience significantly.
  • Apps are found to frequently download the same media at every refresh or connect to the same addresses, leading to waste of bandwidth and energy; caching can help in these cases.
  • Many video or audio apps stream data at low bit rates even when the device has high bandwidth available. Using Data Sense to customize apps for the available network can help save energy and time.

Best practices for app developers

The Network Monitoring tool is a useful accompaniment that you can use to identify, visualize, and fix network issues in your apps. In addition to the tool, there are some best practices as well, which can be followed based on the type of app and the target market. The following list provides some best practices for app developers:

  • Optimize the frequency of using the network and pinging the radio/network interfaces.
  • Depending on the user experience, transmit as much data as possible in a single burst (analyze tradeoffs in benefits of Data Virtualization for your scenario using Network Monitoring).
    • For example, news apps might not benefit from virtualization of headlines’ texts because pre-fetching these small data items can greatly conserve battery.
    • On the other hand, downloading all images from a photo album at one go might waste lot of bandwidth and degrade response time if the user is not going to view all of them.
    • For video apps, however, it might be useful to download media in small segments at periodic intervals, which can be stopped if the user does not continue.
  • Caching should be utilized whenever possible to avoid downloading the same media and wasting bandwidth. Only items that have been modified should be transmitted.
  • Apps should be designed to adapt to the network available on the device and offer customized levels of resolution depending on bandwidth and user requirements.

In conclusion, ensure that you can limit the amount of time connected to the network and minimize the number of connections required for optimum network and energy efficiency and a great user experience.