Closed eliotbo closed 1 year ago
Looks like a bug in our example code. We should amend it to implement one of the solutions in #1701 to avoid this type of non-deterministic behavior (and model the correct way to handle safe asset loading).
We should also probably hunt down that unwrap
and give it a more informative error (or better fallback behavior).
This is my first bug report ever. I am not sure if I provided enough information, or even if this bug is relevant at all... Let me know!
Looks like a real issue! The description was great; hopefully we can clean this up easily enough.
Shaders not being loaded yet should be handled properly internally by Bevy. Users shouldn't need to do manual tracking for that. If they do, this is an internal bug that must be fixed.
I can think of two solutions, one more desirable then the other. First, changing the asset loading for shaders to be synchronous, in that we stop everything until shaders are loaded, not the best. Second, similar to a version mentioned in another thread, we bail on a render pass as early as possible if it contains shaders that are unloaded and just let that pass finally occur once it is loaded, I think the second one is more feasible.
Yeah "not drawing" things without loaded shaders is the right way to go. I'll just handle this correctly in the new renderer once we re-add pipelines as assets.
@cart is this still valid? Your last comment says you were planning to handle this yourself :)
Yeah the new renderer properly "doesn't draw" in this case, as far as I know. And in the unlikely event that this is still a problem (we havent seen this pop up anywhere), the internals are so different now that we'd want a new issue anyway.
Bevy version
0.5.0
Operating system & version
Ubuntu 20.04
What you did
I cloned the bevy repo from Github. Enter "cargo run --example hot_shader_reloading" in a terminal. On my machine, the shaders sometimes don't have the time to load before they are used when instantiating a mesh.
What actually happened
This error occurs about once every 10 to 20 times that I try to run the example.
This issue becomes worst as more assets are loaded in a big project.
Temporary fix
Either add a sleep time after all the asset_server.load() calls (100 milliseconds worked) or verifying the loading states with AssetServer::get_load_state(handle)
Note
This is my first bug report ever. I am not sure if I provided enough information, or even if this bug is relevant at all... Let me know!