Categories News

Why does Shader memory stay high? Variance management is key – UWA Q&A | Blog | Sharing gaming and VR application performance optimization notes

1) Why does Shader memory remain high? Variance management is key
2) Common causes and methods of positioning font resource redundancy


This is UWA’s 473rd technical knowledge sharing effort. It selects hot topics in the UWA community and includes UWA Q&A, community posts and other technical knowledge points to help everyone master and learn more comprehensively.

UWA community homepage: community.uwa4d.com
UWA QQ Group: 793972859

The practical cases driven this time come from real and typical problems in projects that use UWA services. UWA organizes important pointers, positioning paths, and processing suggestions into reusable case notes, making it easy for anyone to quickly compare and solve similar problems in their own projects.

Practical cases

Q: After testing our project using UWA GOT Online, we found that reports show that the peak Shader value is 200MB, which is far beyond the recommended UWA value (<60MB), and fluctuates greatly in various scenarios. Is this phenomenon normal? How to optimize Shaders in the future?

A: From the GOT Online report, we can see that the project’s Shader memory peaked at around 200 MB, and the Shader memory kept fluctuating significantly in various scenarios. Judging from the Shader resource memory trend curve alone, there are certain problems with the current Shader memory management.

We can specifically find the reason for the high memory of the Shader by determining its frame. Select the specified frames and sort them in reverse order of memory usage. You will find that a large number of single Shaders have excessive usage. It is recommended that in mobile game projects, focus on all Shaders that occupy more than 1MB each. There is basically room for optimization in those Shaders, such as Standard in the Built-in pipeline, UberPost, Lit, and other Shaders in the UPR pipeline.

Additionally, because there is a strong correlation between Shader memory usage and the number of variants, Shader memory essentially reflects the complexity of the compiled files. The core depends on two main factors: the number of calculations of one variant and the total number of variants. Both can roughly be considered product relationships.

Typically we would not sacrifice the computational complexity of a single variant to reduce Shader memory – this would have a direct impact on screen performance, so the core entry point of optimization should focus on controlling the number of variants. For example, UberPost Shader memory in a typical URP project requires about 21 MB, and the number of associated variants is about 2,000. Therefore, unless the Shader you write yourself in this project is much more complicated than this, the memory ratio and number of variants will roughly remain at this order of magnitude.

Combining these rules, it can be further concluded that the core reason for the high memory of various single Shaders with high occupancy in this project is largely because a large number of redundant variants reside for a long time. In contrast, in conventional mobile projects, although a wide variety of Shaders are reused, there are often only a few hundred or even fewer variants that actually participate in rendering during actual operation. A large number of invalid Shader variants that are not enabled exist for long periods of time, continuously causing memory redundancy and wasting resources. The top-ranked shader in the current report is estimated to have thousands of variants logged into memory. You can use UWA’s online AssetBundle detection tool to further check the number of keyword variants and combinations.

In this case, you can use callback nodes such as OnProcessShader to adjust the logic to accurately intercept and protect against useless macro keyword combinations and excessive variations in the rendering process. Since the size of the variants will grow exponentially with keyword overlay, after cleaning up redundant keywords and simplifying invalid combinations, the total number of Shader variants and memory overhead can be greatly reduced, and the overall optimization benefits become very significant.

In short, combined with our previous project optimization experience, the more recommended approach is: unified management after Shader effects stabilize, complete variant collection, unified packaging of ShaderVariantCollection files and Shader resources into the same AssetBundle, and centralized loading, caching and preheating during the game startup phase. This optimization solution can effectively control the Shader’s memory overhead and keep it within a reasonable range, and ultimately present a smooth, non-fluctuating linear state on the memory trend graph.

Practical cases

Q: We discovered font resource redundancy in the UWA GOT Online report. Peak numbers indicate that multiple resources with the same name are in memory at the same time. What is the reason?

A: One of the most common reasons resource duplication and redundancy occurs is because the resources are not packaged properly according to their dependencies. If the same font resource is packaged into several different AssetBundle packages, and multiple AssetBundle packages are loaded simultaneously during runtime, the resource will be created repeatedly in memory, and eventually multiple copies of the resource with the same name will exist. This issue is universal and does not only occur with font resources. A similar situation will occur in various resources such as textures, models and Shaders. If you later find that the number of project resources is abnormal and the memory peak is too high, you can prioritize checking whether there are redundant problems caused by packaging AssetBundle. It is also one of the most common and common types of resource redundancy in game development.

Such issues can be quickly identified with the help of UWA’s online AssetBundle detection tool: by analyzing resource dependency links completely, repeatedly packaged resources can be accurately filtered and the root cause of redundancy can be efficiently investigated. In addition, unreasonable resource loading and unloading strategies can also lead to resource redundancy, requiring targeted investigation and optimization based on project resource lifecycle management logic.

Whether it’s back-and-forth discussions between developers in the community or rapid feedback from AI based on accumulated knowledge, the point is to solve every technical problem and every obstacle to make an impact. The sharing of this issue comes from the UWA AI Q&A and UWA Q&A communities. I hope that this experience drawn from real development scenarios can directly help you solve technical problems that are stuck at the moment, and also enable you to find solutions more efficiently when faced with similar problems.

Cover image comes from the Internet


That’s all for sharing today. Life has limits but knowledge has no limits. In a long development cycle, the problems we encountered were just the tip of the iceberg. The UWA community is ready to accompany you to explore and share together. More developers are welcome to join the UWA community.

UWA official website: www.uwa4d.com
UWA Community: community.uwa4d.com
UWA Schools: edu.uwa4d.com
Official technical QQ group: 793972859

PakarPBN

A Private Blog Network (PBN) is a collection of websites that are controlled by a single individual or organization and used primarily to build backlinks to a “money site” in order to influence its ranking in search engines such as Google. The core idea behind a PBN is based on the importance of backlinks in Google’s ranking algorithm. Since Google views backlinks as signals of authority and trust, some website owners attempt to artificially create these signals through a controlled network of sites.

In a typical PBN setup, the owner acquires expired or aged domains that already have existing authority, backlinks, and history. These domains are rebuilt with new content and hosted separately, often using different IP addresses, hosting providers, themes, and ownership details to make them appear unrelated. Within the content published on these sites, links are strategically placed that point to the main website the owner wants to rank higher. By doing this, the owner attempts to pass link equity (also known as “link juice”) from the PBN sites to the target website.

The purpose of a PBN is to give the impression that the target website is naturally earning links from multiple independent sources. If done effectively, this can temporarily improve keyword rankings, increase organic visibility, and drive more traffic from search results.

Jasa Backlink

Download Anime Batch

More From Author