Search Unity

Mac M1 stuck at 60 FPS ?

Discussion in 'macOS' started by Deleted User, Aug 31, 2021.

  1. Deleted User

    Deleted User

    Guest

    Running 2021.2.0b7 on MacMini M1 (Metal) I can't get pass the 60 fps with a blank scene.
    Does anyone experience this too ?
     
  2. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    Vsync on?
     
    JoeStrout likes this.
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Deleted User likes this.
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,678
    M1 MacMini's don't support disabling VSync at this point in time, so the max frame rate you're going to get is the refresh rate of your monitor.
     
  5. Deleted User

    Deleted User

    Guest

    Oh thanks absolutely ignored that; do you by chance have any link to a technical reference for this ? Will this be eventually fixed in the future; Apple or Unity side ?

    Thanks
     
  6. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    The m1 seems to support higher resfresh rates if the monitor also supports it.
    For example here is a site that says it supports 4k at 120 hz.

    https://tonsky.me/blog/monitors-mac/
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,678
    Apologies. This will sound weird, but it seems I was partially wrong.

    M1 Macs indeed don't support disabling VSync (in a sense that disabling it would cause tearing), but it should not cap the frame rate. When I was bringing up Apple silicon support a year ago, I saw the exact same thing you're seeing: the FPS being capped at 60. When I asked Apple, they told me disabling VSync is not supported so I just moved on.

    I just tested it again and in both 2020.3 using Rosetta editor, native player, and 2021.2 native editor and native player I can observe that disabling VSync allows me to go above 60 FPS, which is totally opposite of what I remember. Now I'm wondering if we have a bug somewhere that causes it to happen sometimes.

    By the way, all my tests were done using a MacMini with a 4k monitor connected to it via HDMI.

    What macOS version are you running on your MacMini?
     
    Deleted User and AcidArrow like this.
  8. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    HDMI cables aren't all capable of equal bandwidth so that will be a factor to consider.
     
    Lars-Steenhoff likes this.
  9. Deleted User

    Deleted User

    Guest

    That's interesting; never heard of a cable limiting bandwidth. I also have a PC connected to those monitors and switch between with hdmi switcher (also tried connecting directly) I get way above 60 which is expected.

    You disable VSync on 2021.2b9 and it goes beyond 60 ? Crazy, I see that if I have the scene and game view showing in the same screen I drop to 30 fps. I remember seeing this in a bug report that was confirmed, so ... this is a regression ?

    MacMini M1 16Gb running 11.5.2. I will try 2020.3 with Rosetta again but I remember not being able to go beyond 15-20fps builtingRP.

    And finally (if it helps), starting a blank project with the sample URP template I get 60fps (with or without sync) and then crashes as well after 20-30 seconds.
    Tried both 2021.2.0b7 and 2021.2.0b9 same result.
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,678
    It seems that disabling vsync doesn't totally unlock frame rate. For me it gets stuck at 100-110 FPS when the monitor is set to 60 Hz and 50-55 FPS when the monitor is set to 30 Hz. I profiled a bit and it seems like macOS throttles frame rate in form of blocking when acquiring "metal drawables" even when VSync is disabled, but the frame rate limit is higher than the monitor refresh rate.

    I don't think the cable quality has anything to do with it unless your monitor is stuck at 30 Hz for whatever reason.

    Yes:
    upload_2021-9-1_13-56-52.png

    I can actually reproduce this too:

    upload_2021-9-1_13-57-20.png

    It almost sounds like the scene view and game view are drawn in sequence (game view -> scene view -> game view) instead of in parallel, so we are getting hit by the same macOS limit. If you have a bug number, I can look up its status for you.


    I believe this is because URP template is using CPU lightmapper, which is non-functional on the apple silicon editor. I saw a fix go out that forces GPU lightmapper regardless of what it says in the project settings. I'm not sure whether it landed yet. A good manual workaround would be switch to the GPU lightmapper in the lighting settings before the editor crashes.
     
    ilmario likes this.
  11. Deleted User

    Deleted User

    Guest

    Thanks for the explanation. My screen reports 4k60fps. I confirm I get maximum 60fps no matter what.

    Here's the link to the issue: https://issuetracker.unity3d.com/is...s-scene-view-and-game-view-open-in-the-editor

    URP works as expected with your workaround it's magic ! I will give it a try.
    Well there's still this burst error InvalidOperationException: Burst failed to compile the function pointer `Int32 DoGetCSRTrampoline()` but I think it's nothing we can do about it.

    I'm interested in the follow up on this. Let me know if you want me to try things.

    Thanks !

    Capture d’écran 2021-09-02 à 10.25.17.png
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,678
    You can! Update the burst package. 1.6.0 just shipped with full apple silicon editor support.
     
    Deleted User likes this.
  13. Deleted User

    Deleted User

    Guest

    I almost fainted when I read this. Went ahead but still some errors. I guess have to wait for the next beta to incorporate this release.

    Code (CSharp):
    1. InvalidOperationException: Burst failed to compile the function pointer `Void _mono_to_burst_Hash64Long(Byte*, Byte*, Int64, Byte*, UInt64 ByRef)`
    2. Unity.Burst.BurstCompiler.Compile (System.Object delegateObj, System.Reflection.MethodInfo methodInfo, System.Boolean isFunctionPointer, System.Object managedFallbackDelegateObj) (at Library/PackageCache/com.unity.burst@1.6.0/Runtime/BurstCompiler.cs:349)
    3. Unity.Burst.BurstCompiler.Compile (System.Object delegateObj, System.Boolean isFunctionPointer) (at Library/PackageCache/com.unity.burst@1.6.0/Runtime/BurstCompiler.cs:235)
    4. Unity.Burst.BurstCompiler.CompileFunctionPointer[T] (T delegateMethod) (at Library/PackageCache/com.unity.burst@1.6.0/Runtime/BurstCompiler.cs:216)
    5. Unity.Collections.xxHash3..cctor () (at Library/PackageCache/com.unity.collections@0.15.0-preview.21/Unity.Collections/xxHash3.cs:229)
    6. Rethrow as TypeInitializationException: The type initializer for 'Unity.Collections.xxHash3' threw an exception.
    7. System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate (System.Delegate d) (at <76cf9df0db0d4d0ca5e0b61b6e332823>:0)
    8. Unity.Burst.BurstCompiler.Compile (System.Object delegateObj, System.Reflection.MethodInfo methodInfo, System.Boolean isFunctionPointer, System.Object managedFallbackDelegateObj) (at Library/PackageCache/com.unity.burst@1.6.0/Runtime/BurstCompiler.cs:291)
    9. Unity.Burst.BurstCompiler.CompileILPPMethod (System.RuntimeMethodHandle burstMethodHandle, System.RuntimeMethodHandle managedMethodHandle, System.RuntimeTypeHandle delegateTypeHandle) (at Library/PackageCache/com.unity.burst@1.6.0/Runtime/BurstCompiler.cs:168)
    10. Unity.Collections.xxHash3+_mono_to_burst_Hash128Long_00000A46$BurstDirectCall.Constructor () (at <f2a8e5185d2542738539d81d01ff7875>:0)
    11. Unity.Collections.xxHash3+_mono_to_burst_Hash128Long_00000A46$BurstDirectCall..cctor () (at <f2a8e5185d2542738539d81d01ff7875>:0)
    12. Rethrow as TypeInitializationException: The type initializer for 'Unity.Collections._mono_to_burst_Hash128Long_00000A46$BurstDirectCall' threw an exception.
     
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,678
    Do you mind posting about this on https://forum.unity.com/forums/burst.629/? I don't think it's expected.
     
    Deleted User likes this.
  15. Deleted User

    Deleted User

    Guest