Search Unity

Adaptive Performance Package

Discussion in 'Android' started by David-Berger, Mar 28, 2019.

  1. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    We released Adaptive Performance and Samsung Android 2.0.0 Preview 11 today which comes with many fixes and updates to the Indexer and Scalers. Please read the changelog below for details. The installation in Adaptive Performance 2.0 is different to 1.0 due to the new provider system. Please see the quick installation guide below. Changes in Adaptive Performance 2.0:
    • Samples to show off different Adaptive Performance features.
    • Settings for Scalers
    • A number of sample Scalers
      • Adaptive Sorting
      • Adaptive Batching
      • Adaptive Shadowmap Resolution
      • Adaptive Shadow Distance
      • Adaptive Shadow Quality
      • Adaptive Shadow Cascades
      • Adaptive LOD
      • Adaptive MSAA
    • Fixes to VRR support.
    Quick Installation Guide:

    • Install Android Support for Unity. Unity needs Android Support to build to your Samsung device.
    • Switch Platform to Android in the Build Settings window.
    • Use the Unity Package Manager and install the Adaptive Performance
    • Install and activate the Adaptive Performance Samsung Android provider in Adaptive Performance Settings.
    • If you want to use the Device Simulator Extension, you also have to activate the Adaptive Performance Simulator provider in the Adaptive Performance Settings.
    Please also read the Installation Guide in the manual, which has additional details.
     
  2. yuliyF

    yuliyF

    Joined:
    Nov 15, 2012
    Posts:
    167
    Will it work on Huawei and other brands?
     
  3. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    Not at this moment with the shipped providers.
     
  4. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    We released Adaptive Performance and Samsung Android 1.1.9 and 1.2.0 today which comes with bug fixes, dependency changes and updates. Please read the changelog for details. 1.1.9 and 1.2.0 have the following fixes:
    • Automatic Performance Mode: lower CPU and GPU levels at the same time instead of one at a time to increase efficiency and higher power savings.
    • Fixed Automatic Performance Control flag to respect the function and not be read only anymore.
    • Thermal Mitigation Logic changes in GameSDK 3.2 and it was updated in SetFreqLevels() to react to the correct return values.
    • Automatic Performance Mode: gpuUtilizationThreshold increased from 0.7 to 0.9 to increase effeciency.
    • Automatic Performance Mode: gpuFactor increased from 0.72 to 0.92 to increase effeciency.
    • Automatic Performance Mode: Increase GPU Active time Ratio.
    • Changed Documentation to make clear that changing CPU and GPU levels is risky and the Automatic Performance Mode should be used instead.
    • Exchanged GameSDK wrapper with updated version removing GameSDK 3.1 support.
    • Automatic Performance Control does not lower CPU lower than 1 on GameSDK 3.2 workaround.
    • Add workaround to send temperature warning when the device starts as warm already as currently no events are sent.
    1.2.0 has the same changes as 1.1.9 but it also updates a dependency: The Subsystem Registration was updated from 1.0.6 to 1.1.0. This updates the minimum supported version to Unity 2019.4. It fixes an issue where you get compilation errors if you disable the built-in module Subsystems in your project and you install Adaptive Performance afterwards. This is an issue in Unity 2019.4+. A workaround is to enable the the Subsystem module again before installing Adaptive Performance. This means, the Support Matrix looks like:

    Unity 2018 LTS : Adaptive Performance and Samsung Android 1.1.9
    Unity 2019 LTS+: Adaptive Performance and Samsung Android 1.2.0
     
  5. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    We are happy to announce that Adaptive Performance 2.0.0 and Samsung Android 2.0.0 are now available. This verified release comes with many new features to improve your device performance. It comes with samples which can be use on the Samsung device but also in the Unity Editor in combination with the Device Simulator:
    • Samples to show off all Adaptive Performance features.
    • Editor settings for all features.
    • All features of Adaptive Performance 1.0. including Automatic Performance mode, Bottleneck and Thermal state detection.
    • Device Simulator Extension
    • A number of Scalers utilizing the Indexer
      • Adaptive Framerate
      • Adaptive VRR
      • Adaptive Resolution
      • Adaptive Sorting
      • Adaptive Batching
      • Adaptive Shadowmap Resolution
      • Adaptive Shadow Distance
      • Adaptive Shadow Quality
      • Adaptive Shadow Cascades
      • Adaptive LOD
      • Adaptive MSAA
    • Variable Refresh Rate Support.
    Quick Installation Guide:
    • Use the Unity Package Manager and install the Adaptive Performance.
    • Install and activate the Adaptive Performance Samsung Android provider in the Adaptive Performance Settings.
    • If you want to use the Device Simulator Extension, you also have to activate the Adaptive Performance Simulator provider in the Adaptive Performance Settings and install the Device Simulator Package.
    • Install Android Support for Unity. Unity needs Android Support to build to your Samsung device.
    • Switch Platform to Android in the Build Settings window.
    Please also read the Installation Guide in the manual, which has additional details.

    For additional information and upgrade guides, please see the first post.
     
  6. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
  7. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    We released Adaptive Performance and Samsung Android 2.0.2 today which comes with bug fixes when you use Unity < 2020.2. Please read the change log linked above for details.

    We also release Samsung Android 1.2.1 today which replaces a broken 1.2.0 - please upgrade to Samsung Android 1.2.1 if you use 1.2.0. In case you use Unity 2018, please stay/downgrade to 1.1.9.
     
  8. mk0a1a

    mk0a1a

    Joined:
    Nov 24, 2018
    Posts:
    24
    Hello, I'd like to ask if there is any progress on a generic Android provider for Adaptive Performance? I'd like to know if work has already started on it. This package is pretty great but for it to work only with the latest Samsung devices makes it very limiting. Can we expect it soon? Maybe in 2021 or something? An ETA would be greatly appreciated.

    Also, I know this is in the Android subforum but can we expect this for other platforms? Like on Windows, iOS, etc.
     
  9. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    There is additional APIs in Android 11 which we evaluate at the moment. Most Thermal APIs, required for Adaptive Performance, are still missing on Android and iOS. We monitor the APIs closely and hopefully will be able to support more platforms in future. For now, if you use Adaptive Performance, it should be easy to adapt it for other platforms once they are available.
     
    mk0a1a likes this.
  10. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    125
    It might be helpful if you need to check device thermal state: iOS / Android
     
    Thermos and David-Berger like this.
  11. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
  12. caletbak-sp

    caletbak-sp

    Joined:
    Dec 11, 2018
    Posts:
    6
    Hi!,

    I think this is a very nice feature to have in every game. I would like to know if there is any intention or you know if this will be available for iOS platform at anytime soon? Also for other Android device manufacturers.

    Thanks!
     
  13. kmedved

    kmedved

    Joined:
    Aug 18, 2016
    Posts:
    125
    Hi! You can use this asset for Android and iOS devices
     
  14. caletbak-sp

    caletbak-sp

    Joined:
    Dec 11, 2018
    Posts:
    6
    I have seen this asset previously, thanks. But this is only for receiving thermal events. The most interesting thing about AP is changing the CPU and GPU levels where needed and play with them.
     
  15. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    We are researching possible extensions, but for now it's not available. However, you always can create a custom provider easily if you find yourself on platforms which have similar APIs available already.
     
  16. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,023
    I love the idea of this, but how many people actually use this package ? It seems like way too much work for most Indies to incorporate a plugin that only targets a subset of a subset of their user base. Unless this works out of the box across iOS and Android, surely the adoption rate will be low?
     
    apkdev and Noisecrime like this.
  17. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    We are bound by API availability with the extension to other systems unfortunately. The good thing is that with Samsung you have million devices covered, as it's a pretty big part of the Android ecosystem and, once you implement it successfully, it will work out of the box for any other platform once it is available.
     
    AshwinTheGammer likes this.
  18. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    AshwinTheGammer likes this.
  19. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    AshwinTheGammer likes this.
  20. MassiveTchnologies

    MassiveTchnologies

    Joined:
    Jul 5, 2016
    Posts:
    79
    apkdev, Prodigga and SenseEater like this.
  21. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,023
    Yeah that's a little confusing. When you say "bound by API availablity", what exact does that mean?

    There is also this for all other android devices, right?:
    https://developer.android.com/ndk/reference/group/thermal

    So why can't this "just work" everywhere?

    I imagine most people will just roll their own solution that can work everywhere to some extent if they are willing to put in the work to add granularity to their game quality.
     
    SenseEater likes this.
  22. SenseEater

    SenseEater

    Joined:
    Nov 28, 2014
    Posts:
    82
    I think this has been mentioned in a post. The shared APIs are just thermal events whereas AP package also requires APIs to explicitly also change GPU/CPU clock level of device if i am not wrong.
     
    MassiveTchnologies likes this.
  23. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,023
    Right I see. I guess they don't want to "officially" support platforms that don't offer the entire feature set they require? After I posted I had a quick look at the scripting API for Unity's adaptive performance package and it seems there is a way to specify what sort of features are available.

    https://docs.unity3d.com/Packages/c...ine.AdaptivePerformance.Provider.Feature.html

    If all you have is thermal information, you can specify that. It would be great if the other platforms were supported by the official package even at this basic level? If there is a larger adoption of this feature and it proves useful then that might put pressure on other manufacturers to provide the missing APIs?
     
    kou-yeung and MassiveTchnologies like this.
  24. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    Thermal Info is a great API, and we'd love to support it on more platforms and using the Provider.Feature is exactly what will be used for it. (Alternatively you can already use it if you implement the provider yourself) We gonna add some more Provider.Feature helper function to make it more useful during runtime in the next release.

    The current APIs for thermal are less precise then what we use on Android/Samsung devices. The good news is that with Android 11 the thermal headroom API provides us with more details we can use to generate a thermal trend picture to service the basic functionality of AP.

    Thanks for your feedback, really appreciate it. Stay tuned for more updates soon!
     
    apkdev and Prodigga like this.
  25. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    We released Adaptive Performance and Samsung Android 3.0.0-prev.2 which comes with several new features. It comes as verified package release candidates in 2021.2.0a19 but minimum requires version is 2021.2.0a18.

    New in 3.0 (3.0+ only)
    • Minimum Support Unity 2021.2
    • Startup Boost mode - Enables boost mode during engine startup.
    • Profiler Integration - Profile Adaptive Performance easily from the Unity Profiler.
    New in 3.0 (also coming to 2.2)
    • Scaler profiles - Easily define and change Adaptive Performance Scalers with predefined profiles.
    • Boost mode - Boost CPU and GPU for short periods of time.
    • Cluster info - Request cluster info to have details which and how many cores are available on the device.
    • Feature API - Check which Adaptive Performance feature is available on the current platform.
    • Adaptive view distance scaler - A new scaler to change the Camer.main view distance automatically.
    • Additional samples
    Boost mode, Startup Boost mode and Cluster info API require GameSDK 3.5 which is not released at this point, but you can use the Device Simulator Extension to simulate the features. We will keep you posted when GameSDK 3.5 is going to be publicly available on Samsung Phones. This is a release which comes with many new feature and we would love to hear feedback. Some features require a breaking upgrade, so please ensure your project is backed up properly!
     
    MateiGiurgiu and MartinTilo like this.
  26. Guillogika

    Guillogika

    Joined:
    Sep 18, 2017
    Posts:
    13
    Hello there!

    I have been playing a bit with Adaptive Performance 2.1.1 with Unity 2020.3.2f1 and it seems very promising. It's actually quite easy to set up and the scaler system is great.

    Everything behaves correctly in the editor with the simulator (I see the "AdaptivePerformanceManager" game object created and I see the impact of my modifying the scalers in realtime). However even though I have installed and activated the Samsung Android Provider for Android I get this log at the start with my Samsung devices: "Unable to start the Samsung Android subsystem". The devices are recent (Galaxy S9, S21, with Android 10 and 11), do you know what may be causing this?
     
  27. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    Hi Guillogika,

    Can you verify that both checkmarks (Samsung Android Provider as well as Initialize Adaptive Performance on Startup) are ticked in the Android Provider Settings?

    Capture.PNG
     
  28. Guillogika

    Guillogika

    Joined:
    Sep 18, 2017
    Posts:
    13
    Hi David-Berger, yes both checkmarks are ticked
     
  29. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    Can you try the following test.apk and see if you get the output below in logcat?

    Code (CSharp):
    1. [Adaptive Performance] Subsystem version=3.3
    3.3 or higher, otherwise it is a possibility that game SDK installed on the device is not supported. If there is a device update available I'd recommend to install that.
     
  30. Guillogika

    Guillogika

    Joined:
    Sep 18, 2017
    Posts:
    13
    Thank you for taking the time to help me and sorry for my late reply. These are the logs that we see with this apk. The last Android update on this device was made two days ago.

     
  31. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    This looks like the phone does not have Samsung GameSDK 3.3+ installed which is required for AP 2.x. Is this the same message with the up to date S21?
     
  32. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    We released Adaptive Performance and Samsung Android 2.2.1 which comes with several new features (backported from 3.0.0 where possible). It comes as verified package in 2020.x+ but also works with 2019.

    New in 2.2
    • Scaler profiles - Easily define and change Adaptive Performance Scalers with predefined profiles.
    • Boost mode - Boost CPU and GPU for short periods of time.
    • Cluster info - Request cluster info to have details which and how many cores are available on the device.
    • Feature API - Check which Adaptive Performance feature is available on the current platform.
    • Adaptive view distance scaler - A new scaler to change the Camera.main view distance automatically.
    • Additional samples
    Boost mode, Startup Boost mode and Cluster info API require GameSDK 3.5 which is not released at this point, but you can use the Device Simulator Extension to simulate the features. We will keep you posted when GameSDK 3.5 is going to be publicly available on Samsung Phones. This is a release which comes with many new feature and we would love to hear feedback. Some features require a breaking upgrade, so please ensure your project is backed up properly!
     
    Fodges likes this.
  33. Guillogika

    Guillogika

    Joined:
    Sep 18, 2017
    Posts:
    13
    It is very strange, on the S21 your test apk works and shows that the phone has the GameSDK 3.4
    upload_2021-8-30_12-58-32.png

    However in our app on the same device this is what happens:
    upload_2021-8-30_12-59-5.png

    Even though the settings are like you mentioned before:
    upload_2021-8-30_13-54-38.png

    Note: if you prefer that we have this discussion in another thread let me know, I wouldn't want to spoil your package update's information thread.
     
  34. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    I'm sorry that this is happening. I do not have a good explanation at this point.
    This forum is fine, once we found a solution it hopefully will help anyone running into similar issues.

    The log indicates that it's running GameSDK 3.4 on the device and it would be available to use.
    As we ruled out the GameSDK version, the other way for the message to appear is if GameSDK can not be initialized correctly.
    Can you provide the full logcat log from application start?
    Also, the apk was made with 2.2.1 - which has a newer GameSDK wrapper. Can you upgrade to 2.2.1?
     
  35. Guillogika

    Guillogika

    Joined:
    Sep 18, 2017
    Posts:
    13
    I have updated the packages to 2.2.1 and still no luck on the S21. Full logs attached
     

    Attached Files:

    Last edited: Sep 1, 2021
  36. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    That looks normal - except it should initialize properly if the test apk worked. Could you include the full logcat (not limited to Unity logs only) as there should be some additional info. You can also send a private message with the log if needed - or email to db@unity.com and I can have a closer look at the init process. Also please restart the device to ensure the startup process is clear.
     
    Guillogika likes this.
  37. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    The issue above is not easy to debug and we will add additional logging to Adaptive Performance in future. If you are stuck on a older version and wonder what's wrong, you can add some more logs into the SamsungGameSDKAdaptivePerformanceSubsystem.cs found in Adaptive Performance Samsung Android package under Runtime/Provider.

    Instead of the current RegisterDescriptor() you can add following:

    Code (CSharp):
    1.         static void RegisterDescriptor()
    2.         {
    3.             if (!SystemInfo.deviceModel.StartsWith("samsung", StringComparison.OrdinalIgnoreCase))
    4.             {
    5.                 GameSDKLog.Debug($"The device {SystemInfo.deviceModel} is not a supported Samsung phone. This provider will not run. Aborting registering the Adaptive Performance provider descriptor.");
    6.                 return;
    7.             }
    8.  
    9.             if (!NativeApi.IsAvailable())
    10.             {
    11.                 GameSDKLog.Debug($"The native API for this provider is not available. Aborting registering the Adaptive Performance provider descriptor.");
    12.                 return;
    13.             }
    14.  
    15.             AdaptivePerformanceSubsystemDescriptor.RegisterDescriptor(new AdaptivePerformanceSubsystemDescriptor.Cinfo
    16.             {
    17.                 id = "SamsungGameSDK",
    18.                 subsystemImplementationType = typeof(SamsungGameSDKAdaptivePerformanceSubsystem)
    19.             });
    20.         }
    and instead of StaticInit() please add:

    Code (CSharp):
    1.             static private void StaticInit()
    2.             {
    3.                 if (s_GameSDK == null)
    4.                 {
    5.                     try
    6.                     {
    7.                         s_GameSDK = new AndroidJavaObject("com.samsung.android.gamesdk.GameSDKManager");
    8.                         if (s_GameSDK != null)
    9.                             s_isAvailable = s_GameSDK.CallStatic<bool>("isAvailable");
    10.                     }
    11.                     catch (Exception ex)
    12.                     {
    13.                         GameSDKLog.Debug($"GameSDK is not available due to {ex} Aborting Adaptive Performance initialization.");
    14.                         s_isAvailable = false;
    15.                         s_GameSDK = null;
    16.                     }
    17.  
    18.                     if (s_isAvailable)
    19.                     {
    20.                         s_GameSDKRawObjectID = s_GameSDK.GetRawObject();
    21.                         var classID = s_GameSDK.GetRawClass();
    22.  
    23.                         s_GetGpuFrameTimeID = GetJavaMethodID(classID, "getGpuFrameTime", "()D");
    24.                         s_GetHighPrecisionSkinTempLevelID = GetJavaMethodID(classID, "getHighPrecisionSkinTempLevel", "()D");
    25.  
    26.                         if (s_GetGpuFrameTimeID == (IntPtr)0 || s_GetHighPrecisionSkinTempLevelID == (IntPtr)0)
    27.                             s_isAvailable = false;
    28.                     }
    29.                 }
    30.             }
    Note: You will have to make a local copy of the package in the Project/Package folder to be able to save changes. To see the logs you will need to enable the Samsung Provider Logging in the AP Settings and run the app in development mode to get the logs.
     
  38. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    705
    If you face a situation and get errors like: Unable to start the Samsung Android subsystem. The log above might give you a better insight what's wrong.

    If you receive a log like [Samsung GameSDK] GameSDK is not available due to UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.samsung.android.gamesdk.GameSDKManager it might mean the GameSDKManager was removed from your final binary. This can happen due to minify or ProGuard. You can check the Player Settings if they are activated for the project. Note: Those settings can be overridden if you use a custom Gradle Project.

    proguard.PNG

    In some cases it helps to add a custom proguard-user.txt file in Assets/Plugins/Android with the following content:

    -keep class com.samsung.android.gamesdk.** { *; }
    -keepclassmembers class com.samsung.android.gamesdk.** { *; }

    This tell Proguard to keep the files and not minify or optimize them. You can verify your settings if you export your project and open it in Android Studio. This should also help if a 3rd party plugin overrides your settings and still strips the classes.

    androidproj.PNG

    While unfortunately it did not solve Guillogikas issues I hope this helps others to narrow down the problem.
     
    Guillogika likes this.
unityunity