#How to figure out what pulls font asset into sharedassets0.assets.resS?
1 messages · Page 1 of 1 (latest)
Maybe provide some context first. Like what that file is and how it's relevant to anything?
its the same font asset file from yesterday, but now its being loaded from a different location
the addressable part of it was solved
The same as in the asset bundle?
And what makes you think that the shared assets file is related?
that's not in the assetbundle anymore, Report doesn't show it anymore and memory profiler doesn't show the AssetBundle references anymore connecting to them
Memory Profiler says it
bottom right corner: sharedassets0.assets.resS
This just mean that it's not a real asset, but generated in the editor or during build. Anyways, you should be look at the referenced by window. You can see that it's referenced by a font asset, so you should be looking at why that fond asset is loaded.
that doesn't help
I know that font asset well
Well, then see what is referencing it or why it's loaded.
so by default, the font asset had a fallback list, where there were like 10 different font assets placed
this is the case in editor time
but I made a class months ago, which clears up this font fallback list during runtime
and that part works perfectly
because it worked well for months
I'm not allowed to remove the fonts from the font fallback list entirely though
so those should not be there in the first place
@digital kestrel "then see what is referencing it or why it's loaded." this is what I'm trying to do in the last few months constantly 🙂
Can't you double click it here? Or search in the profiler and select it manually?
I'm doing 3 tasks parallel, so I will check it later
what to double check it there?
this is all I can see
for some reason I can't even see that sharedassets0.assets.resS stuff now
@dusty zodiac any idea?
sorry for pinging, but I should have already solved this
Whats the issue, that this font is referenced at all? It says 4.5k managed references which is quite a lot
it should not be referenced at all
this font + a 16 others
all chinese, korean and japanese localizations
while in fact the language is not even selected
Try using this in editor to double check dependencies easier https://github.com/SilverdaleGames/AssetReferenceViewer
never mind, I realized I cleared up the direct references to font assets in the Addressables, which were added as a dependency (not directly added)
but there are also indirect references to those font assets
and I realized rebuilding addressables doesn't clear up those indirect references
I don't know why though
so how can I forcely rebuild all addressables?
because this was not enough
yea that helps but you can also just delete all addressable stuff in Library/
I afraid to do that
but if you know the correct way of doing this, it would be awesome
deleting stuff in Library could cause multiple hours of importing, especially with huge projects
No just Library/com.unity.addressables
I literally have build CI delete this to ensure bullshit doesnt happen
so only this folder needs to be deleted?
Yea it should help clear out cached data
I don't know if you solved it by know, but basically you can see that it's referenced by something, which is why it's loaded. As simple as that. And you can see what it's referenced by by expending the hierarchy there.
I think we went over this many many times by now though...
I will be honest with you. I perfectly know that means "sometimes" (I highly doubt that is the case each time) its referenced by something. But honestly the Memory Profiler is not that efficient to find these issues.
For example, I needed to learn in the last few months that the "Referenced By" window is 70% of time is simply misleading and extremely confusing. Like its intentionally not showing the references correctly (not showing the root cause), or showing child classes instead of the real referencing parent classes, etc.
I needed to invest hours to correctly figure out the exact reasons, because it was so extremely confusing that window is
now its confusing again
not logical at all
@dusty zodiac I deleted the Library/com.unity.addressables, it rebuilt addressables (although its again took quarter of time it did building for the very first time)
and it still says its referencing that font
which is quite impossible
I already searched those prefabs looking for t:TextMeshProUGUI, there's only 2 components of those in these prefabs, and that has None in the Font Asset field
It can't show the root cause. Because all of the causes are equal for the profiler. It can't make assumptions about where in the reference chain you want to cut the dependency.
Same for classes. It's probably showing the class of the instance that holds the reference. If the code that actually references the object is from a base class or not is unrelated. If it were to infer that data with reflection or something, it would take ages to make a capture.
Both of these things are easily solvable with human brain and ide tools. For the former, you need to read reference chain and understand the relationship. You can easily discard cyclical references if you notice one. For the latter, you can scope the ide search to specific files or scroll quickly through the class definitions and look at their fields.
okay, we won't progress if you're only saying that I'm dumb for still not understanding it
my human brain simply can't understand this
I'm not saying that you're dumb, but you're jumping all over the place instead on focusing on one thing a little bit to get the info you need to solve the issue.
This is mot even the memory profiler.
okay, then maybe help me understand the issue...
memory profiler shows me 17 font assets, and they are huge, 64 mb each
And it just tells you that the asset is referencing the font asset somewhere. Perhaps it's not the ugui components. Or maybe there's another asset in between. Like default fallback fonts or something.
or 32 mb, I don't remember, but they are huge
I'm not jumping all over the place, this is the issue
What do the references show?
I already told you...
Where??
we are wasting time if I'm showing you that again...
@digital kestrel
That doesn't answer my question. And btw we went of it here:
<#1423598442470441012 message>
Did you do what I suggested or not?
Speaking of wasting time...
I'm seeing that font asset
and I know that its loaded, because that font is inside the fallback list
Great. Then that's the answer.
Yep. If you don't want it loaded, remove it from the fallback list.
There is no other solution
I'm not allowed to remove these fonts from the fallback list
Then there is no solution.
there must be without remaking the whole project
because it would mean that
I can't remove those from the fallback list
this is why I'm looking for different ways
There are no different ways. That's how tmp or even unity asset management works.
You'll need to customize the engine.
would you listen to me?
if the prefabs I'm talking about don't refer to the LTSoul medium sdf (containing those fonts in the fallback list) then I believe the fallback list wouldn't be loaded
this is the other route I want to solve
Then you need to see what they are referenced by in the memory profiler.
Or dig through the prefab.
your way would take weeks to solve this issue... and I'm not allowed to do those huge changes in the project
already did that multiple times
this is what I'm trying to explain
It could be that this font is used by default. Or is in a fallback list of the default font asset.
no, so
there's one common shared sub prefab in these referering prefabs
and that one common shared sub prefab had this LTsoul medium SDF font
but I already deleted that reference, its None
so there's nothing anymore refering to that font
Then look at the memory profiler to see what is referencing it...🤷♂️
You can spend a few hours(really no need for a few hours even) doing that, or keep on guessing.
my eyes are popping out looking at that
I looked at that so many times without recognizing anything useful
It literally tells you what is referencing what. I don't understand how that's not useful.
I have an idea, to check in the memory profiler where the Ltsoul medium sdf is referenced instead of the huge font assets
although I'm 99% sure where is it referenced from, but lets see
making a build now
for some reason its not in the memory anymore...
what I only did is to remove the TextMeshProUGUI component from the prefab, I pressed CTRL+Z to replace it back and I rebuilt addressables, and I created a new build
@digital kestrel okay, I made a new build and it appeared again...
these are the references
I can't really see anything here
maybe I can't read
Double click the font asset. Or search it in left area of the window.
why would I want to see the font asset? I already saw its in the fallback list
but I still need to go around the fallback list
You can't go around it
Because that's why it's loaded... Are we gonna go over this again..?
If it's loaded because it's in a fallback list of some other font that is actually used in the game, then there is no way around it, aside from removing it from that fallback list...
I really don't understand what's so hard to understand about this..?
@digital kestrel I told you million times that I'm not allowed to remove those from the fallback list...
and there's a way around it, why do you think its not...
maybe not loading the entire font asset at all, which has the fallback list?
this is what I'm trying to do now
to skip loading the entire font asset with its fallback list
I mean to skip adding that font asset into the prefab
because that's how it gets into the addressable bundles
Well then we're back to looking at the references - prevent the asset with the fallback list from being loaded.
See what's referencing it.
there was only one thing referencing it, and that didn't have the font asset anymore, because I removed that
I needed to completely remove the TextMeshProUGUI component to make it recognize its not connecting anymore to that font asset
but I didn't want to remove the whole component though...
If there is nothing that references it anymore, and it's not loaded manually, then it wouldn't be in the profiler.
Both of these you can confirm in the memory profiler.
its in the profiler only because it gets built into addressables
So, you see the asset bundle referencing it in the profiler like before?
no... for some reason I can't. But if I just tested it to temporarily completely remove the whole TextMeshProUGUI component, then it worked
worked = it was not referenced anymore
just again the Memory Profiler can't correctly print its referenced from there
It's the third time I'm asking it, but did you try double clicking the font asset or searching it in the profiler, selecting and looking at "referenced by"?
If you're gonna dismiss this question again, I'm gonna mute you and never participate in this conversation again. It's really annoying when you're trying to help but getting ignored repeatedly...
Ok, so it is referenced by the asset bundle
But that's not what I was asking about
What is the font asset referenced by
not the atlas
These objects should all be referenced by the same thing in the end. They're just objects representing characters.
So it is referenced by these tmp components
that's fine that these are using that font during runtime
but during runtime I clear up the fallback list
I just can't clear that up in build time
because for runtime I can write preprocessor directives around it
but not in build time
because I can't create new prefab variants for everything using the font asset
Now you're adding a lot of info that we never heard before and I've no clue how it's related to the issue..? Why is there a distinction between build time and runtime?
its only related to the issue, because this whole thing caused issues for me in the past
that the chinese fonts are in the fallback list
but since I was not allowed to remove those from the asset itself in build time, because that would need to remake half of the game
I made a system to clear up the fallback list during runtime
and that worked perfectly for some months
until new addressable bundles were created, which are refering to a shared prefab between them, which is using the font asset
since I'm still not allowed to manipulate fallback list in build time or editor time, I just need to find a way to remove the whole reference to that asset in build time
and in build time, only the shared prefab is refering to that
Then I've no clue why that's fine that these are using that font during runtime.
If it's referencing it at runtime, then it would be loaded, no matter how much you manipulate it outside of the runtime.
but the fallback list is clear during runtime
But why would it matter if we see it referenced in the profiler anyway?
We can clearly see that it's referenced in the TMP components that are referenced by the gameobject and some tweeen components. So either your fallback list cleaning didn't work, or it's referenced somewhere else as well(like the actual font field)
Maybe looking at these characters hierarchy can reveal more info on where exactly in the TMP ecosystem it's referenced.
You can also try breaking in a script that has a reference to one of these components to see what field exactly references the font asset.
but it works, because these are the References By list of the LTSoul-Medium SDF
and not the References By list of the fallback list font assets
Indeed, these are referenced directly in tmp component.
So the fallback list is not related here. At least from what we can see so far.
@digital kestrel so the reference was really disappeared from Addressables, but its appeared again in sharedassets0.assets.resS.
Since I can't understand "Referenced By" again (its intentionally not showing the real sources), how should I figure out how these get into the sharedassets file?
Shared assets is just where assets referenced in a scene go to. It's there because it's referenced by something. No other reason.
You can see that it's referenced by a font asset, so you need to figure out why the font asset is loaded.
@digital kestrel we already spoke about the font fallback list and that these are assigned there, but I already said I'm not allowed to clear the fallback list in build time
and its cleared in runtime
so we need to find a different solution
also, for some reason, if I make a build, sometime these get loaded and sometimes they are not
and I have zero idea why
in one build these gets included, in the next one its not
although I didn't change anything
Runtime doesn't matter... If there is a dependency at build time then that is the explanation
@dusty zodiac for multiple months it was appeared in the memory profiler
it only appeared recently
but these were in the fallback list from the beginning of the project
this is why I think there must be a different solution than rewriting the whole game because of this
You can check asset dependencies in editor by using third party tools or using Asset database yourself.
because removing these fonts from the other font's fallback list would mean to rewrite the whole game
this is the only thing I see
Well, you can definitely see it referenced by something, so your "clearing" doesn't seem to be working
Check dependencies with this: https://github.com/innogames/asset-relations-viewer
Remember anything in Resources is always included in builds
I afraid its not referenced in runtime, only in build time
This one says that it's unused loaded. You could probably unload it with UnloadUnusedAssets.
@digital kestrel check this image
The profiler is showing the references at the time of the capture.
Yeah. Check my message above
hmm, now I could really do unload_unused_assets
weird
that's not always working for unused references
although it should
It was referenced by something first, so it loaded. Then it stopped being referenced, but because it's an asset, it's not GCed. It remains in memory until scene load or manual unloading.
"but because it's an asset, it's not GCed."
now this part was not trivial at all
Unity should really have a manual for this Memory Profiler 🙂 not straightforward sometimes
or I'm dumb
You should be able to Destroy() the asset to unload it
If you are very sure it's not in use
It literally says that in the profiler...
Reading is a very powerfull tool
Read stuff, especially if it says stuff like "help"
which you didn't do "but because it's an asset, it's not GCed."
the not trivial part was "because of its an asset"
and its not printed anywhere
I mean the reasoning
This is irrelevant. It is your fault to make an assumption that GC unloads everything
that its not unloaded especially because of its an asset
obviously
At the very least you should know that GC does not manage native memory, that most assets would live in.
And you don't need to know that detail anyway. The profiler tells you why it's loaded and how to unload it. That's the main source of truth. If you need to know the specific reason, then you just research that. Or ask the community.
okay, so I guess it was not enough: _regularFonts[i].fallbackFontAssetTable.Clear();
I should also destroy ONLY those elements which won't be needed during the session
right?
I still needed your description about "if its an asset, then it won't be cleared up by GC automatically". Because based on that screenshot it was not trivial at all
If it's orphan(not referenced by anything), I think UnloadUnusedAssets should work.
english is not my native language, you know
Destroy would probably destroy it(at least the native part) even if it's referenced.
and after the clear, should I wait one frame, or I could call UnloadUnusedAssets right away?
It's probably fine to call it right away, though don't quote me on that.
All the stuff that's on the C++ side of the engine
Basically everything other than what you(or engine packages) create/allocate explicitly in C#, + some C# wrappers of native objects(the "managed shell" that you've seen in the profiler).
A good example of this concept is if you make a new texture and forget to destroy it. The c# object may get garbage collected but the native object counterpart and texture data (it's pixels) will remain.
what would be the c# object in that case? the texture.asset?
Texture2D tex = new Texture()
Everything you reference in C# is a C# object. It's just that often it's just a wrapper of a C++ object.
and what is the correct way of using Resources.UnloadUnusedAssets if a scene is getting played for like 1 hour?
should I regularly call this in every 5-10 min?
a lot of objects getting created during this time
Ideally, don't. If you need to use it all the time there's something really wrong going on. Like assets being created at runtime.
and a lot of objects gets destroyed
hundreds of enemies
prefabs
I mean prefab instances
These don't need unload assets to be called to get cleared.
and mostly because it was not written in ECS
Unless for some reason the same prefabs are loaded(not instantiated, but actually loaded), again and again.
And even then I'm not sure that's possible in the first place.🤔
some of them were cached into object pool
but so much objects were cached into pools that I'm clearing those up as well
multiple hundreds of objects without being reused
Well, then uncache them. Calling unload assets is not gonna help, as prefab instances are not assets.
well, currently I'm just doing a test to set cache counts to 1
and I check memory again
not so easy to uncache them, because there are a lot of times when these are random (I mean their usage)
so we will see
@digital kestrel okay, exact same story again
used asset
but from where, I can't see again
maybe I can't read and I should go back to elementary school
I don't get it... if it worked well a week ago, then what has been added which again loads everything
I know its the LTSoul-Medium SDF fallback list...
but I'm clearing that in runtime, and that worked perfectly a week ago
nobody touched that
then I have no idea what happened again
Referenced by tmp components
Something references it again.🤷♂️
Then your solution is not failproof.
I'm using a fully different scene to profile memory now in editor (still can't make builds quickly), maybe that's the reason. A few weeks ago I still used a different scene to profile from