With the right steps, Undo in Material Editor crashes Unreal Engine 5.5. Is that a known issue? Looking at 5.6, it seems like it is still having the same issue.
I was working on a crash for Material Editor. What we found is that Undo commends will call itself on too many material editors.
Open a Material and 2 Material functions, making sure the material is using one of the material functions, and the material function is using another material function.
Now we have:
Material A - using Material Function B
Material Function B - using Material Function C
Material Function C
Open the Unreal Editor with only A and B opened in the background. Modifying B by removing function call for Material Function C. Duplicate a node, then undo the duplication will leads to crash.
What happened is when Node for C got removed, they are marked as garbage. Unless GC is called, it will stay there as we can still call undo to bring it back.
However, since undo was called on A as well, FMaterialEditor::PostUndo calls UpdateOriginalMaterial and tried to recompile B, which calls garbage collection and cause the expressions in B to be set to null. Later, B will crash in its own FMaterialEditor::PostUndo as it did not expect it to be null.
If only B is being worked on, does A need to be recompiled at that moment? It is not in focus and was just in background. FMaterialEditor::MatchesContext should catch it, but it doesn’t seem to care the context. I added a check to make sure we are updating only the editor relevant to the material that is being worked on and was able to stop it.
For this particular crash, another issue being it is compiling/updating every material window existing. For artist who is working on shaders, it is common and easy to have a lot of material editor opening at the same time. If every undo means all of them will recompile, it makes Unreal pretty slow. I was wondering if we have done some engine changes that caused this, but all the code there seems untouched.
Do we know if this is something that is fixed for 5.6? Any intel is appreciated.