This document is about: FUSION 2
SWITCH TO

Fusion Statistics 2.1

To avoid performance impact on the RELEASE DLL, Fusion Statistics will only collect statistics data when using the DEBUG DLL.

Overview

Fusion Statistics consists of a set of UI components for monitoring useful Fusion telemetry. The FusionStatistics component is the primary component for generating, initializing and controlling a hierarchy of telemetry UI elements.

Fusion Statistics uses the basic UnityEngine.UI components, which allows stats to be viewed in builds as either a screen overlay or attached to an object in 3D space.

Fusion Statistics Example
Example of the Fusion Statistics in use.

Basic Usage

There are three ways to get started with Fusion Statistics:

  • Add the component FusionStatistics on a NetworkRunner object before it was started; or,
  • Click the statistics button on the Network Runner Controls window; or,
  • Call the extension method NetworkRunner.SetupStatistics() on a NetworkRunner instance.

Note: It is possible to remove the statistics by clicking the same button again or calling the extension method NetworkRunner.RemoveStatistics().

Add Fusion Statistics
Add Fusion Statistics.

After the setup, a root canvas will be created with a statistics panel displaying lots of useful information.

Line charts can display data either per update (the rate they are collected) or per second. The current rate is shown in the chart name as (U) for per update and (S) for per second. You can toggle the rate by clicking on the chart graphics. A few specific stats are locked to a specific rate, such as RTT, which is locked to per update.

Statistics Panel Usability

Anchor and Collapse
Statistics Panel Anchor and Collapse Usability

You can anchor the panel on either side of the screen. You can also collapse the panel to see more of the game, as shown above.
When using Multi-Peer, a button will be available to switch between statistics panels.

Statistics Pages

The Statistics panel features multiple pages that display specific information, such as memory, network and simulation data. You can switch between these pages using the dropdown menu at the bottom of the panel.

Note: The images were captured alone in shared mode, so a few stats such as Objects Update In or input-related ones are expected to be zero.

Simulation Page

Statistics Simulation Page
Statistics Simulation Page

The simulation page will display stats related to the simulation itself.

  • Forward Ticks: How many forward ticks were simulated.
  • Re-simulation Ticks: How many re-simulation ticks were executed.
  • Objects Update In: How many objects updates fusion received.
  • Objects Update Out: How many objects were updated and sent by the local simulation.

Network Page

Statistics Network Page
Statistics Network Page

Displays networked related stats.

  • RTT: last calculated Round Trip Time. RTT is always displayed per update.
  • In Bandwidth: Amount of Bytes received.
  • Out Bandwidth: Amount of Bytes sent.
  • In Packets: The amount of packets received by the simulation.
  • Out Packets: The amount of packets sent by the simulation.
  • Input In Bandwidth: Amount of bandwidth in Bytes for the inputs received.
  • Input Out Bandwidth: Amount of bandwidth in Bytes for the inputs sent.

Memory Page

Statistics Memory Page
Statistics Memory Page

The Memory page shows the status of the total memory and memory blocks used for the two allocators that Fusion uses internally. If either of these radial charts reaches 100%, Fusion will not have any more memory available to work with. You can change the memory values on the NetworkProjectConfig.

Behaviour Page

Statistics Behaviour Page
Statistics Behaviour Page

Use the Behavior page to check the execution count and execution time of any NetworkBehaviour or SimulationBehaviour internally for Render or FixedUpdateNetwork. Use it to see how many milliseconds of your execution time is spent on a specific behavior.

To add a behavior, click the "Add Behaviour" button and select the desired behaviour. Only the first ten elements are displayed, so use the search bar to find the desired behaviour.

Use the top buttons to change between FixedUpdateNetwork or Render values.

Object Page

Statistics Object Page
Statistics Object Page

The object page is used to check in and out bandwidth for a specific NetworkObject, add an object by clicking the "Add Object" button. Only the first ten elements are displayed, so use the search bar to find the desired object.

Lag Compensation Page

Lag Compensation Page
Lag Compensation Page

The Lag Compensation page displays information about the Lag Compensation system, such as the percentage of hitboxes in use and the time required for internal updates.

Time Page

Time Page
Time Page

The Time page displays various time-related data, such as the delta time between state receives, interpolation offset and more.

Configurations

Statistics Hub Config
Statistics Hub Config

Fusion statistics can be configured either by editing the configuration asset directly or by using the Fusion Hub configuration page. The developer can add new pages, change the background opacity, define how zero values will be treated, set a refresh rate for the pages, and more.

The configuration is applied when setting up the statistics panel.

Configuration asset path: Photon/Fusion/Runtime/Statistics/Resources/FusionStatsResources/FusionStatisticsDefaultConfig.asset

World Anchor

In VR scenarios, or any other scenario where it is necessary to set the statistics graphs to world position, this can be achieved by using the extension method NetworkRunner.SetStatisticsWorldAnchor(Anchor).
Pass a Null value as anchor to restore the canvas to screen space. Adjust the size by scaling the StatisticsRootCanvas object.

The statistics panel canvas will follow the GameObject position, if the object is destroyed the statistics will be removed from the NetworkRunner and the developer should set it up again.

Breaking Changes from 2.0

Fusion statistics changed a bit, the following instructions will help when upgrading from fusion 2.0.

Manually Collecting Data

Since it may be desirable to gather the values directly, it is possible to read the stats directly from the FusionStatisticsManager from the NetworkRunner. They can now be accessed as follows:

Note: Each simulation stat has a corresponding value on the FusionStatType enum.

C#

public void StatisticsCollectData() {
    if (Runner.TryGetFusionStatistics(out var statisticsManager)) {
        // simulation snapshot
        var rtt = statisticsManager.SimulationSnapshot.Stats[FusionStatType.RoundTripTime];
        var forwardTicks = statisticsManager.SimulationSnapshot.Stats[FusionStatType.ForwardTicks];
        
        // memory snapshot
        var generalMemoryFree = statisticsManager.MemorySnapshot.GeneralAllocatorMemorySnapshot.TotalBytesFree;
    }
}

Known Issues

  • Unity may throw an error about GUIClips when editing the gradient fields on the configuration page.
Back to top