Vertex Factory missing: crash check(VFType) in Game

I quick fixed the problem, just posting here for anyone who could have the same issue, or if someone knows some magic to better solve this problem…

So, I have a custom FVertexFactory (VF) in my Plugin. I recently commented out all the code using it. And now Game Build crashes at startup in:

Source\Runtime\Engine\Private\Materials\MaterialShader.cpp line 1698 : check(VFType)

I investigated with UE4 build from github (Debug Game with Launcher, Visual Studio says “source file not available”), and in Debug Game Build I found that my VF is not in the FVertexFactoryType::GetTypeList().

I deduced it’s probably because the compiler optimized out my (unused) VF in Game Build!!!

So, in UE4Editor it Cooks and Serialize my VF in the Materials, but then in Game Build it unserizialize but cannot find the code/type of my VF.

Quick fix solution: I #if 0 my VF… re-build everything and re-cooked.

Is there a better way to avoid the compiler to optimize out my VF ?

Hello, I appear to be having the same issue but for a used VF. I’m getting a serialize error crash reported from MaterialShader.cpp.

An idea what I would need to do to fix?

I face the same problem when I write my uplugin file like this:

 "Modules": [
    {
      "Name": "MyShader",
      "Type": "Developer",
      "LoadingPhase": "PostConfigInit"
    },

then I change it to the following:

  "Modules": [
    {
      "Name": "MyShader",
      "Type": "Runtime",
      "LoadingPhase": "PostConfigInit"
    },

The problem is gone!

You need to check that your plugin is correctly load in Game Build. Since plugin is ignored in Game Build when Type=Developer so I meet this problem