Blogs

A Developer’s Take on How to Make an iOS App Lighter and Faster

BLOG by 

CitrusBits
September 16, 2022
#XR #VR #UX #UI

Have you ever been told the iOS app you put your sweat and blood into is terribly slow? Did you get disheartened by these reviews? If so, you’re not the only one!

We’ve all been there, we find a way to make our apps faster, lighter and better. You keep second-guessing what you did wrong and whether or not it was a good strategy. But here’s the thing – maybe you don’t have to start from scratch or reinvent the wheel all over.

There is only code you need to crack here – find out what’s the root cause of the problems your users are facing.

Ways to Measure Your App’s Behavior to Find the Cause of the Problem

The mobile app development process doesn’t just stop once the app is released. Once your mobile application is available to the public, you have to continually optimize it to ensure its performance is up to the mark. This step comes once your app has established a healthy user base.

“I wish this app was faster” is probably the last thing you’d want the users to say about an app you’ve worked tirelessly on for hundreds of hours.

Even if things seem to be going as planned and your target audience responds well initially, you still need to track its performance while continuously improving the user experience to make sure it stays that way.

To start with, you need to determine your app’s KPIs (Key Performance Indicators). Defining KPIs will provide clarity on how you define your app’s performance, as well as what your process is for measuring it.

Once you’ve defined your KPIs, the next step is to simply track the data.

Following are the basic indicators that’ll help you track your app’s success.

  • General app KPIs
  • User engagement KPIs
  • Revenue metrics
  • User experience and performance metrics
  • Marketing KPIs
  • App Store category ranking

Keep in mind that while all these indicators are important in determining the app’s success, you’ll have to determine which ones are the most relevant for your app and track them.

Let’s review the key indicators in the top three KPIs to help measure your app’s performance.

General App KPIs

Before we begin with the general mobile app KPIs, remember that how much importance you attach to each KPI depends on your product, and thus may vary from one app to another.

App Downloads

The number of mobile downloads speaks for the app’s popularity, but alone it may not be the best indicator of an app’s success. Keep a closer eye on the user reviews that show you what your customers like about your app, and what still needs improvement.

Upgrades

If your app has both a free and a paid version, this KPI can help you track the number of people who update the app to the premium version, how long it takes them to do so, and whether the premium version is receiving higher or lower ratings than the free version.

Subscriptions

If you offer subscriptions, a quick and easy approach to see if your app is working smoothly or not is through tracking them (including canceled ones). An increase in unsubscribes should tell you that certain features need updating or have other issues that you might have overlooked. You can also track how long it takes users to subscribe after downloading your application.

User Engagement KPIs

Measuring engagement is another useful metric to track an app’s progress and identify areas that need improvement. User engagement KPIs indicate when, how, and where the users are engaging with your product and collect the relevant data.

Look for the following key indicators while measuring engagement.

Retention Rate

Here’s an easy formula for you to calculate your app’s the retention rate:

Retention Rate = ((CE _ CN)/ CS) X 100

where:

  • CE: Number of customers at the end of a period
  • CN: Number of newly acquired customers during that period
  • CS: Number of customers at the beginning of a period

Average Sessions

For mobile apps, user engagement is measured in terms of app sessions – how often a user has interacted with the given app and for how long. This indicates the app’s popularity among its users.

Daily Active Users

Daily active users(DAU) is a metric used to determine how many users log in and engage with an app each day. DAU is the preferred metric for companies to assess both the present and potential growth and engagement of their mobile apps.

Churn Rate

Churn rate refers to the rate at which customers uninstall or stop using your app.

High churn rates are a bummer, but measuring the rate at which people uninstall your application or unsubscribe will only help you keep it as low as possible. If you notice high churn rates, you might want to take a look at general functionality issues like crashing issues, lack of updates, etc.

Revenue metrics

Your mobile app is not just about the end-user experience. Ultimately, the purpose of your app is to generate revenue for your business. You can measure how your app generates money in the following ways.

  • Customer acquisition cost (CAC): Divide gross revenue by the cost of advertising to determine the CAC.
  • Customer lifetime value (CLV): Here’s a simple formula to measure the amount of revenue your app has generated:
    CLV= Average Purchase Value X Average Purchase Frequency Rate X Average Customer Lifespan
  • Return on investment (ROI): ROI can be calculated by dividing the revenue gained by the time and money spent on marketing.
  • Average revenue per user (ARPU): ARPU will help you determine how much a user spends on your application, eventually helping you with making additional sales. Here’s how you can calculate it:

    ARPU= total revenue of your business / total number of customers you have in a given duration.

