Error in Computer Shader "Accessing the RHI resource at this time is not allowed" (5.4.2)

Did moving the allocation above the loop fix the crash? Does it work as intended?