Search Unity

We recently wrapped up GDC 2019, where we spoke about Adaptive Performance during our Keynote. We’re excited to let you know that the Preview version and the Megacity mobile sample are now available so you can get started exploring this feature. This blog explains more about Adaptive Performance and how to apply it to your own projects.

Unlike for a PC or console game, harnessing the full power of mobile hardware requires a delicate balance for games to look beautiful and play smoothly. Maxing out a device’s capabilities can quickly compromise your game’s performance by overtaxing the hardware, which leads to throttling, poor battery life, and inconsistent performance. For developers, this issue becomes even more problematic considering the wide range of low-end to high-end target devices.

Today, developers take different tactics to solve this problem. The two main approaches we’ve seen are: trying to make sure games perform at their best on all target hardware, which means sacrificing graphics fidelity and frame rate, or attempting to anticipate hardware behavior, which is really difficult because there are not many options to precisely measure hardware trends.

How Adaptive Performance works

Adaptive Performance provides you with a better way to manage thermals and performance of your games on a device in real time, allowing you to proactively adjust on-the-fly performance and quality settings of your game and utilizing the hardware without overtaxing the device. The result is a predictable frame rate and a decrease in thermal buildup, enabling longer play times and a much more enjoyable player experience while preserving battery life.

For developers, it means having a new, deeper insight into hardware with new tools to make your games more dynamic and flexible, providing your players with the smoothest and best-performing experiences when they’re playing on mobile devices. It gives you control over decisions that usually the operating system makes, such as when to run at high clock speeds or what to adjust to avoid throttling.

We gave several talks about this feature during GDC 2019. You can view the slide deck here and watch the Unity GDC Booth Talk – Megacity on mobile: How we optimized it with Adaptive Performance below.

 

Partnering with Samsung on Adaptive Performance

We’ve partnered with Samsung, the world’s largest Android mobile device manufacturer, to help bring this solution to fruition. Built on top of Samsung’s GameSDK, Adaptive Performance will first be available for Samsung Galaxy devices such as the Samsung Galaxy S10 and Galaxy Fold, followed by additional Samsung Galaxy devices later this year.

Early results

These charts (shown during our Unity at GDC 2019 keynote) illustrate how Adaptive Performance helps deliver a steady high frame rate with Megacity running on the new Samsung Galaxy S10.

In red, you can see the frame rate in Megacity before we added Adaptive Performance; and in blue, you can see the results after we added Adaptive Performance. With Adaptive Performance, the demo runs at 30 fps for a much longer time and is much more stable.

Why Megacity?

Megacity is a futuristic, interactive city featuring millions of entities, demonstrating how Unity can run even the most complex projects on current-gen mobile hardware. It showcases the latest advances in our Data-Oriented Technology Stack (DOTS), the name for all projects under our “Performance by Default” banner, including Entity Component System (ECS), Native Collections, C# Job System, and the Burst Compiler. Megacity was first presented at Unite Los Angeles 2018 and was released for desktop during GDC 2019.

Megacity is the right project to demonstrate a sample implementation of Adaptive Performance, as it provides us with the flexibility to adapt the game dynamically and proactively to best utilize the hardware. Adaptive Performance was built with scalability in mind, which works great with the principles of DOTS used to build the foundation in Megacity.

The mobile version of the project has 4.5M mesh renderers, 200K building components, 100K audio sources, and more than 6M entities – an ideal candidate for demonstrating Adaptive Performance’s capabilities.

How Adaptive Performance works (in Megacity)

After you install Adaptive Performance via the Unity Package Manager, Unity automatically adds the Samsung GameSDK subsystem to your project when you build to a device. During runtime, Unity creates and starts an Adaptive Performance Manager on supported devices, which provides you with feedback about the thermal state of the mobile device. You can subscribe to events or query the information from the Adaptive Performance Manager during runtime to react in real-time; otherwise, it will only report the stats to the console.

As an example, you can use the API provided to create applications that react to the thermal trends and events on the device. This ensures constant frame rates over a longer period of time while avoiding thermal throttling, even before throttling begins. In the sample implementation of Adaptive Performance in Megacity, we used three different ways to smooth the frame rate:

  • By starting at moderate CPU and GPU levels, and increasing them gradually to eliminate bottlenecks, we were able to keep energy consumption low.
  • If we saw that the device was getting close to throttling, we could tune quality settings to reduce thermal load – and we decided to lower the LOD levels.
  • We also decreased the target frame rate once we were close to throttling.
  • When the target frame rate is reached and temperature is in decline, we increase LOD levels, raise target frame rate, and decrease CPU and GPU levels again.