User Experience and Performance Metrics

One of the crucial steps in approaching application performance monitoring is tracking and measuring user experience. No matter how passionate you may be about your app, ultimately it’s your users who determine its success.

Measure the following indicators to determine the areas that you’d need to improve in order to improve application performance.

Load Speed

You never want to hear your users complaining about your app loading slower than a slug. There can be two types of delays in your apps:

  1. Displaying splash screen for longer than three seconds.

This could happen for two reasons:

  • Image size: The used images do not scale well for different screen sizes.
  • Components placement: you didn’t follow launch storyboard guidelines.

2. Long method of pulling events from the event server. You can optimize it by using Elasticsearch.

While developing the Erupt app (news and debate platform), we solved the delay issues by implementing batching on the backend server. Simply put, pull the first batch that is 1-10 items instead of pulling 100.

You can measure your application’s loading time in the following two ways:

  1. Launch Time pane in the Xcode Organizer to view the number of milliseconds between the user tapping your icon and when your first screen is drawn, after the static splash screen.
  2. Firebase by clicking on the Performance tab under the Release and Monitor menu.

Once you’ve recorded how long it takes for your app to launch, you’ll need to determine what is causing the delay. A way to track what causes it to load slower is through profiling your app’s code, during which instruments gather information about what methods your app called and how long did it take to execute them. Use this data to identify potential bottlenecks or issues in your code.

For instance, while developing the Erupt application, we tackled delayed app launch by profiling the app launch under different situations (considering the cold and warm launch) to see how these factors affect the experience.

Following was our approach to improve the Erupt app launch and optimize it’s load speed:

  1. Reduced dependency on external frameworks and dynamic libraries.
  2. Reduced the static initializers in the code.
  3. Moved expensive tasks out of the application delegate.
  4. Reduced the complexity of initial views.
  5. Optimized the network API calls e.g. removed the redundant jobs that run after a simple startup and when the application is opened from the notification tray.

Our approach involved gathering data that affects launch time (either directly or indirectly).

Here’s what you can do to monitor your app’s performance.

  1. Switch on the device, unlock it, and launch the app.
  2. Force quit the app and relaunch it. The system will terminate the app processing followed by a warm launch.
  3. Launch the app directly from the notification.

Crash Reports

Crash reports reveal the exact moment a crash occurs, pointing out what caused the problem and where, playing a critical role in making the app development and maintenance process smoother and faster. Crashes can occur due to various reasons including the complexity of the product and unexpected user actions.

Following are the most common reasons for crashes:

  • The array index is out of bound – a buffer overflow error that occurs when the index used to address array items exceeds the allowed value.
  • iOS doesn’t load view into view hierarchy unless it is rendered. Accessing any elements (IBOutlet) will surely cause a crash.
  • Fatal error unexpectedly found nil while unwrapping an optional value.

You can use Firebase Crashlytics to analyze the reasons for crashes as

  • It helps prevent manual work
  • Identifies where the crash occurred and why
  • Reports every time a crash occurs

Since the ‘index out of bound’ exception is very common among developers. The good thing is we can avoid it by utilizing the power of swift extensions.

How to Plan and Execute Performance Approval Cycles into an Existing Application

As a mobile application developer, the responsibility is on you to make sure your app performs well. If it takes forever to launch, lags, or responds too slowly to any input, it appears to the users as sluggish.

Here’s a scientific approach you can use to execute a well-planned performance improvement cycle.

  • Collect information regarding the problems your users are facing
  • Evaluate your app’s behavior to find the root cause of the problems
  • Plan one change to improve the situation
  • Implement the change
  • Look for any improvement in the app’s performance

Let’s take a look at the key elements that you should consider to improve iOS apps’ performance and how we deployed them in our processes to yield great results.

App Size

Although app size doesn’t have a direct impact on in-app performance, it does have an influence on potential users who consider installing your application. App size puts a strain on the user’s limited disc space, eventually resulting in taking longer than expected to download and install the application.

App Launch

The OS optimizes resume and warm launches so we should focus on cold launches. In the 2019 WWDC talk, Apple urged the developers to aim and strive for a 400 ms cold app launch, described as follows:

  • For the first 100ms, iOS will do the necessary system-side work to initialize the application
  • You must create your views, load your content, and generate your first frame over the next 300ms.
  • Your app should be launched and interactable after the initial 400ms. You can still keep on loading additional content afterward.

