Materials registered with the EntitiesGraphicsSystem at runtime break when maximising game view

Hello unity graphics people. A little bug report here:

At runtime, I duplicate a material, and register the new matierial with the entities graphics system (EntitiesGraphicsSystem.RegisterMaterial). I get back the material ID which I assign to the MaterialMeshInfo component. This all works correctly. But when I maximise the game view (by double clicking on the game tab), all the materials break and I’m left with the pink shader error. This does not happen when I use materials that are not registered with the EntitiesGrpahicsSystem at runtime.

See below for before and after maximising the game view. Note that, yes, those little pink things are in fact the same mesh with a broken shader (I do a lot of vertex and shader work to trace the voxels).

Small code snipped:

Material mat = new(material);
mat.SetBuffer(blocksBufferMatId, buffer);
materialMeshInfo.MaterialID = graphicsSystem.RegisterMaterial(mat);
// ...
// materialMeshInfo is set to the object being rendered, which then breaks when I maximise. It doesn't break if I just use a material that wasn't registered at runtime.

Working before maximising:

After maximising: (it works fine if I start with the game view already maximised)

Makes it very hard to work :(.

Which Entities Graphics package version are you running with? Is it 1.1+ or is it 1.0? MaterialMeshInfo received a few updates in 1.1, so maybe a bug slipped in at some point.

Although, since you need to maximize the window to trigger the bug it might have to do with the way the BatchRendererGroup is keeping material IDs up to date internally. It’s possible that maximizing the window has a few side effects which are not correctly handled.

In any case, could you please make a ticket with a repro project for this?

Hey there, I am using Entities Graphics 1.1. Made a bug report with a simple repro.
Bug ticket: IN-57937

If you do find any workarounds let me know.

Cheers.

There’s something I forgot to mention which seems relevant. If you un-maximise an already maximised game view, it does not break; it only breaks when maximising, not un-maximising. It also doesn’t care about window resizes.