These capabilities enable your game to achieve a smoother performance over time. By keeping a close eye on a device’s thermal trends, you can adjust performance settings on the fly to avoid throttling altogether.

Download the Megacity mobile sample project here, to see how we’ve done this. For feedback or questions about Megacity, please visit this forum thread.

Adaptive Performance Manager

The heart of the package is the Adaptive Performance Manager, which Unity creates during startup, allowing you to access and subscribe for thermal and performance event notifications easily. The example below shows how to access the Adaptive Performance Manager using the IAdaptivePerformance interface in the Start function of your MonoBehaviour.

Thermal events

Unity sends thermal events whenever there are changes in the thermal state of the device. The important states are when throttling is imminent and when throttling is occurring. In the example below, you subscribe to ThermalEvents to reduce or increase your lodBias, which helps to reduce GPU load.

Note that if you reduce the lodBias below a value of 1, it will have a visual impact in many cases and LOD object-popping might occur, but it is an easy way to reduce graphics load if it is not required for the game experience. In case you want to make even more detailed decisions to fine-tune how your game’s graphics and behavior are handled, the bottleneck events are very useful.

CPU and GPU performance levels

The CPU and GPU of a mobile device make up a very large part of its power utilization, especially when running a game. Typically, the operating system decides which clock speeds are used for the CPU and GPU.

CPU cores and GPUs are less efficient when running at their maximum clock speed. Running at high clock speeds overheats the mobile device easily and the operating system throttles the frequency of the CPU and GPU to cool down the device.

You can avoid this situation by limiting the maximum-allowed clock speeds with these properties:

  • IAdaptivePerformance.cpuLevel

  • IAdaptivePerformance.gpuLevel

The application can configure those properties based on its special knowledge about the current performance requirements and decide, based on the scenario, if the levels should be lowered or raised.

  • Did the application reach the target frame rate in the previous frames?

  • Is the application in an in-game scene or in a menu?

  • Is a heavy scene coming up next?

  • Is an upcoming event CPU or GPU heavy?

  • Will you show ads that do not require high CPU/GPU levels?

An early-warning system for performance bottlenecks

In the Adaptive Performance Manager, you can subscribe to receive performance bottleneck events that let you know if you are GPU, CPU, or “frame-rate bound.” Frame-rate bound means that the game is limited by Application.targetFrameRate, in which case the application should consider lowering its performance requirements.

Running in the background governing bottleneck decisions – and queryable via the Manager – is the GPU frametime driver, which monitors the hardware time the GPU spent on the last frame; for the moment, the CPU time is calculated by summing Unity’s internal subsystems. Depending on the game and scenario, you can have it react differently when the game is CPU or GPU bound according to thermal state changes.

There are many different ways to optimize games, and the samples above and in Megacity only provide some suggestions for how to do it; ultimately, it depends very much on what works best for your game. For more information, please also check the package documentation.

What’s next for Adaptive Performance

This is only the beginning! We are going to continue to invest in Adaptive Performance, adding more features and supporting more devices over time. The current package includes a low-level API, but we are already working on a high-level, component-based API compatible with DOTS, which should make it even easier to adapt performance in your Unity projects. Stay tuned for more information.

Get started today

A Preview version of Adaptive Performance is available now for Unity 2019.1 (beta) via the Unity Package Manager. You can access it here. For up-to-date information on Adaptive Performance, to see how other developers are using it, and to post questions or comments, please visit the forum.

