Skip to main content

Runtime Analysis

info

Runtime Analysis runs automatically when a creative is tested in develop mode. You can click here for more information.

What is Runtime Analysis?

Runtime Analysis is a feature of Playworks Plugin that excludes unused classes, methods or shaders from your playable build in order to save space, whilst also eliminating the time needed to manually exclude these yourself.

In addition to user methods, classes and shaders, Runtime Analysis also excludes code within the engine that is not being used.

To achieve this, upon running Runtime Analysis we detect all c# classes, their methods and properties. We mark each of them as “unused” and place a hook inside. Each time a class, method or property is used, our hook is fired and and we mark this component as “used”. Were constantly updating this exclusion list as the game is played, and this list will become smaller and smaller as new shaders, classes and methods are used during playthroughs. This exclusion list is shown in the Runtime Analysis tab.

Runtime Analysis uses this procedure to detect what shaders are actively performing in the playable. It runs the same process that is used for classes, methods and properties and the shader data is stored in the Unity Playworks Plugin Shader Variant Collection asset. In this way, Runtime Analysis can help users to export only the necessary shader variants.

Scripts exclusions and Runtime Analysis are not connected with each other. Excluded scripts will not be included in the playable build used during Runtime Analysis.

You will need to playthrough your game enough times that you go through most possible interactions. This will allow Runtime Analysis to have a comprehensive idea of what methods/classes/shaders are needed, and in doing so will avoid errors in your build.

From testing this feature on a number of projects, we have found that Runtime Analysis reduces the size of the playable code by ~30%!

This means you have more space for features and improved game art, which can drive engagement and experience.

Warning!

As this process is automated you may encounter build issues if the wrong script is marked for exclusion. If so, you can check the list of excluded code in the Runtime Analysis tab and untick any methods/classes/shaders that are needed.

Where to find Runtime Analysis

Runtime Analysis can be found by navigating to the Runtime Analysis section of the Playworks Plugin window.

images-large

You can also navigate to this tab from within the Size Optimisation tab, by clicking on the "Optimize Scripts" button.

images-large

How to use Runtime Analysis

Currently, Runtime Analysis runs continuously in background for any develop build. This allows developers not to have to rebuild the project just to execute Runtime Analysis, and this also help to strip unnecessary modules from the beginning of testing.

In order to create an accurate exclusion list, you will need to refresh and playthrough as many aspects/interactions of your game as possible. This will allow Runtime Analysis to build a comprehensive list of methods/classes/shaders to not exclude from the build, and will avoid errors occurring.

How to integrate Runtime Analysis into your Playable Creation process

remember

Runtime Analysis records all used code and its final goal is to make sure you have checked all your work while you are building your playable.

Here is an example of how Runtime Analysis should be integrated into your Playable Creation process:

  1. Take your project and import the latest version of Playworks Plugin.
  2. Create a develop build and check that it works properly in the browser. Runtime Analysis will record the used code for this build.
  3. You might decide to implement a new feature: test it in Unity first, then test it in the develop build. Runtime analysis will record the code used for your feature.
  4. You might want to implement Orientation handling logic: firstly, you can test it in your Unity Playworks Plugin develop build and Runtime analysis will record the used code.
  5. You might implement Playground fields: firstly, test it in Unity Playworks Plugin develop build (dont forget to test all expected values), and Runtime analysis will record the used code.

As a result, all functionalities youve worked on have been recorded by Runtime Analysis. Even if you rearranged your code and some of it is no longer needed, it will be included in the build anyway but it will not take much space.

Warning!

If you do not test your code in a Unity Playworks Plugin build, you cannot be sure it works properly. Please test every code change in develop mode.

CLICK HERE for Runtime Analysis before Playable v3.4.1

Starting Runtime Analysis

In order to start Runtime Analysis, first navigate to it within Playworks Plugin Plugin.

After doing so click on the "Start Analysis" button. This will go about building the game and checking the selected scene(s).

images-large

When this process has completed, a pop-up window will appear asking you to run the playable in the browser.

images-small

This is an important step in the analysis, as your playthrough will highlight any methods/classes that were missed out as 'needed' when the initial scan of your scene(s) was done.

In order to create an accurate exclusion list, you will need to refresh and playthrough as many aspects/interactions of your game as possible. This will allow Runtime Analysis to build a comprehensive list of methods/classes/shaders to not exclude from the build, and will avoid errors occurring.

The build that opens at the end of Runtime Analysis is a unique build that detects unused methods/classes. Future develop builds will allow Playable to re-include methods/classes that were previously marked as unused if their use is detected in future builds, but will not add more methods/classes to the exclusion list. To do so you will need to run Runtime Analysis again.

Pausing Runtime Analysis

With Playworks Plugin 3.1.0, whenever a creative is tested in develop mode, Runtime Analysis will be automatically performed. This allows developers not to have to rebuild the project just to execute the Runtime Analysis process.

Additionally, by activating the Pause Runtime Analysis checkbox, Runtime Analysis can be paused. By doing so, users can temporarily stop the feature from running so they do not have to go through every possible interaction every time a playable is tested.

images-large

If you would like to undo all exclusions made by Runtime Analysis you can simply click on the 'Reset' button:

images-large

Try resetting Runtime Analysis if any of your ad functionalities previously working in Unity suddenly do not work in Luna. Execute Runtime Analysis and play your playable again, but make sure that every app functionality is being called.

Code Tab

Once you tested your develop build, the exclusion list will update and the scripts will be organised in a hierarchical order that follows the structure below:

Namespace
└── Class Name
└── Method Name

Disable Code Stripping

When in you are in the Code Tab of Runtime Analysis, you will be presented with a Disable Code Stripping checkbox. By activating this checkbox, you will prevent Runtime Analysis from removing any code, regardless of the content of excluded code or excluded modules.

images-large

Undoing Exclusions

If you have found that Runtime Analysis has marked a script you need for exclusion, you can untick said script from with the Excluded Code list:

images-large

Excluded Modules

In this section, you can specify if your project does not use any of the following modules:

Activating the checkbox will make Runtime Analysis exclude the selected module, resulting in an additional size reduction.

Shader Tab

Disable Shader Stripping

While in the Shader Tab of Runtime Analysis, you will be presented with a Disable Shader Stripping checkbox. By activating this checkbox, you will prevent Runtime Analysis from from removing any shader.

images-large

Undoing Shader Variants Exclusions

If you have found that Runtime Analysis has excluded a shader variant that is needed for the build, you can re-include it by using the Shader Tab in the Assets section of the plugin. Have a look a this document to see how the Shader Tab works.