Mobile game ads generate a large portion of app revenue for developers. This is why mobile developers need a proactive way to uncover problems with ad SDKs. If you’re having difficulty troubleshooting your third-party or Unity ad SDK, we’ve rounded up a few of the best tips.

In this blog, we’ll cover how to:

  • Move ad SDKs to a background thread
  • Monitor the performance of ad SDKs
  • Take corrective action

Here are a few of the most effective ways that a developer can troubleshoot a mobile game ad SDK:

Move ad SDKs to a background thread

One of the best things you can do is move your third-party or Unity ad SDK to a background thread. This is advantageous because it:

  • Improves game performance: Moving your ad SDK to a background thread prevents the game thread from being blocked by a faulty ad SDK. This means that your game can load and display ads faster for a more seamless user experience.
  • Reduces the risk of ANRs: If an ad SDK experiences an error or exception, it will impact this background thread instead of the main game thread.
  • Increases ad revenue: Reducing the impact of your ad SDKs on your mobile game performance means it’s likely that you’ll be able to show more ads with less friction on the user experience.

Here is how you can move your ad SDK to a background thread:

  1. Prepare and load your ad by requesting the content.
  2. When the ad is ready, pause or suspend the app elements as necessary based on your ad SDK.
  3. Show the ad.
  4. When the user dismisses the ad, resume app elements.

You can reference the example below as a guide on how to load and show an ad in the background rather than blocking the main thread and possibly producing an ANR.

public void LoadAndShowAdInBackground()
	// Assume that all other necessary pausing 
    	// of functionality is or has been handled.
	var adTask = Task.Run(() => LoadAndShowAd());
private void LoadAndShowAd()
	// Hold onto this reference somewhere to 
    	// prevent it from being cleaned up.
	var adProvider = new AdProvider();
	var ad = adProvider.LoadAd(adConfiguration);
	while (!ad.isReady)
        // Configure the above to be longer 
       	// or shorter as necessary.

Monitor the performance of ad SDKs

Once you’ve moved your ad SDKs to a Unity background thread, the next step is issue mitigation. There are many technical issues that can happen in an app. Unless your monitoring platform accounts for them, you won’t be able to spot issues with ad SDKs that greatly impact your end users’ experience. You can measure the performance of your game through the following measures:

Check during SDK initialization

The ability to view key moments like startup time source issues quickly. Since ad SDKs are often initialized during startup, you want to monitor issues that occur here. You should monitor changes like:

  • An increase in startup time: This surfaces SDKs that take too long to initialize.
  • A spike in incomplete startups: This reveals broken SDKs that block your app.
  • An uptick in abandoned startups: This uncovers slow, broken, or failing SDKs that are causing user frustration and abandonment.

This method of proactive monitoring keeps you ahead of significant user complaints.

Startup time measurement in the Embrace dashboard.

Track network call performance

Your ad SDKs don’t send requests to your backend. This is why you need to measure the performance of these first- and third-party network calls from the perspective of your users to understand where they fail.

At minimum, you should know:

  • Which ad calls are failing. If the ad isn’t loading correctly, then you’re not being paid.
  • Which ad calls have long load times. When ads take too long to load, it leads to freezes and ANRs.

Since you’re probably using several ad providers, you need an easy way to track ad performance across vendors. Creating dashboards by vendor (and setting alerts for spikes in failures) are additional ways to keep tabs on the health of your ad SDKs.

Network insights pertaining to ad SDKs.

Monitor ANRS

Ad SDKs are notorious contributors to ANRs. The data you get from Google is the stack trace at the end of an ANR rather than at the beginning. This can be misleading when attempting to understand the source of an issue. It’s why you need a stack trace from the beginning of an ANR and multiple stack traces to understand how code evolves through an issue. Even better would be to have helpful grouping and visibility of the common code paths that lead to ANRs. This data allows you to uncover problems with ad SDKs resulting in high levels of ANRs which negatively affect your app.

An Embrace flame graph.

Track crashes

Developers need data that includes the full detail of the user experience. This information is vital to see if a crash occurred while showing a user an ad or if an ad failed to load and led to a broken experience like a broken WebView. When you notice an ad SDK in one of your crash stack traces, you know where to focus developer efforts and resolve issues.

Stack trace data from a crash.

Configure error logs

Developers need to collect error logs wherever exceptions occur. This is because these logs contain valuable insight into the stability of the mobile game, including the amount of users affected by an error, the timing, and the app versions experiencing the issue. Logging for different failures in ad SDKs and configuring corresponding alerts, notifies you to issues as soon as they happen therein mitigating negative user experiences.

Error logs.

Take corrective action

There are few options you have with ad SDKs, so the more data you have backing your decisions, the better. Here are a few things to try:

  • Ask the ad vendor to fix the ad SDK. Start by providing the vendor the necessary data to show where they are at fault. This includes things like bloated startup times, their SDK’s presence in ANR stack traces, or their SDK consistently returning 400 errors. This data is more likely to spur action.
  • Keep the ad SDK. Sometimes, the vendor won’t fix your issue. In this circumstance, you must weigh the pros and cons. How much revenue is the ad vendor contributing and how many issues is it causing? What user segments or device cohorts are affected? If the impact is small enough, the right answer for your business might be to keep using the ads.
  • Stop supporting the ad SDK. When the ad SDK is causing serious issues, affecting many users, or causing poor ANR and crash rates that result in lower app store discoverability, then the right answer might be to remove the SDK and find an alternative with better performance.

An example of corrective action informed by high-fidelity data is from Wildlife. Wildlife is a top mobile gaming company based out of São Paulo, Brazil. One of their longest-running live games, Sniper 3D, posed many challenges. This game was difficult to keep below the Google ANR threshold because the game had a large number of users that could encounter errors, older and therefore complex code, and constant changes because it was updated on a routine basis.

The team investigated and found that during the game’s ANR occurrences, 60% of the time they occurred while the game was OnPause, 30% while in WebViews, and the other 10% was miscellaneous. They used Embrace’s ANR monitoring and flamegraphs to delve deeper into the OnPause issues. With this data, the team tested hypotheses and came to the conclusion that their best option was to disable ads for a subset of devices and stop supporting the game entirely for low-end devices. These devices contributed little to their overall revenue, but greatly to their decreased Play Store visibility. After testing out this hypothesis, they met the technical thresholds and received more frequent features in app stores.

Final thoughts

Ads are a vital part of many mobile games’ revenue strategy. Game teams need reliable ways to see where ad SDKs are causing poor user experiences and leaking revenue. When you’re unclear on the effect that your ad SDKs have on your mobile game, you’re putting your business at stake and leaving your app revenue to chance.

If your team frequently struggles with ad SDKs, you can get started free with Embrace, the best platform for delivering incredible mobile experiences.