bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Fix infinite asset preparation due to undrained AssetEvent events

Open brianreavis opened this issue 1 year ago • 2 comments
trafficstars

Objective

After #10520, I was experiencing seriously degraded performance that ended up being due to never-drained AssetEvent events causing havoc inside extract_render_asset::<A>. The same events being read over and over again meant the same assets were being prepared every frame for eternity. For what it's worth, I was noticing this on a static scene about every 3rd or so time running my project.

  • References #10520
  • Fixes #11240

Why these events aren't sometimes drained between frames is beyond me and perhaps worthy of another investigation, but the approach in this PR effectively restores the original cached EventReader behavior (which fixes it).

Solution

I followed the CachedSystemState example to make sure that the EventReader state is cached between frames like it used to be when it was an argument of extract_render_asset::<A>.

brianreavis avatar Jan 17 '24 08:01 brianreavis

this PR fixes https://github.com/bevyengine/bevy/issues/11240

mockersf avatar Jan 17 '24 12:01 mockersf

I was seeing significant memory usage increases (VRAM and CPU), as well as significantly longer load times when testing loading large scenes on main, and this fixes them.

Elabajaba avatar Jan 26 '24 21:01 Elabajaba

Merging now to help y'all diagnose other perf issues more easily.

alice-i-cecile avatar Jan 27 '24 03:01 alice-i-cecile