App Responsiveness

Just as Apple states,
“When the app responds to gestures and taps in real-time, it creates an experience for users that they’re directly manipulating the objects on the screen. An app that doesn’t respond within a short time shatters this illusion and leaves users wondering whether the app works correctly at all.”

Our development team sticks to our maxim – ‘Performing any UI activity other than “main queue” is a crime.’ This applies conversely to all network and time-consuming processes.

In most cases, developers update the UI without making sure that it’s the main queue. This results in app hangs and delayed updates on the user interface.

A common mistake is when a background task is performed and there no indicator provided for the user. This leaves the user in many undefined states. For example, if you have disabled the user interaction during a background task to reduce the vulnerability but didn’t provide a good indicator, it will be perceived as an app hang where the app is functioning correctly, but just not providing the exact state/message for the end-user.

We came across similar app responsiveness issues while developing chemoWave (a HIPAA compliant healthcare platform for chemotherapy patients), Pelican-Pentair (an e-commerce app with built-in NFC scanner capabilities for Pentair – global leader in water treatment), and JobFlare app (an innovative job search platform with science-backed games, connecting job seekers to opportunities).

Take a look at the best practices that we applied to improve app responsiveness:

  • Keep the main thread free from non-UI work
  • Use high-level concurrency constructs to avoid having too many threads
  • Minimize view update time
  • Load network data in batches where the response is in a long list of arrays
  • Make all Datasource set up operations in a background view and update the UITableView under the main queue only when needed
  • Reduce main thread operations in view load calls

Here’s a basic approach you can follow to monitor the responsiveness of an app;

  • View load times
  • View update times
  • Scroll hitch rates
  • App hangs

Memory Usage

You can improve your app’s performance by analyzing memory-use metrics and making changes to maximize memory efficiency.
Optimizing our apps help us to utilize the main memory efficiently and eliminate the disk operations as much as possible.

Xcode helps in analyzing the memory used by the app with the following two metrics:

  1. Peak memory usage: Highest memory use observed.
  2. Offline memory usage: Observed on suspension, when the app enters the background.

While working for brands as big as Burger King and Urban Plates, we used the following guidelines and practices to analyze memory usage and optimize it in the best way possible.

We generated the memory graph of the objects and allocations in our app from the button ‘Memory Graph button’ in the Xcode’s debug area at the bottom of the workspace window.

  1. Optimized image assets
  2. Reduced the size of core data transactions
  3. Discarded unused view objects
  4. Eliminated memory leaks

Battery Usage

An app that consumes too much power can lead the users to uninstall the application.
Apple has an extensive collection of WWDC talks and articles that will help you debug and write energy-efficient applications.

Disk I/O

Many apps that write to disk slow themselves down and can wear out the user’s SSD faster than expected, negatively affecting the user experience across the entire device.

There had to be extensive API calls and disk operations in the Burger King mobile app as we had business logic to cache store information from the remote server. Therefore, we batched and reduced network operations (as possible) and avoided unnecessary UI updates. We prioritized the API calls and UI updates. Also, the disk operation and core data transactions were optimized to reduce size.

We faced similar issues while developing the Champions Round app that delivers live score updates to the users. Real-time (socket) communication undoubtedly draws significant power as compared to conventional HTTP rest base APIs.

We made sure to deallocate all the socket connections and resources as soon as the app goes either to the background state OR the user switches to any other view which does not require real-time updates. Smart interactive micro animations were used that provide a good UX while maintaining the efficient use of battery power every time the user returned back to the scorecard (that requires real-time updates).

Take a look at the extensive guide Apple has provided on improving your app’s responsiveness by optimizing how it writes data to permanent storage.

How to Resolve the Following Issues and Improve an iOS App’s Performance

When choosing the profiling template that is relevant to the metrics you’re considering, use instruments to profile your mobile application.

For unresponsiveness and hangs, use the Time Profiler template.

We often used the time profiler template to sort out unresponsiveness in the Burger King app since it clearly presents the allocation with the associated time. We were able to decide what object needs to be allocated in a lazy-loading pattern.

For memory issues, use the Allocations and Leaks template.

The major mistake that many developers unintentionally make is a strong retain cycle. One effective practice that we have developed in our team and applied to many of our apps, like JobFlare and chemoWave, is to keep a weak reference of self whenever it is accessed within a closure.

For power-consumption issues, use the Energy Log template.

