Code Monkey home page Code Monkey logo

visualprofiler-unity's Introduction

Visual Profiler

The Visual Profiler provides a drop in solution for viewing your mixed reality Unity application's frame rate, scene complexity, and memory usage across a variety of platforms.

Visual Profiler Screenshot

Missed frames are displayed over time to visually find problem areas. Scene complexity is reported in the form of batches, draw calls, and rendered vertex counts (or triangle counts). Memory is reported as current, peak and max usage in a bar graph.

Note

To ensure the profiler is minimally intrusive it does not create any GameObjects, perform any per frame managed allocations, and renders in a single draw call.

The Visual Profiler has been verified to work on the following platforms:

  • Microsoft HoloLens & HoloLens 2
  • Microsoft Immersive headsets (IHMD)
  • OpenXR platforms
  • Steam VR (HTC Vive / Oculus Rift)
  • Meta Quest & Quest 2
  • Windows PCs
  • WebGL

Installation

The Visual Profiler is normally ingested as a Unity package. To import the Visual Profiler package into your Unity project follow the below steps:

Note

The Visual Profiler package requires Unity 2021.3 and above.

  1. Open your Unity project and select Window > Package Manager from the file menu bar

  2. Click the '+' icon within the Package Manager and select "Add package from git URL..."

    Package Manager Add

  3. Paste https://github.com/microsoft/VisualProfiler-Unity.git?path=/com.microsoft.mixedreality.visualprofiler#v3.4.0 into the text field and click "Add"

    Package Manager Paste

  4. The Visual Profiler will now be installed within your Unity project as an immutable package within the project's Packages folder named Microsoft Mixed Reality Visual Profiler.

  5. Finally, add the VisualProfiler component to any GameObject in the Unity scene you wish to profile. The profiler is initially active and visible (toggle-able via the IsVisible property), but can be toggled via the enabled/disable voice command keywords (on Windows/UWP platforms only).

It is advised you use a specific release of the Visual Profiler package to ensure your project is locked to a stable release. Release version 3.4.0 is suggested in step three above. You can also pull another version, specific branch, or git commit hash by altering the URL as demonstrated below:

Syntax URL example
Specific version https://github.com/microsoft/VisualProfiler-Unity.git?path=/com.microsoft.mixedreality.visualprofiler#vX.Y.Z
Specific branch https://github.com/microsoft/VisualProfiler-Unity.git?path=/com.microsoft.mixedreality.visualprofiler#my_branch
Git commit hash https://github.com/microsoft/VisualProfiler-Unity.git?path=/com.microsoft.mixedreality.visualprofiler#badc0ffee0ddf00ddead10cc8badf00d1badb002

Usage

When using the profiler look for "missed frames" which appear as orange bars. Missed frames indicate your application is not hitting its target frame rate and may need optimization work. Draw call counts and vertex counts (or triangle counts) are also displayed under the missed frame indicators. These numbers can be indicative of why your app isn't meeting its target frame rate.

Profiler Guide

One should also keep an eye on the bottom memory bar to insure memory usage isn't rapidly changing or approaching the application's memory limit.

Note

The Visual Profiler works in both development and release builds.

The profiler UI (such as anchoring, scale, follow behavior and UI color) can also be tweaked in the component inspector.

Profiler Inspector

Custom profilers can be added to the bottom of the Visual Profiler by adding to the list of "Profiler Groups." Profiler Groups use Unity's ProfilerRecorder API. For example the below image shows how the "BehaviorUpdate", "LateBehaviourUpdate", and "FixedBehaviourUpdate" markers display a millisecond average over 300 samples with the group label "Scripting."

Custom Profilers

Sample

A sample Unity project can be found in the VisualProfilerUnityProject folder. This project contains a simple sample scene that demonstrates the Visual Profiler being used in 3D and 2D (perspective and orthographic cameras) plus example profiler groups for C# behaviors, rendering, and physics.

Sample

Feedback

To file issues or suggestions, please use the Issues page for this project on GitHub.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

