#How to figure out what pulls font asset into sharedassets0.assets.resS?

1 messages · Page 1 of 1 (latest)

round shale
#

There are some font atlases, which gets pulled into sharedassets0.assets.resS. But I don't know what uses them (because these are chinese fonts, and nothing in the game shows chinese texts displayed anywhere).

digital kestrel
round shale
#

the addressable part of it was solved

digital kestrel
#

The same as in the asset bundle?

#

And what makes you think that the shared assets file is related?

round shale
round shale
#

bottom right corner: sharedassets0.assets.resS

digital kestrel
# round shale

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.

round shale
#

I know that font asset well

digital kestrel
#

Well, then see what is referencing it or why it's loaded.

round shale
#

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 🙂

digital kestrel
round shale
#

I'm doing 3 tasks parallel, so I will check it later

round shale
#

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

dusty zodiac
#

Whats the issue, that this font is referenced at all? It says 4.5k managed references which is quite a lot

round shale
#

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

dusty zodiac
round shale
#

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

dusty zodiac
#

yea that helps but you can also just delete all addressable stuff in Library/

round shale
#

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

dusty zodiac
#

No just Library/com.unity.addressables

#

I literally have build CI delete this to ensure bullshit doesnt happen

storm iris
dusty zodiac
digital kestrel
# round shale what to double check it there?

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...

round shale
# digital kestrel I don't know if you solved it by know, but basically you can see that it's refer...

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

digital kestrel
# round shale I will be honest with you. I perfectly know that means "sometimes" (I highly dou...

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.

round shale
round shale
digital kestrel
digital kestrel
round shale
#

memory profiler shows me 17 font assets, and they are huge, 64 mb each

digital kestrel
#

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.

round shale
#

or 32 mb, I don't remember, but they are huge

#

I'm not jumping all over the place, this is the issue

digital kestrel
round shale
#

I already told you...

digital kestrel
#

Where??

round shale
#

we are wasting time if I'm showing you that again...

round shale
digital kestrel
#

Did you do what I suggested or not?

#

Speaking of wasting time...

round shale
#

I'm seeing that font asset

#

and I know that its loaded, because that font is inside the fallback list

digital kestrel
round shale
#

see?

digital kestrel
#

Yep. If you don't want it loaded, remove it from the fallback list.

round shale
#

I know this is the answer, but the solution is not to remove these

#

nooo

digital kestrel
#

There is no other solution

round shale
#

I'm not allowed to remove these fonts from the fallback list

digital kestrel
#

Then there is no solution.

round shale
#

because it would mean that

#

I can't remove those from the fallback list

#

this is why I'm looking for different ways

digital kestrel
#

There are no different ways. That's how tmp or even unity asset management works.

#

You'll need to customize the engine.

round shale
#

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

digital kestrel
#

Then you need to see what they are referenced by in the memory profiler.

#

Or dig through the prefab.

round shale
#

your way would take weeks to solve this issue... and I'm not allowed to do those huge changes in the project

round shale
#

this is what I'm trying to explain

digital kestrel
#

It could be that this font is used by default. Or is in a fallback list of the default font asset.

round shale
#

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

digital kestrel
#

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.

round shale
#

I looked at that so many times without recognizing anything useful

digital kestrel
#

It literally tells you what is referencing what. I don't understand how that's not useful.

round shale
#

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

round shale
#

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

round shale
#

@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

digital kestrel
# round shale

Double click the font asset. Or search it in left area of the window.

round shale
#

but I still need to go around the fallback list

digital kestrel
#

You can't go around it

digital kestrel
#

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..?

round shale
#

@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

digital kestrel
#

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.

round shale
#

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...

digital kestrel
#

Both of these you can confirm in the memory profiler.

round shale
#

its in the profiler only because it gets built into addressables

digital kestrel
#

So, you see the asset bundle referencing it in the profiler like before?

round shale
#

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

digital kestrel
#

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...

round shale
#

I don't dismiss anything...

digital kestrel
#

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

round shale
digital kestrel
# round shale

These objects should all be referenced by the same thing in the end. They're just objects representing characters.

digital kestrel
round shale
#

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

digital kestrel
#

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?

round shale
#

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

digital kestrel
#

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.

round shale
#

but the fallback list is clear during runtime

digital kestrel
#

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.

round shale
#

and not the References By list of the fallback list font assets

digital kestrel
#

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.

round shale
#

yeah

#

maybe I explain things badly

round shale
#

@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?

digital kestrel
#

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.

round shale
#

@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

dusty zodiac
#

Runtime doesn't matter... If there is a dependency at build time then that is the explanation

round shale
#

@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

dusty zodiac
#

You can check asset dependencies in editor by using third party tools or using Asset database yourself.

round shale
#

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

digital kestrel
dusty zodiac
#

Remember anything in Resources is always included in builds

round shale
digital kestrel
# round shale

This one says that it's unused loaded. You could probably unload it with UnloadUnusedAssets.

round shale
digital kestrel
#

The profiler is showing the references at the time of the capture.

digital kestrel
round shale
#

hmm, now I could really do unload_unused_assets

#

weird

#

that's not always working for unused references

#

although it should

digital kestrel
# round shale weird

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.

round shale
#

"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

dusty zodiac
#

You should be able to Destroy() the asset to unload it

#

If you are very sure it's not in use

digital kestrel
#

Reading is a very powerfull tool

#

Read stuff, especially if it says stuff like "help"

round shale
#

the not trivial part was "because of its an asset"

#

and its not printed anywhere

#

I mean the reasoning

digital kestrel
#

This is irrelevant. It is your fault to make an assumption that GC unloads everything

round shale
#

that its not unloaded especially because of its an asset

digital kestrel
#

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.

round shale
#

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?

round shale
digital kestrel
#

If it's orphan(not referenced by anything), I think UnloadUnusedAssets should work.

round shale
#

english is not my native language, you know

digital kestrel
#

Destroy would probably destroy it(at least the native part) even if it's referenced.

round shale
#

and after the clear, should I wait one frame, or I could call UnloadUnusedAssets right away?

digital kestrel
#

It's probably fine to call it right away, though don't quote me on that.

round shale
#

and native memory is the unity assets?

#

and also the Unity objects?

digital kestrel
#

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).

dusty zodiac
#

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.

round shale
dusty zodiac
#

Texture2D tex = new Texture()

digital kestrel
#

Everything you reference in C# is a C# object. It's just that often it's just a wrapper of a C++ object.

round shale
#

should I regularly call this in every 5-10 min?

#

a lot of objects getting created during this time

digital kestrel
round shale
#

and a lot of objects gets destroyed

digital kestrel
#

What exactly is created?

#

And why?

round shale
#

prefabs

#

I mean prefab instances

digital kestrel
#

These don't need unload assets to be called to get cleared.

round shale
#

and mostly because it was not written in ECS

digital kestrel
#

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.🤔

round shale
#

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

digital kestrel
#

Well, then uncache them. Calling unload assets is not gonna help, as prefab instances are not assets.

round shale
#

well, currently I'm just doing a test to set cache counts to 1

#

and I check memory again

round shale
#

so we will see

round shale
#

@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

digital kestrel
digital kestrel
digital kestrel
round shale