Search Unity

iPadPro 2017 120hz ProMotion

Discussion in 'iOS and tvOS' started by Cascho01, Jul 24, 2017.

  1. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Rustybret likes this.
  2. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    516
    I was suppose to post the same topic, but I'm glad that I scrolled down a bit...

    It turns out that in the current iOS controller of Unity, the frame rate is being locked to 60FPS. This is due to the API limitation as before iPad Pro 10.5" there were only 60Hz-max fixed refresh rate. Per documentation of CADisplayLink, setting "frameInterval" to anything below 1 would result in undefined behavior.

    "frameInterval", however, is deprecated in iOS 11, so onwards iOS programs have to set "preferredFramesPerSecond". This API is available sine iOS 10 so you can change the iOS layer by yourself to enable this feature. But do test thoroughly because higher frame rate may cause time-critical unexpected behaviors.

    This is my attempt of doing selective API usage based off 2017.1f3. I don't have a new iPad Pro so I don't know if it works:
    Objective-C code (not C#...)
    Code (csharp):
    1. // UnityAppController+Rendering.mm : 117
    2. - (void)callbackFramerateChange:(int)targetFPS
    3. {
    4.     if (targetFPS <= 0)
    5.         targetFPS = 60;
    6.  
    7.     int animationFrameInterval = (60.0f / targetFPS);
    8.     if (animationFrameInterval < 1)
    9.         animationFrameInterval = 1;
    10.     _enableRunLoopAcceptInput = (animationFrameInterval == 1 && UnityDeviceCPUCount() > 1);
    11.  
    12.     //---------MODIFIED---------
    13.     if ([_displayLink respondsToSelector:@selector(setPreferredFramesPerSecond:)])
    14.     {
    15.         [_displayLink setPreferredFramesPerSecond:targetFPS];
    16.     }
    17.     else
    18.     {
    19.         [_displayLink setFrameInterval: animationFrameInterval];
    20.     }
    21.     //--------------------------
    22. }
    After changing the code, don't forget to add a Boolean key "CADisableMinimumFrameDuration" to the Info list of Unity-iPhone target (info.plist) and set it to "YES".

    Hope this helps.
     
    Sailendu, Lars-Steenhoff and User340 like this.
  3. figbash

    figbash

    Joined:
    May 13, 2008
    Posts:
    60
    Hi, I am using a 2017 iPad Pro running iOS 10 and the above code works great. Thank you for sharing.
     
    User340 likes this.
  4. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Confirming, the instructions from Neonlyte are spot on.
     
    Lars-Steenhoff likes this.
  5. Kubic75

    Kubic75

    Joined:
    Jan 2, 2017
    Posts:
    83
    Thank you!
    I would prefer Unity to natively support this.
     
  6. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
  7. Kubic75

    Kubic75

    Joined:
    Jan 2, 2017
    Posts:
    83
    Voted :)
     
  8. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    has this been added to later builds of Unity?
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    This needs to be logged with a case number (bug report) if it's not working for you.
     
  10. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    If you're not going to answer the question...
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    The correct answer is "file a bug report and leave the case number here." This has been the correct course of action for getting replies from Unity staff since forever. Also I am not Unity staff, just a long term Unity user and I hope, help people for free.

    If you're not interested in staff replies for bug reports you will need to wait until a member of staff visits the forum who works on this part, which usually takes a lot longer for non-beta.

    It should work. It's core device functionality. If it doesn't work then the best way to pester Unity is to bug report it, drop case numbers and use the feedback site. Hopefully someone will add it if there is demand. But as the device supports a higher refresh, it seems more like a bug to me.

    Good luck in finding a resolution, and sorry I couldn't help more.
     
  12. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    The correct answer is "no, Unity haven't gotten around to it, despite 60 requests for it, and iPad Pros having sold quite well."

    https://feedback.unity3d.com/suggestions/support-apples-promotion
     
    Last edited: Apr 14, 2018
  13. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    516
    Yes. At lease since 2017.4 the new API has been implemented. Not sure about the key as I already automated it through post build processing.
     
    Rustybret likes this.
  14. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Do you know what the API is called?
     
  15. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    It's a setting in the playerprefs.
     
    Rustybret and User340 like this.
  16. WiktorCal

    WiktorCal

    Joined:
    Mar 1, 2014
    Posts:
    4
    Your findings are very helpful! I am using Unity 2018.4.18f1 Personal and the callbackFramerateChange function is already using preferredFramesPerSecond API but the iPad Pro is still not responding to the refresh rate changes.

    If turns out that my info.plist has CADisableMinimumFrameDuration set to NO. After I change it to YES, the iPad is finally running at 120Hz!

    Thanks again.
     
    april_4_short likes this.