Ya no se aceptan más comentarios.

  1. While this is predominantely a mobile concern, I think it is something you should be looking at in the PC world as well. Thermals play a huge role in the performance of gaming laptops thin and otherwise, as well as tablets.

  2. This is some kind of click bait «better performance» «we use a samsung s10» xD what´s the point of this if is only for high-end devices and a specific samsung device, developers want better performance on low-end devices, not in a powerful phone that only a few portion of the market will have. What´s next? «we have an incredible performance on PC, the optimization is the best ever done, your games can run smoothly at 60 fps, 8k resolution, this new feature only works in nvidia RTX» xD

  3. It’s a welcome addition, but it’s a shame that it’s coming to the extremely highend devices first – the devices that need it the least.

  4. I get an error when i click the link to download the Megacity pack

    1. Hey Anthony,
      is there an error message? What browser are you using?

  5. Stefan Hollekamp

    abril 2, 2019 a las 8:46 am

    is it limited to Android only?
    what’s about iOS and Metal ?
    also like some mention before…
    this would be great for all Platforms Unity supports…
    thx

    1. Hi Stefan,
      the preview package currently supports Galaxy S10 devices at this moment, more to follow. iOS is not supported.

  6. This is pretty neat. I hope it expands to other devices pretty quick, but I especially hope it expands to PC one day because that would be a real game changer. I understand the problems with getting that to work, especially for Windows Store releases, but I can dream.

    1. Hey Liz,
      thanks for your feedback. On Desktop it’s more common to have Settings Menus to offer more control to the user, so it’s gonna be an interesting task to offer the right functionality.

      1. I’m aware of that, but at the same time it’s important to understand that not all users are technically minded. One of the reasons things like GeForce Experience have systems in place to apply settings is because many users simply run at default, which is a less than ideal experience.

    2. Monitoring frames and adjusting quality settings/LODbias would not be hard to implement yourself on PC.

  7. I was excited about the APM at first, but am disappointed that you chose to build it «on top of Samsung’s GameSDK». Instead of making devs’ lives easier, you add another level of hardware dependency on a platform that is already riddled with fragmentation issues.

    Any dev who who is serious about adaptive performance must put effort in the design and implementation of issues such as reducing scene complexity, switching out materials or even switching functionality on and off. No one wants to build that and then discover that the whole system only works on «supported devices». So why not choose a more general approach? (At a minimum, tracking FPS is possible on any device and could be used as a fallback on those that don’t provide thermal information. And there are other measures that could be used as heuristics, like framerate consistency.)

    1. Thanks for your feedback Wendelin,
      as mentioned in the blog post, this project is just at the very beginning of our work on Adaptive Performance and there is much more to come over the upcoming years. Using the Samsung GameSDK gives us the flexibility to implement and create an APIs for Unity which can deal with any underlying data provider and enables us to design functionality and APIs across platforms which are not available otherwise. As an example, it is not trivial nor reliable across platforms to use FPS as an indicator of throttling state, while it’s impossible to preemptive take actions as the framerate might not change leading up to throttling on every device. With Adaptive Performance, you get the thermal trend and events e.g. for throttling imminent states, which requires platform-specific hooks as those depend on OEM specific implementations and are not exposed on most OS.

      Having a fallback scenario is important and part of the future R&D as it should be reliable across platforms. We have many more things planned so please stay tuned.

      1. What about iOS? (they have an API for that: https://developer.apple.com/documentation/foundation/nsprocessinfo/1417480-thermalstate?language=objc)

        It’s nice to have such an API for Samsung devices, however I think iOS would make a lot of sense, as it is a single API for a broad range of devices, while in case of Samsung it’s just a fraction of the Android landscape.

        1. Thank you for the reference Patrick. Currently, iOS is not supported. However, as mentioned in the blog post, this is a first peek into what our vision is. Also, the Adaptive Performance package is open source, and extending it with a new provider is possible. One of the great things the Samsung GameSDK offers, is the functionality, such as temperature trends and setting CPU and GPU levels to save power. Those calls have minimal impact on the runtime performance which makes an easy integration possible.

      2. Hey David. Do you have any idea of when this will be available for iOS? (near future, not even started working on it yet, 2019, 2020, next month… :) ) It would be a huge improvement to the project I’m currently working on now.

        1. In iOS 11+, there is a thermal event API available on iOS, but no temperature (trends) or control over CPU/GPU, so those features would be missing if we offer the packages on iOS at this moment, but if you’d like to use it on Samsung, you can do that now and easily extend it with an additional provider providing data from other sources if you like.

    2. Agreed.

      My response was basically «That looks neat. Maybe I’ll use it in 1 or 2 years after the Samsung exclusivity period ends, but only if it works on most of Android and iOS devices»

  8. Alejandro Castan

    abril 1, 2019 a las 3:08 pm

    Hi. Great Job Unity I am very interested in using Adaptive Performance for VR projects, for it, Is it VR Ready? Thanks

    1. Thank you, Alejandro,
      The current preview targets Samsung Galaxy devices and is optimized for the Samsung S10 with more devices of the Samsung Galaxy family to follow. Our goal is to enable as many devices as possible to use Adaptive Performance in the future. The package is open source and you can take a look at the implementation at any time.

  9. Happy AFD Unity!
    Good job!

    It barely to run and compile that megacity project on any pc.

    1. The Megacity sample implementation of Adaptive Performance uses a different Render Pipeline and settings optimized for the Samsung S10. You might wanna give it a go as it is different than the Desktop version. If you have issues building it on your machine please make sure to let us know the specs of your development machine in our Megacity thread (https://forum.unity.com/threads/megacity-feedback-discussion.647248/ ) and the issues you are seeing.