Search Unity

Advanced FPS Counter [RELEASED]

Discussion in 'Assets and Asset Store' started by codestage, Feb 12, 2014.

  1. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    @kaz2057 it's not a real conflict actually, it's just a matter of correct settings. But I'll add another check and warning to the editor code to make sure customers are aware of it.
     
  2. Binary42

    Binary42

    Joined:
    Aug 15, 2013
    Posts:
    207
    Hi, thanks for that nice counter! It would be nice if you can add some Garbage Collection Stats. For ex. seconds since it ran last time, how long it ran, mean time it is called and total number of collections.
    .
     
  3. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, Binary42!
    I'm not sure it fully possible to implement (unless you're calling GC manually and wish to profile such calls), but I'll take a look, added to my TODO, thanks.
     
  4. dog_funtom

    dog_funtom

    Joined:
    Nov 16, 2013
    Posts:
    9
    Hi. I just find out that Mono memory counter is always constantly growing, even on your example scene. I want to use a Mono memory counter to detect leaks, because I'm actively experimenting with avoiding deallocations. But having its own leak, makes it's kinda useless.
     
  5. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @dog_funtom!
    It relies on the GC.GetTotalMemory(false) under the hood which is usually growing even in empty project. So it's an expected behaviour it will grow for some time until GC hits. So to look up for some leaks I'd suggest to track the maximum value of the Mono counter. So if something really leaks, you'll notice it will grow infinitely.
     
  6. dog_funtom

    dog_funtom

    Joined:
    Nov 16, 2013
    Posts:
    9
    I just tried again and it showed 4MB of Mono memory without any growth. Both in empty project and in my project (even in the scene that need testing for leaks). I even made a script that intentionally deallocates random garbage, but it won't grow, only decrease to 3MB sometimes due to garbage collection. This is a bit weird...

    This article about GC claims that GC.GetTotalMemory() returns the value for a whole managed heap instead of for one application. So, probably, the source was outside of Unity, though it's hard to imagine that I have any application that uses Mono. Or maybe it was a leak in the Unity editor itself, or some of editor scripts (my or third-party).
     
  7. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    @dog_funtom
    If you enable precise mode, you should see how it grows and drops down on GC run.
    And yeah, it measures all managed heap in current Mono process. But Mono is not a .NET framework, it doesn't pre-installed and every app can use own Mono runtime. So GC.GetTotalMemory in mono usually returns managed heap of current process.
    Anyway feel free to let me know if you'll have this issues again, and I'll try to reproduce it to make sure AFPSCounter doesn't leak.
     
  8. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
  9. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
  10. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Regarding your feature request, @Binary42. I made a small research and figured out we don't have needed APIs in our version of Mono to listen for GC. .NET has Garbage Collection Notifications since 4.5 (https://msdn.microsoft.com/en-us/library/cc713687(v=vs.110).aspx) and that's what I could possible use. But we don't have it in our mono.
    I'm not sure there is any other reliable way to do what you're asking for =\
     
  11. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Advanced FPS Counter 1.2.7 is available at Asset Store!
    I added MS value to FPS counter, added fillrate and driver API output to the GPU info, added nice free VeraMono font (and assigned it in prefab) and made few optimizations and fixes.

    Full changelist:
    1.2.7
    - added optional Milliseconds output for FPS counter (turned on by default)
    - added new anchors: UpperCenter and LowerCenter
    - added approximate fillrate to the DeviceInfoCounter's GPU output
    - added graphics API to the DeviceInfoCounter's GPU output
    - added VeraMono monospace font (free for commercial use) and assigned it by default in prefab
    - memory counter's precise mode output optimizations
    - minor optimization in fps calculation code
    - few additions and fixes in the readme
    - other minor changes

    And once again, final version is available as live WebGL demo: http://codestage.ru/unity/fpscounter/demo/
     
  12. jd-conley

    jd-conley

    Joined:
    Aug 30, 2012
    Posts:
    2
    I just grabbed the latest version for a Unity 5 project and get the following warning:

    Assets/CodeStage/AdvancedFPSCounter/Scripts/CountersData/DeviceInfoCounterData.cs(207,59): warning CS0618: `UnityEngine.SystemInfo.graphicsPixelFillrate' is obsolete: `graphicsPixelFillrate is no longer supported in Unity 5.0+.'

    Seems to run fine, though.
     
  13. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @jd.conley!
    Thanks for reporting this, looks like they abandon it since it's really hard to gather fill rate from all the variety of GPUs nowadays.
    Anyway, it should not affect AFPSCounter except it just will not show fillrate on Unity 5+. I'll keep this feature in place for a while since it works in Unity 4.x and often shows fillrate for some popular GPUs.
     
  14. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Great news: Advanced FPS Counter 1.2.8 out!
    Changes:
    - added new MinMax FPS prewarm delay to let you skip any initialization hiccups of the game
    - added currentFPSLevel property to let you easily get current FPS level (normal, warning, critical)
    - added onFPSLevelChange Action to let you react on FPS level change
    - fixed extra empty line in DeviceInfo counter if Unity can't detect RAM amount
    - Advanced FPS Counter Game Object creation in Editor now can be undone
    - Advanced FPS Counter Game Object now automatically selected after creation
    - minor refactorings
    - minor fixes in example scene
    - fixes in readme
     
  15. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @Dmitriy Yukhanov Hello, is there a way to allow the FPS counter prefab to be within a group? Right now if it's not at the root of the scene it gives out a warning at runtime saying it doesn't work:

    Advanced FPS Counter is placed in scene incorrectly and will be auto-destroyed! Please, use "GameObject->Create Other->Code Stage->Advanced FPS Counter" menu to correct this!

    I have a "persistent" group in my scene's root and I need to put the FPS in there. Do you think there could be a way to allow that please?
     
  16. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @Seith !
    Currently it will not allow you do this.
    But you may easily disable this check here:

    AFPSCounter.cs, 613 line:
    Code (CSharp):
    1.  
    2.         private bool IsPlacedCorrectly()
    3.         {
    4.             return (transform.childCount == 0 &&
    5.                     transform.parent == null);
    6.         }
    7.  
    Just remove "&& transform.parent == null" part to disable check for parents.
    It will be removed in fututre updates as well.
     
  17. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Thank you very much Dmitriy, that works!! :)
     
  18. jl008

    jl008

    Joined:
    Jan 31, 2013
    Posts:
    25
    Hi there,

    The readme doc says:
    "Disabled mode is used to remove all counters and stop all internal processes except the global hotkey listener."

    When I choose Disabled as default value for the counter hotkey seems to be not working. It is working only when the initial state is Normal. Is it correct behavior? I wanted to have it disabled (or background) by default and only show up when I hit hotkey...
     
  19. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @vjj! (rhyme!)

    No, it's a kind of bug which I just fixed (submitting bugfix update to the store right now). It's a bit complicated fix to describe it here. Just drop me your invoice and I'll drop you back latest version if you don't wish to wait for the update approval.

    Thanks for reporting it (I fixed one more related issue as well).
     
    Last edited: May 14, 2015
  20. jl008

    jl008

    Joined:
    Jan 31, 2013
    Posts:
    25
    Thanks for quick reply! I will ping you on your support email.

    One more question. Do you know how to render the counter using http://www.unikronsoftware.com/2dtoolkit/doc/2.5/reference/tk2dcamera.html properly? I mean it works just fine when you drop the prefab (and have one tk2dcamera). Yet when you re-size the editor or deploy the app to phones with different resolutions the font is not scaled. As a result, on big resolutions the text is too small and on small resolutions it is too big. It is not big deal but would be nice to have...
     
  21. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    It looks like 2DToolkit does not work fine with GUITexts I'm using to render counters according to this post:
    http://2dtoolkit.com/forum/index.php?topic=2454.0

    I'd suggest to try regular camera in order to draw counters properly.

    I have plans on adding other output options like new UI, nGUI, etc. in future, but still can't say when I'll reach this section in my TODO.
     
  22. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Looking forward to a Unity UI implementation!
     
  23. jl008

    jl008

    Joined:
    Jan 31, 2013
    Posts:
    25
    That's fine. It seems one would need to use http://www.unikronsoftware.com/2dtoolkit/doc/2.4/html/classtk2d_text_mesh.html as a label for it to be scaled properly. It seems like I would just need to rewire DrawableLabel for it to work. But it is not one to one and some thing would need a work around, such as pixelOffset. Anyways it works fine with tk2dcamera besides the scaling part. So I'm good.
     
    codestage likes this.
  24. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    Agreed, it would be nice to use the new UI's built in Canvas Scaler instead of having to scale the font size myself in a custom script.
     
  25. knotFF

    knotFF

    Joined:
    Apr 13, 2013
    Posts:
    66
    Quick one.
    "Advanced FPC Counter" appears to only work if it's placed on the root of hierarchy, is that the expected behaviour?
     
  26. dreasgrech

    dreasgrech

    Joined:
    Feb 9, 2013
    Posts:
    205
    See here.
     
  27. knotFF

    knotFF

    Joined:
    Apr 13, 2013
    Posts:
    66
    Thank you.
     
  28. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Hi, any news on the Unity UI implementation? Thanks.
     
  29. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @Korindian !

    Sorry for a late reply, Unity UI implementation is at the top of my TODO list for AFPSCounter, so more likely it will be included within closest updates.

    However now I'm heavily loaded with new Anti-Cheat Toolkit update and I'll back to AFPSCounter and Maintainer as soon as ACTk will be submitted for review.

    Currently I hope to finish ACTk update in few weeks.
     
  30. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Great, thanks for the update!
     
  31. Deleted User

    Deleted User

    Guest

    How cross platform is this? Would it work for Windows, Linux, Mac, XBox One, Wii U, PS4, Android, iOS? Thanks.
     
  32. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @Black Lodge Games!
    It should run everywhere, where GUIText works.
    I've tested it on Windows (including Phone, Store), Mac, Android, iOS, WebGL.
    Didn't tested it on other platforms yet since I don't have appropriate devices to do this.

    I'd be glad to know how it works for you on those platforms and help fix any compatibility issues if you'll have any.
    Thanks for your interest!
     
    Deleted User likes this.
  33. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    374
    @Dmitriy Yukhanov you sure this plugin is accurate? An empty scene claims 6ms on the CPU and only approx. 160FPS. That doesn't seem right at all.

    I ensured V-Sync was fully disabled.

    I'm on Unity v5.2.
     
    Last edited: Sep 3, 2015
  34. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    I'm not the author of this asset but I might be able to help.
    Default Unity project settings use V-Sync in Every V-Blank.
    If you change your V-Sync settings from Edit/Project Settings/Quality Settings to Don't Sync that might change the CPU usage.
    Hope that helps.
     
  35. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    374
    Yep checked that. Definitely disabled V-Sync.

    FYI I'm on Unity v5.2.
     
  36. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @strich!

    Did you measured it in the Editor?
    Did you tried to check values in the build?

    In my case it show lesser values in Editor since Editor adds own overload. Example:
    367 [2.70 ms] in editor and 1099 [0.9 ms] in standalone build for the example scene.
     
  37. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    374
    Yes it was in the editor. So the editor FPS gauge is more accurate than this plugin when in-editor?
     
  38. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    No, built-in gauge tries to show you a value you'll more likely see in the build, ignoring Editor influence. But AFPSCounter shows you your real FPS as is, including Editor influence.

    Try to use Fraps or similar app to see the real FPS.
    In my case it shows same values as my plugin: http://i.imgur.com/6qwjfGr.png
     
  39. Juan-Gril

    Juan-Gril

    Joined:
    Sep 1, 2014
    Posts:
    1
    +1
     
  40. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @Juan Gril !

    I'm afraid it would be not correct to automatically change all canvas modes from overlay to the camera and assign first camera with GUILayer I encounter.

    End customer may need some uGUI canvas to render as overlay and I can't predict this. All I can - just warn you in the readme about this possible issue. Or I may throw warnings every time I see the overlay canvas, but it more likely will annoy the end customer - he will see it on each run if it uses canvas in overlay mode explicitly.
     
  41. tosiabunio

    tosiabunio

    Joined:
    Jun 29, 2010
    Posts:
    115
    I'm using uGUI in overlay mode exclusively and I wouldn't like to see constantly warning about that. But this also means that most offered anchor places are unusable and the FPS counter isn't displayed in a pixel perfect manner. Any suggestions for possible workarounds?
     
  42. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @tosiabunio !
    Did you tried to change pixel offset? It should allow you to move counters from the initial anchor positions to tune their placement more precisely.
     
  43. Deleted User

    Deleted User

    Guest

    Confirmed working on the Wii U devkit.
     
    codestage likes this.
  44. tosiabunio

    tosiabunio

    Joined:
    Jun 29, 2010
    Posts:
    115
    Yes, I tried but no visible effect. Here's a comparision of GUI text at size 8 using pixel perfect overlay canvas with FPS counter using the same font at size 16:



    Could I use API to retrieve the texts and display tem using Text controls on my overlay canvas?
     
  45. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    @Black Lodge Games thanks for sharing!

    @tosiabunio I meant not the pixel perfect, I meant the pixel offset option AFPSCounter has. You said "most offered anchor places are unusable", that's why I suggested to try use pixel offset option to move counters away from initial positions.

    Regarding pixel perfect - AFPSCounter uses Pixel Correct GUITexts by default and should be able to output pixel perfect fonts. Here is an example with default VeraMono font with Hinted Raster rendering mode: http://i.imgur.com/RVUJRPJ.png

    Are you sure you're applying correct font to the AFPSCounter? Could you please check if GUITexts in the Advanced FPS Counter object has right font assigned?

    You may use AFPSCounter in the Background mode and access all its counters raw values using public API.
     
  46. tosiabunio

    tosiabunio

    Joined:
    Jun 29, 2010
    Posts:
    115
    I used the public API and display pixel perfect values using uGUI with proper anchoring and sorting.

    But you consider adding a couple public uGUI Text fields and when filled by the user use those UI objects to display texts instead of using GUITexts. That would give users more flexibility for using the counter without resorting to custom coding and the public API.
     
  47. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @tosiabunio ,

    I see your point, and going to do something with uGUI support anyway in future, it might be complete move from GUITexts to the uGUI or some kind of option, need to do some research first.

    Thanks for your feedback, stay tuned for updates in this thread!
     
    tosiabunio likes this.
  48. Deleted User

    Deleted User

    Guest

    At least leave a long term legacy edition if you decide to abandon GUIText, so that those who need GUIText can still use your fantastic product. I still use Unity 4.3 to target a current-gen console, which is before uGUI was introduced in 4.6. As time goes on, this use case scenario will die out.
     
  49. codestage

    codestage

    Joined:
    Jul 27, 2012
    Posts:
    1,931
    Hey, @Black Lodge Games !

    Sure, no worries, I'll keep GUITexts. More likely I'll make option to choose from uGUI and GUIText or something like this.
     
    tosiabunio likes this.
  50. g0tNoodles

    g0tNoodles

    Joined:
    Nov 28, 2010
    Posts:
    193
    Hello!

    Is there any way to print out these stats to a text document so I can have testers send the info to me?