# How do I fix runtime "Failed to compile Material Instance" and "Building adjacency information"?

**URL:** <https://forums.unrealengine.com/t/how-do-i-fix-runtime-failed-to-compile-material-instance-and-building-adjacency-information/152839>\
**Category:** UDK Content Creation and Design\
**Tags:** unreal-engine\
**Created:** [October 28, 2020, 12:41pm UTC](https://forums.unrealengine.com/t/how-do-i-fix-runtime-failed-to-compile-material-instance-and-building-adjacency-information/152839 "2020-10-28T12:41:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathaniel3W](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nathaniel3W](https://forums.unrealengine.com/u/Nathaniel3W)\
**Post date:** [October 28, 2020, 12:41pm UTC](https://forums.unrealengine.com/t/how-do-i-fix-runtime-failed-to-compile-material-instance-and-building-adjacency-information/152839/1 "2020-10-28T12:41:14Z")

</div>

I’ve had many of these in my logs since day one when I load new levels:

```auto

Warning: Warning, Failed to compile Material Instance
Log: Building adjacency information for static mesh

```

I never really bothered with them because the game seemed to run fine. But now I think that the attempted runtime compiling of material instances is really hurting performance. Any idea why these are happening and how I can stop it?

---

<div class="post-metadata">

**Author:** ![Nathaniel3W](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nathaniel3W](https://forums.unrealengine.com/u/Nathaniel3W)\
**Post date:** [October 28, 2020, 1:20pm UTC](https://forums.unrealengine.com/t/how-do-i-fix-runtime-failed-to-compile-material-instance-and-building-adjacency-information/152839/2 "2020-10-28T13:20:35Z")

</div>

Yeah, it takes about 6 seconds each time the game tries to compile a material instance at runtime. I have a level that has 4 of these in them. It spends 24 seconds trying and failing to compile material instances, then it saves LocalShaderCache-PC-D3D-SM3.upk. How do I stop that?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f7db3d16](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f7db3d16](https://forums.unrealengine.com/u/anonymous_user_f7db3d16)\
**Post date:** [October 29, 2020, 8:18pm UTC](https://forums.unrealengine.com/t/how-do-i-fix-runtime-failed-to-compile-material-instance-and-building-adjacency-information/152839/3 "2020-10-29T20:18:21Z")

</div>

have you opened the editor and fully load all your games assets. That should compile all your material shaders for you and save them. Then the waiting should go away.

---

<div class="post-metadata">

**Author:** ![Nathaniel3W](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nathaniel3W](https://forums.unrealengine.com/u/Nathaniel3W)\
**Post date:** [October 30, 2020, 5:17am UTC](https://forums.unrealengine.com/t/how-do-i-fix-runtime-failed-to-compile-material-instance-and-building-adjacency-information/152839/4 "2020-10-30T05:17:05Z")

</div>

> [@](#):
>
> have you opened the editor and fully load all your games assets. That should compile all your material shaders for you and save them. Then the waiting should go away.

Yeah, I did that. I found out it actually leaves the same warning in the log when I try compiling the materials in the editor.

I’ve also spent the last two days fruitlessly chasing the warning deeper into C++. UMaterialInstance::CacheResourceShaders to UMaterial::CompileStaticPermutation to FMaterial::CacheShaders to FMaterial::Compile to FMaterial::CompileShaderMap to FMaterialShaderMap::Compile. I don’t know C++ very well, but what it seems like is happening right now is

```auto

UBOOL FMaterial::CompileShaderMap()
{
    return OutShaderMap.Compile(); // returns FALSE
}

UBOOL FMaterialShaderMap::Compile()
{
    // do stuff
    return TRUE;
}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f7db3d16](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f7db3d16](https://forums.unrealengine.com/u/anonymous_user_f7db3d16)\
**Post date:** [October 30, 2020, 6:15pm UTC](https://forums.unrealengine.com/t/how-do-i-fix-runtime-failed-to-compile-material-instance-and-building-adjacency-information/152839/5 "2020-10-30T18:15:00Z")

</div>

It sounds as if it is a material causing it. Does it say anything about certain materials? Can you watch the log or console as its compiling and try to see whats compiling and where and when it errors? maybe you can figure out what textures causing it. Sounds like a material is not made quite right.

---

<div class="post-metadata">

**Author:** ![Nathaniel3W](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nathaniel3W](https://forums.unrealengine.com/u/Nathaniel3W)\
**Post date:** [October 31, 2020, 9:05am UTC](https://forums.unrealengine.com/t/how-do-i-fix-runtime-failed-to-compile-material-instance-and-building-adjacency-information/152839/6 "2020-10-31T09:05:40Z")

</div>

Yes, there were some specific materials that were not compiling. I know which materials were having the problem, but I don’t know what the problem was. Eventually I removed some features of the materials and brought their instruction count down to about 210, whereas they had been around 240 before. Now they seem to be working. They don’t quite match the other materials now, but at least they are compiling and saving, so they don’t have to recompile every time the player loads a level.