When an app suspends connections and deallocates resources as soon as it changes its state from foreground to background, this helps reduce battery consumption. We followed a similar approach in the Lovesac application which is highly optimized for different app transition states (background, foreground) and highly reliant on the device’s Bluetooth connectivity for data transfer.

For I/O issues: Use the File Activity template.

In our case, keeping an app as complex as Kedalion Therapeutics (with constant I/O operations) responsive wasn’t as simple.

The Kedalion Therapeutics app connects with AcuStream devices using Bluetooth technology. It constantly searches for an available AcuStream device and connects to it immediately, displaying a connected indicator for the end-user. All the continuous search and connect services are performed in a background queue by utilizing best practices of the CoreBluetooth framework and CentralManager class.

The device sends the data to the app when a dose is taken by the patient, all I/O operations are performed under the background queue, and UI gets updated on the main thread which keeps the application responsive.

For network-related issues, use the Network template.

When developing an app as big as Burger King, you do tend to come across major performance challenges. Here’s how we donned our armor and dealt with them!

Due to business logic and backend limitation, we had to keep the limited database inside the application. The data was very lightweight in terms of size but it required intensive CPU operations. We implemented a smart queuing mechanism for all DB-related queries with a hybrid data fetch and display model that has a very minimal performance impact and keeps the app UI responsive to the best extent.

After Testing Your App’s Performance, a QA Should Be Able to Pinpoint the Following Feedback

Though every test report may vary depending on individual company format and practices, a typical test summary report template generally contains a summary of test activities and final test results, and an assessment of how well the testing is performed

While largely subjective, this usually includes:

  • Important information uncovered by the tests conducted
  • Quality of testing effort
  • Quality of the mobile application
  • Statistics derived from incident reports
  • Different types of testing performed and time taken for each of them
  • Based on the test report, stakeholders can

This report allows stakeholders to:

  • Evaluate the quality of the tested product
  • Decide on the software release. For example, if the test report informs that there are many defects remaining in the product, the stakeholder can delay the release until all the defects are fixed.

Why You Must Use Xcode and Instruments to Measure and Improve App Performance?

Xcode instruments, the performance analysis and testing tool for developers that comes free with Xcode, has plenty of useful tools to inspect and improve an iOS app.

These instruments effectively:

  • Track down problems in your source code
  • Analyze your app’s performance
  • Find memory problems

Although most of the instruments can be run on the simulator, it is not recommended to do so. Use a physical device for more realistic results.

Take your time getting to know the available instruments so that you know when to use a specific instrument and kickstart your performance improvement cycle.

How Would You Optimize Your App for Multitasking?

In terms of user experience, multitasking means being able to easily to open and switch between multiple apps at the same time.

To add multiple windows to your app, you create scenes for each instance of your user interface using UIScene. When you add support for UIScene, consider also implementing modern state restoration, which lets people come right back to what they were working on in your app rather than resetting to the main screen.

Wrapping It Up

Monitoring key metrics and following how they trend over time can help you determine what needs your attention now and in the future. It gives you the insight you need to determine where to best spend your time and resources reducing user friction.

Furthermore, sticking to KPI-based optimization plans is a big step towards creating a trustworthy base for your app’s growth. This will give you an accurate picture of exactly how your users interact with your mobile app, which is a significant step towards continually delivering valuable tools to your users.

We’d like to reiterate that the emphasis on each KPI will vary depending on the product, so it is important to tailor each KPI to your specific app.

If you’re looking for ways to give your iOS app a makeover or build a new one, worry no more. We’re here to give your app that glow-up you’re looking for.

CitrusBits is a leading custom software development company that specializes in creating innovative solutions tailored to meet unique business needs. With a team of expert developers and designers, they deliver high-quality mobile app development services, empowering businesses to engage their audience and drive digital transformation. CitrusBits’ commitment to excellence and customer satisfaction makes them a trusted partner for companies seeking cutting-edge software solutions.

About the Author

CitrusBits

Content Writer

Lorem ipsum dolor sit amet consectetur. Odio ullamcorper enim eu sit. Sed sed sociis varius odio vitae viverra. Eu sapien at vitae vulputate tortor massa semper vel. Lectus sed gravida blandit lorem consequat erat integer non ut. Morbi amet dui cras posuere venenatis. Laoreet sapien lacus sit sit elementum risus massa auctor. Enim ornare pharetra quis massa fusce. Nibh vitae in erat ut mollis erat. Amet cursus ut sem condimentum ultrices. Felis morbi malesuada sit amet ultrices at ut consectetur.

Newsletter

Let’s stay in touch