Unreal crashes when loading another level if a substance factory is referenced in a blueprint

Hey guys,
I’m working on a project where I create dynamic materials from a Substance Factory and make the exposed parameters accessible via Blueprint variables. For this I have built a function that I can use either in the construction script or the event graph to set the materials.

The problem is that as soon as I reference the factory in the blueprint and load another level, Unreal crashes. Depending on how complex the material is, Unreal already crashes when compiling the blueprint.

I have built an extra scene to replicate this problem and can provide it if needed.

The log indicates that the garbage collection cannot clean everything when loading the new level, because the blueprint holds a reference to the factory. Is this a known problem and if so, are there best practices for creating dynamic materials and referencing substance files?

UE4 4.27.2

Substance Plugin 4.27.0.1

SubstDes_DynMat_Test.log (100.9 KB)

Excerpt from the log:

[2021.12.22-10.28.40:673][361]LightingResults: New page: Lighting Build
[2021.12.22-10.28.40:677][361]LogUObjectHash: Compacting FUObjectHashTables data took 0.72ms
[2021.12.22-10.28.40:713][361]LogReferenceChain: (standalone) SubstanceInstanceFactory /Game/Materials/Plastic_ClearAndNoise/Plastic_ClearAndNoise.Plastic_ClearAndNoise->mGraphInstances
[2021.12.22-10.28.40:713][361]LogReferenceChain: SubstanceGraphInstance /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel.BP_Cube2.Plastic_Graph_INST->Outer
[2021.12.22-10.28.40:713][361]LogReferenceChain: BP_Cube_C /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel.BP_Cube2->Outer
[2021.12.22-10.28.40:713][361]LogReferenceChain: Level /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel->Outer
[2021.12.22-10.28.40:713][361]LogReferenceChain: World /Game/Maps/DynamicMats_Main.DynamicMats_Main
[2021.12.22-10.28.40:713][361]LogReferenceChain:
[2021.12.22-10.28.40:713][361]LogEditorServer: Error: Old world /Game/Maps/DynamicMats_Main.DynamicMats_Main not cleaned up by garbage collection while loading new map! Referenced by:
(standalone) SubstanceInstanceFactory /Game/Materials/Plastic_ClearAndNoise/Plastic_ClearAndNoise.Plastic_ClearAndNoise->mGraphInstances
SubstanceGraphInstance /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel.BP_Cube2.Plastic_Graph_INST->Outer
BP_Cube_C /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel.BP_Cube2->Outer
Level /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel->Outer
World /Game/Maps/DynamicMats_Main.DynamicMats_Main
[2021.12.22-10.28.40:749][361]LogReferenceChain: (standalone) SubstanceInstanceFactory /Game/Materials/Plastic_ClearAndNoise/Plastic_ClearAndNoise.Plastic_ClearAndNoise->mGraphInstances
[2021.12.22-10.28.40:749][361]LogReferenceChain: SubstanceGraphInstance /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel.BP_Cube2.Plastic_Graph_INST->Outer
[2021.12.22-10.28.40:749][361]LogReferenceChain: BP_Cube_C /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel.BP_Cube2->Outer
[2021.12.22-10.28.40:749][361]LogReferenceChain: Level /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel->Outer
[2021.12.22-10.28.40:749][361]LogReferenceChain: World /Game/Maps/DynamicMats_Main.DynamicMats_Main->Outer
[2021.12.22-10.28.40:749][361]LogReferenceChain: Package /Game/Maps/DynamicMats_Main
[2021.12.22-10.28.40:749][361]LogReferenceChain:
[2021.12.22-10.28.40:749][361]LogEditorServer: Error: Old level package /Game/Maps/DynamicMats_Main not cleaned up by garbage collection while loading new map! Referenced by:
(standalone) SubstanceInstanceFactory /Game/Materials/Plastic_ClearAndNoise/Plastic_ClearAndNoise.Plastic_ClearAndNoise->mGraphInstances
SubstanceGraphInstance /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel.BP_Cube2.Plastic_Graph_INST->Outer
BP_Cube_C /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel.BP_Cube2->Outer
Level /Game/Maps/DynamicMats_Main.DynamicMats_Main:PersistentLevel->Outer
World /Game/Maps/DynamicMats_Main.DynamicMats_Main->Outer
Package /Game/Maps/DynamicMats_Main