Skip to content

Commit 1389f05

Browse files
add comment explaining the use of now_or_never
1 parent 929e19d commit 1389f05

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

crates/bevy_render/src/render_resource/pipeline_cache.rs

+5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ impl ShaderCache {
135135
.push_error_scope(wgpu::ErrorFilter::Validation);
136136
let shader_module = render_device.create_shader_module(&module_descriptor);
137137
let error = render_device.wgpu_device().pop_error_scope();
138+
139+
// `now_or_never` will return Some if the future is ready and None otherwise.
140+
// On native platforms, wgpu will yield the error immediatly while on wasm it may take longer since the browser APIs are asynchronous.
141+
// So to keep the complexity of the ShaderCache low, we will only catch this error early on native platforms,
142+
// and on wasm the error will be handled by wgpu and crash the application.
138143
if let Some(Some(wgpu::Error::Validation { description, .. })) =
139144
futures_helper::now_or_never(error)
140145
{

0 commit comments

Comments
 (0)