In Editor, when Animation is executed on a worker thread, there is an asset PostLoad event, which can be directly crashed

Playing In Editor, when Animation is executed on a worker thread, there is an asset PostLoad event, which can be directly crashed

[Attachment Removed]

Hi there,

​Based on the information you’ve provided so far, it’s hard to pinpoint the exact issue. Could you provide more context? Is this issue consistently reproducible? What are the approximate reproduction steps? The issue means that while executing animation tasks on a worker thread, an Asset PostLoad Event was triggered simultaneously, and this Asset PostLoad Event caused a crash. Did this Asset PostLoad Event access bone or animation data? If possible, could you provide the relevant dump information?

Thanks

[Attachment Removed]

Hi, I discussed this with relevant colleagues, and it does seem possible as I described above. There have been similar issues before, but the modules involved and the fixes applied were somewhat different from this one. I’ve put together a quick emergency fix here (https://github.com/EpicGames/UnrealEngine/commit/1e4f0658ebfb71d3be0fcae7752043aa48e290e4\) — feel free to take a look and see if it helps.

[Attachment Removed]

The asset in question could be any arbitrary mesh — it’s not tied to a specific one. The crash is low-probability and not consistently reproducible, which makes it difficult to provide exact repro steps. As for whether it’s related to bone or animation data access, I don’t believe that’s the relevant factor here. The issue occurs in the editor due to certain assets not yet being loaded. In PIE mode, when a character animation is playing and a mesh asset happens to be loaded for the first time, it triggers the PostLoad flow, which can race with animation tasks executing on worker threads and lead to the crash (check).

[Attachment Removed]

Hello, I think what you said is theoretically valid. I looked into this issue carefully. From the call stack, it appears that during the asset loading PostLoad phase, the main thread ‘conveniently’ executed an animation finish task, which called Blueprint code, and then hit the engine assertion that ‘Blueprint calls are forbidden during PostLoad’.

The steps look something like this:

  1. Project code initiates synchronous loading via FStreamableManager::RequestSyncLoadInternal. During this process, it enters the PostLoad phase, and the thread flag IsRoutingPostLoad is set to true.
  2. The loaded asset contains textures, and texture initialization needs to wait for the render thread. UTexture::PostLoad(Texture.cpp:1403) -> … -> UStreamableRenderAsset::WaitForPendingInitOrStreaming(StreamableRenderAsset.cpp:430)
  3. While the main thread is waiting for the render thread, it starts clearing tasks from its own task queue. This task happens to coincide with an animation finish task (FParallelAnimationCompletionTask), and the animation finish task then calls BlueprintPostEvaluateAnimation.
  4. So it violated the engine’s rule: calling Blueprint is forbidden during PostLoad, and an assertion failure was triggered.

To some extent, this should make sense, but if we had some related dumps or logs, we could better confirm the issue.

I’ll discuss this issue with relevant colleagues and get back to you once there’s an update. I think the project team could try changing RequestSyncLoad to async loading, or preloading the relevant meshes in advance. That might help avoid this issue to some extent. If you have any better ideas at the moment, we can continue discussing them as well.

[Attachment Removed]

Thanks a lot!

[Attachment Removed]