What causes materials on a scene proxy to disappear?

I am in the process of removing the bugs from my new Destructible Mesh Editor. The most pressing one is that sometimes the materials disappear from my shattered mesh. This generally only happens when there’s more than one.

You can see the effect in this video.

Now, that is rendered by a scene proxy, descended from FSkeletalMeshSceneProxy.

Here’s the definition:

class FDestructibleMeshChunkSceneProxy : public FSkeletalMeshSceneProxy
{
public:
	FDestructibleMeshChunkSceneProxy(class UDestructiblePreviewComponent *comp);
	virtual ~FDestructibleMeshChunkSceneProxy();

	virtual HHitProxy* CreateHitProxies(UPrimitiveComponent* Component, TArray<TRefCountPtr<HHitProxy> >& OutHitProxies) override;

	virtual void GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const override;
	
private:
	bool IsChunkSelected(FBoneIndexType BoneIndex) const;
	
	UDestructiblePreviewComponent *PreviewComp;

	/** Hit Proxy for each bone. */
	TMap<uint8, class HDMEChunk*> HitProxiesByBone;

	

};

And the relevant method:

void FDestructibleMeshChunkSceneProxy::GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const
{
	if (!MeshObject)
	{
		return;
	}

	const int32 LODIndex = MeshObject->GetLOD();
	check(LODIndex < SkelMeshResource->LODModels.Num());
	const FStaticLODModel& LODModel = SkelMeshResource->LODModels[LODIndex];

	const FLODSectionElements& LODSection = LODSections[LODIndex];
	check(LODSection.SectionElements.Num() == LODModel.Sections.Num());

	int32 SectionIndex = 1;
	for (int32 SectionIndex=0;SectionIndex<LODModel.Sections.Num();SectionIndex++)
	{
		FSkelMeshSection Section = LODModel.Sections[SectionIndex];
		const FSkelMeshChunk& Chunk = LODModel.Chunks[Section.ChunkIndex];

		const FSectionElementInfo& SectionElementInfo = LODSection.SectionElements[SectionIndex];

		for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
		{
			if (VisibilityMap && (1 << ViewIndex))
			{

				for (FSkelMeshFaceGroup fg : Chunk.FaceGroups)
				{
					FBoneIndexType BoneIndex = Chunk.BoneMap[fg.Bone];

					bool bIsSelected = IsChunkSelected(BoneIndex);

					FMeshBatch& Mesh = Collector.AllocateMesh();
					Mesh.DynamicVertexData = NULL;
					Mesh.UseDynamicData = false;
					Mesh.LCI = NULL;
					Mesh.bWireframe |= bForceWireframe;
					Mesh.Type = PT_TriangleList;
					Mesh.VertexFactory = MeshObject->GetVertexFactory(LODIndex, Section.ChunkIndex);
					Mesh.bSelectable = IsSelectable();

					if (bIsSelected)
					{
						auto SelectionOverrideProxy = new FOverrideSelectionColorMaterialRenderProxy(
							SectionElementInfo.Material->GetRenderProxy(true, IsHovered()),
							GetSelectionColor(GEngine->GetSelectedMaterialColor(), true, IsHovered())
							);

						Collector.RegisterOneFrameMaterialProxy(SelectionOverrideProxy);

						Mesh.MaterialRenderProxy = SelectionOverrideProxy;
					} else
					{
						Mesh.MaterialRenderProxy = SectionElementInfo.Material->GetRenderProxy(false, IsHovered());
					}

					Mesh.BatchHitProxyId = HitProxiesByBone.Contains(BoneIndex) ? HitProxiesByBone[BoneIndex]->Id : FHitProxyId();

					Mesh.ReverseCulling = IsLocalToWorldDeterminantNegative();
					Mesh.CastShadow = false;

					Mesh.bCanApplyViewModeOverrides = true;
					Mesh.bUseWireframeSelectionColoring = IsSelected();

					FMeshBatchElement& BatchElement = Mesh.Elements[0];

					BatchElement.FirstIndex = fg.StartIndexOffset+Section.BaseIndex;
					BatchElement.IndexBuffer = LODModel.MultiSizeIndexContainer.GetIndexBuffer();

					BatchElement.MinVertexIndex = Chunk.BaseVertexIndex;
					BatchElement.MaxVertexIndex = LODModel.NumVertices - 1;

					BatchElement.UserIndex = -1;//MeshObject->GPUSkinCacheKeys[Section.ChunkIndex];
					
					BatchElement.NumPrimitives = fg.NumTriangles;

					BatchElement.PrimitiveUniformBufferResource = &GetUniformBuffer();

					const bool bRequiresAdjacencyInformation = RequiresAdjacencyInformation(SectionElementInfo.Material, Mesh.VertexFactory->GetType(), ViewFamily.GetFeatureLevel());

					check(Section.TriangleSorting != TRISORT_CustomLeftRight);

					Collector.AddMesh(ViewIndex, Mesh);
				}

			} else
			{
				UE_LOG(LogTemp, Log, TEXT("Skipped an invisible piece"));
			}
		}
	}


}

The same effect happens in the editor, even though that uses an entirely different scene proxy (the original, Epic one, untouched.) The difference is that it flickers there.

So, questions:

What would be causing this effect? Material getting garbage collected? Something else?

How would I debug this?

I had a somewhat similar problem were I was drawing a custom mesh with a scene proxy used in a mesh component, the mesh component had a material property used for rendering. Even when instanced the mesh would only be rendered when overriding these two methods of the mesh component.

virtual int32 GetNumMaterials() const override;
virtual UMaterialInterface* GetMaterial(int32 ElementIndex) const override;