Friday, March 14, 2025
HomeMobile app developmentEfficiency Class helps Google Maps ship premium experiences

Efficiency Class helps Google Maps ship premium experiences



Efficiency Class helps Google Maps ship premium experiences

Posted by Nevin Mital – Developer Relations Engineer, Android Media

The Android ecosystem incorporates a numerous vary of units, and it may be troublesome to construct experiences that benefit from new or premium {hardware} options whereas nonetheless working properly for customers on all units. With Android 12, we launched the Media Efficiency Class (MPC) normal to assist builders higher perceive a tool’s capabilities and establish high-performing units. For a refresher on what MPC is, please see our final weblog put up, Utilizing efficiency class to optimize your person expertise, or try the Efficiency Class documentation.

Earlier this yr, we printed the first secure launch of the Jetpack Core Efficiency library because the advisable resolution for extra reliably acquiring a tool’s MPC degree. Particularly, this library introduces the PlayServicesDevicePerformance class, an API that queries Google Play Companies to get probably the most up-to-date MPC degree for the present system and construct. I’ll get into the technical particulars additional down, however let’s begin by having a look at how Google Maps was in a position to tailor a function launch to finest match every system with MPC.

Efficiency Class unblocks premium expertise launch for Google Maps

Google Maps lately took benefit of the expanded system protection enabled by the Play Companies module to unblock a function launch. Google Maps wished to replace their UI by rising the transparency of some layers. Consequently, this meant they would wish to render extra of the map, and located they needed to cease the rollout on account of latency will increase on many units, particularly in the direction of the low-end. To resolve this, the Maps staff began by slicing an present key metric, “seconds to UI merchandise visibility”, by MPC degree, which revealed that whereas all units had a small improve on this latency, units with out an MPC degree had the most important improve.

A bar graph displays A/B test results for Seconds to UI item visibility, comparing control results with those using increased transparency across different Media Performance Class Levels.  A green horizontal line and text indicate the updated experience shipped to devices qualifying for MPC. A vertical green dotted line separates results for devices without a specific MPC level, which kept the previous UI.

With these leads to hand, Google Maps began their rollout once more, however this time solely launching the function on units that report an MPC degree. As units proceed to get up to date and meet the bar for MPC, the up to date Google Maps UI can be out there to them as properly.

The brand new Play Companies module

MPC degree necessities are outlined within the Android Compatibility Definition Doc (CDD), then units and Android builds are validated in opposition to these necessities by the Android Compatibility Check Suite (CTS). The Play Companies module of the Jetpack Core Efficiency library leverages these check outcomes to repeatedly replace a tool’s reported MPC degree with none extra effort in your finish. This additionally signifies that you’ll instantly have entry to the MPC degree for brand new system launches with no need to amass and check every system your self, because it already handed CTS. If the MPC degree is just not out there from Google Play Companies, the library will fall again to the MPC degree declared by the OEM as a construct fixed.

A flowchart depicts the process of determining Performance Class levels for Android devices, involving manufacturers, CTS tests, a Grader, the Play Services module, and the CDD.

As of writing, greater than 190M in-market units protecting over 500 fashions throughout 40+ manufacturers report an MPC degree. This protection will proceed to develop over time, as older units replace to newer builds, from Android 11 and up.

Utilizing the Core Efficiency library

To make use of Jetpack Core Efficiency, begin by including a dependency for the related modules in your Gradle configuration, and create an occasion of DevicePerformance. Initializing a DevicePerformance ought to solely occur as soon as in your app, as early as potential – for instance, within the onCreate() lifecycle occasion of your Utility. On this instance, we’ll use the Google Play providers implementation of DevicePerformance.

// Implementation of Jetpack Core library.
implementation("androidx.core:core-ktx:1.12.0")
// Allow APIs to question for device-reported efficiency class.
implementation("androidx.core:core-performance:1.0.0")
// Allow APIs to question Google Play Companies for efficiency class.
implementation("androidx.core:core-performance-play-services:1.0.0")

import androidx.core.efficiency.play.providers.PlayServicesDevicePerformance

class MyApplication : Utility() {
  lateinit var devicePerformance: DevicePerformance

  override enjoyable onCreate() {
    // Use a category derived from the DevicePerformance interface
    devicePerformance = PlayServicesDevicePerformance(applicationContext)
  }
}

Then, later in your app once you wish to retrieve the system’s MPC degree, you possibly can name getMediaPerformanceClass():

class MyActivity : Exercise() {
  personal lateinit var devicePerformance: DevicePerformance
  override enjoyable onCreate(savedInstanceState: Bundle?) {
    tremendous.onCreate(savedInstanceState)
    // Word: Good app structure is to make use of a dependency framework. See
    // https://developer.android.com/coaching/dependency-injection for extra
    // info.
    devicePerformance = (utility as MyApplication).devicePerformance
  }

  override enjoyable onResume() {
    tremendous.onResume()
    when {
      devicePerformance.mediaPerformanceClass >= Construct.VERSION_CODES.UPSIDE_DOWN_CAKE -> {
        // MPC degree 34 and later.
        // Present probably the most premium expertise for the very best performing units.
      }
      devicePerformance.mediaPerformanceClass == Construct.VERSION_CODES.TIRAMISU -> {
        // MPC degree 33.
        // Present a top quality expertise.
      }
      else -> {
        // MPC degree 31, 30, or undefined.
        // Take away extras to maintain expertise purposeful.
      }
    }
  }
}

Methods for utilizing Efficiency Class

MPC is meant to establish high-end units, so you possibly can count on to see MPC ranges for the highest units from annually, that are the units you’re more likely to need to have the ability to assist for the longest time. For instance, the Pixel 9 Professional launched with Android 14 and experiences an MPC degree of 34, the most recent degree definition when it launched.

It’s best to use MPC as a complement to any present System Clustering options you already use, reminiscent of querying a tool’s static specs or manually blocklisting problematic units. An space the place MPC is usually a significantly useful device is for brand new system launches. New units needs to be included at launch, so you should use MPC to gauge new units’ capabilities proper from the beginning, with no need to amass the {hardware} your self or manually check every system.

An excellent first step to get entangled is to incorporate MPC ranges in your telemetry. This can assist you establish patterns in error experiences or typically get a greater sense of the units your person base makes use of when you section key metrics by MPC degree. From there, you would possibly think about using MPC as a dimension in your experimentation pipeline, for instance by organising A/B testing teams based mostly on MPC degree, or by beginning a function rollout with the very best MPC degree and dealing your manner down. As mentioned beforehand, that is the strategy that Google Maps took.

You might additional use MPC to tune a user-facing function, for instance by adjusting the variety of concurrent video playbacks your app makes an attempt based mostly on the MPC degree’s concurrent codec ensures. Nevertheless, make certain to nonetheless question a tool’s runtime capabilities when utilizing this strategy, as they could differ relying on the atmosphere and state the system is in.

Get in contact!

If MPC sounds prefer it may very well be helpful to your app, please give it a strive! You may get began by having a look at our pattern code or documentation. We welcome you to share any questions or suggestions you might have on this quick kind.

This weblog put up is part of Digicam and Media Highlight Week. We’re offering assets – weblog posts, movies, pattern code, and extra – all designed that will help you uplevel the media experiences in your app.

To be taught extra about what Highlight Week has to supply and the way it can profit you, make sure you learn our overview weblog put up.



Supply hyperlink

RELATED ARTICLES

Most Popular

Recent Comments