Material Functions not staying compiled

I’ve come across a problem where all my materials that make use of material functions will recompile every time the editor is opened. The compiled versions don’t look like they are getting cached properly or something. They don’t actually recompile until I open the folder that they are located in. So if I open the editor and just play the map they used in it won’t display properly. Open the material folder and I get the recompiling shaders message, play again and the game displays correctly. This problem also affects packaging, the packaged game never gets the compiled version of the shader. This does not affect materials that don’t make use of material functions. I’ve tried deleting the cache and rebuilding it, but that didn’t work. I’m using 4.19 (Don’t want to update unless I absolutely have to).

Anyone know what might cause this?

I finally found the solution. I was looking at the caching settings and notice the setting deleteunused=true. It occurred to me that all the materials that were causing problems were applied to objects dynamically created at runtime. So I tested by putting a cube hidden below in the scene with one of the materials applied. Problem went away.