visualprofiler-unity's People

Contributors

camccaf-msft avatar cameron-micka avatar keveleigh avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

visualprofiler-unity's Issues

Why does gpuFrameRate always be zero?

Dear contributors,

I am working on profiling my MRTK app on Hololens2 by VisualProfiler. I noticed that cpuFrameRate has values ranging from 0 to 60 fps. However, gpuFrameRate is always zero.
Is that because VisualProfiler can not access the information of GPU rendering?

Improve Accessibility

Great feedback:

For accessibility / D&I, I wonder how hard it would be to put a ! or other indicator on the reds (or simply pick a more differentiated color) so they are more distinguishable. Note on color blindness... if you choose a red and a green that would be hard for a color-typical person to easily distinguish if it were converted to grayscale, then they are probably not differentiated enough for someone with red-green color blindness. If it's a dark green and a bright red, I'd be able to differentiate it fine. Thanks!

Would be nice to see triangle (poly) counts as well.

Describe the problem

Right now vertex counts are displayed but some developers (often artists) are curious about triangle counts as well.

Describe the solution you'd like

Display triangle counts rather than vertex counts.

Describe alternatives you've considered

Or, display them side by side.

Positioning is difficult. Please improve.

Can you make it so that this thing will follow a transform instead of automatically only following the main camera? Also the profiler is way too close to my face and I can't adjust how far away it is. Make it easier to look at in VR.

How to Increase Font Resolution When Project Quality Is Set to Very Low

The Issue

Texts on the profiler becomes highly blurry and illegible when the project quality is set to Very Low.

A Potential Solution

All I did was

  1. First make a copy of the original immutable Microsoft Mixed Reality Visual Profiler/Data folder to be able to edit the font file,
  2. Reassign the new font texture and material to the Visual Profiler script component,
  3. Navigate to the new /Data/Font, and on the Inspector change Texture Type to Sprite (2D and UI) and then hit apply.
  4. (Also make sure the Font texture's Max Size is not smaller than 512.)

I am hoping this would be made a little simpler to accomplish.

Existing doc link

The issue is not mentioned in the existing doc.

Additional context

If it matters at all, I am using
Unity 2021.3 LTS
MRTK 3
com.microsoft.mixedreality.visualprofiler#v3.3.0

Thanks for reading!

Add screen-space options, and/or options to work with Orthographic cameras

Describe the problem

I want to use this for apps in screen-space, as well as immersive versions. I'd be able to make do with world-space, except some of our apps also use orthographic cameras

Describe the solution you'd like

An toggle in Window Settings to show this in screen-space, where it basically snaps to the anchor positions with the offsets given and stays there. Ideally sitting on top of UI elements too

Describe alternatives you've considered

I did try to just deal with it just being in world-space, but ran into issues with orthographic cameras (calculations obviously don't work, scale limit is much too small), clipping, and overlapping with the UI elements.

Additional context

May be an odd request, but apps like Microsoft Mesh are a prime example of something that exists in both 2D and 3D space, and it's nice to have the same sort of profiler for simplicity.

I know I could use another profiler, but I just love this one so much ^_^.

I am having a play with hacking the shader a bit when orthographic, dunno how i'll go though.

Add .tgz files to GitHub releases

Describe the problem

This package doesn't have the .tgz package file in the GitHub releases as for the MRTK relseases.
The computer I work on doesn't have internet access, so I can't install the package using the git link in package manager. I had to manually download the code, pack it into a .tgz file and add it to my project.

Describe the solution you'd like

I'd like to have an official .tgz file on GitHub releases so it's easy to download it and transfert it to an offline computer.

Describe alternatives you've considered

Maybe it can also be released in the Mixed Reality Feature Tool?

Simple frame time display

In the same vein as Unreal's stat unit command a simple frame time display:

image

New features to aspire towards are:

  • Zero per frame allocations
  • No gameobjects created
  • One draw call

Ideally it uses Unity's new recorder API and we can simply do text rendering by doing it in a shader

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.