Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Enable ProMotion and Set TargetFrameRate to 120hz -> Keep Crashing!

Discussion in 'iOS and tvOS' started by Thanitsak, Nov 12, 2023.

  1. Thanitsak


    Jan 4, 2016
    Hey guys! Whenever I set TargetFrameRate to 120 hz in the script, and build out to test using Xcode, it keeps crashing on my iPad Pro. Even though I already enabled "ProMotion" checkbox in the iOS Player Settings. Before the App crashed, 120hz is working like a charm on iPad Pro but not long it will crashes (randomly). Also this problem happens whenever I set the Application.targetFrameRate to 120. If removes this line, it won't crash but also my app runs at 30hz, even though the "ProMotion" checkbox is ticked.

    Unity Player Settings
    Screenshot 2566-11-12 at 9.00.50 PM.png

    This is my code
    Code (CSharp):
    1. public class FrameRateSetter : MonoBehaviour
    2.     {
    3.         //#if UNITY_IOS
    4.         private void Start()
    5.         {
    6.             if (Application.isMobilePlatform)
    7.             {
    8.                 //QualitySettings.vSyncCount = 0;
    9.                 Application.targetFrameRate = 120;
    10.             }
    11.             Debug.Log($"QualitySettings vSyncCount: {QualitySettings.vSyncCount}");
    12.             Debug.Log($"Application TargetFrameRate: {Application.targetFrameRate}");
    14.         }
    15.         //#endif
    16.     }
    Error Image from Xcode
    "Thread 1: EXC_BAD_ACCESS (code=2, address=0x16bb63ff0)"
    Error Code from Xcode.png

    I'm using Unity 2023.1.19f1 and Xcode version Version 15.0.1

    Also if what I'm doing is wrong to enable ProMotion (make app run at 120hz), please suggest me the correct way on how to do it properly, I would love to see it

    ,Thank you in advance!
  2. Alexey


    Unity Technologies

    May 10, 2010
    Yes, "enable ProMotion" just adds an info.plist string telling iOS that it should allow higher framerates if available. By default (if you dont tweak Application.targetFrameRate) you get 30 fps indeed.

    As for the crash - it is hard to tell - without proper callstack/repro project.
    Thanitsak likes this.
  3. AcidArrow


    May 20, 2010
    Use 2021LTS.
    Thanitsak likes this.
  4. Thanitsak


    Jan 4, 2016
    Appreciate your responses, @Alexey and @AcidArrow ! My bad for not catching your response earlier—I'm not regularly on this project. Added an FPS counter for debugging, and sure enough, it behaves just like you said, Alexey. -1 for targetFrameRate defaults to 30fps. Boosted it to 120Hz on iPhone, smooth sailing, but hit a snag on iPad with crashes. Took AcidArrow's suggestion, switched Unity Version from 2023.1.19f1 to 2022.3.14f1 LTS. No tweaks, and voila! No more crashes on iPad. Big thanks to you both!
    AcidArrow likes this.