diff --git a/Cargo.lock b/Cargo.lock index c2f5bc5a22a6..31fcee1e9fbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3911,6 +3911,7 @@ version = "0.6.0" dependencies = [ "anyhow", "cargo_metadata", + "re_error", "wasm-bindgen-cli-support", ] @@ -4167,6 +4168,7 @@ dependencies = [ "web-time", "wgpu", "wgpu-core", + "wgpu-hal", "winit", "zip", ] @@ -4374,6 +4376,7 @@ dependencies = [ "re_analytics", "re_build_build_info", "re_build_web_viewer", + "re_error", "re_log", "thiserror", "tokio", @@ -6009,9 +6012,9 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41af2ea7d87bd41ad0a37146252d5f7c26490209f47f544b2ee3b3ff34c7732e" +checksum = "74851c2c8e5d97652e74c241d41b0656b31c924a45dcdecde83975717362cfa4" dependencies = [ "android_system_properties", "arrayvec", diff --git a/crates/re_build_web_viewer/Cargo.toml b/crates/re_build_web_viewer/Cargo.toml index 9481cdc695f8..0dc924258c36 100644 --- a/crates/re_build_web_viewer/Cargo.toml +++ b/crates/re_build_web_viewer/Cargo.toml @@ -17,6 +17,8 @@ all-features = true [dependencies] +re_error.workspace = true + anyhow.workspace = true cargo_metadata = "0.15" wasm-bindgen-cli-support = "0.2.86" diff --git a/crates/re_build_web_viewer/src/lib.rs b/crates/re_build_web_viewer/src/lib.rs index ae0d8b4bbbb4..6d4db4a613e1 100644 --- a/crates/re_build_web_viewer/src/lib.rs +++ b/crates/re_build_web_viewer/src/lib.rs @@ -108,13 +108,27 @@ pub fn build(release: bool, webgpu: bool) -> anyhow::Result<()> { .join(format!("{crate_name}.wasm")); // wasm-bindgen --target web target_wasm_path --no-typescript --out-name target_name --out-dir build_dir - wasm_bindgen_cli_support::Bindgen::new() + if let Err(err) = wasm_bindgen_cli_support::Bindgen::new() .no_modules(true)? .input_path(target_wasm_path.as_str()) .typescript(false) .out_name(target_name.as_str()) .generate(build_dir.as_str()) - .context("Failed to run wasm-bindgen")?; + { + if err + .to_string() + .starts_with("cannot import from modules (`env`") + { + // Very common error: "cannot import from modules (`env`) with `--no-modules`" + anyhow::bail!( + "Failed to run wasm-bindgen: {err}. This is often because some dependency is calling `std::time::Instant::now()` or similar. You can try diagnosing this with:\n\ + wasm2wat {target_wasm_path} | rg '\"env\"'\n\ + wasm2wat {target_wasm_path} | rg 'call .now\\b' -B 20" + ); + } else { + return Err(err.context("Failed to run wasm-bindgen")); + } + } // -------------------------------------------------------------------------------- diff --git a/crates/re_build_web_viewer/src/main.rs b/crates/re_build_web_viewer/src/main.rs index d1cbbfb9c2df..8f887ab89bbf 100644 --- a/crates/re_build_web_viewer/src/main.rs +++ b/crates/re_build_web_viewer/src/main.rs @@ -34,7 +34,7 @@ fn main() -> ExitCode { }; if let Err(err) = re_build_web_viewer::build(release, webgpu) { - eprintln!("Failed to build web viewer: {err}"); + eprintln!("Failed to build web viewer: {}", re_error::format(err)); ExitCode::FAILURE } else { ExitCode::SUCCESS diff --git a/crates/re_error/src/lib.rs b/crates/re_error/src/lib.rs index e6f3e454a580..d3dc5b00a1c4 100644 --- a/crates/re_error/src/lib.rs +++ b/crates/re_error/src/lib.rs @@ -2,7 +2,7 @@ /// Format an error, including its chain of sources. /// -/// Always use this when displaying an error. +/// Always use this when displaying an error, especially `anyhow::Error`. pub fn format(error: impl AsRef) -> String { fn format_impl(error: &dyn std::error::Error) -> String { let mut string = error.to_string(); diff --git a/crates/re_renderer/Cargo.toml b/crates/re_renderer/Cargo.toml index 7f085fb27076..2cad0fadb3dd 100644 --- a/crates/re_renderer/Cargo.toml +++ b/crates/re_renderer/Cargo.toml @@ -66,6 +66,7 @@ static_assertions = "1.1" thiserror.workspace = true type-map = "0.5" wgpu.workspace = true +wgpu-hal = "0.16.1" # wgpu-hal 0.16.1 contains a critical fix for mobile devices: https://github.com/gfx-rs/wgpu/pull/3780 # optional arrow2 = { workspace = true, optional = true } diff --git a/crates/re_web_viewer_server/Cargo.toml b/crates/re_web_viewer_server/Cargo.toml index 709b50246304..357dc2cb689d 100644 --- a/crates/re_web_viewer_server/Cargo.toml +++ b/crates/re_web_viewer_server/Cargo.toml @@ -66,3 +66,4 @@ re_analytics = { workspace = true, optional = true } [build-dependencies] re_build_build_info.workspace = true re_build_web_viewer.workspace = true +re_error.workspace = true diff --git a/crates/re_web_viewer_server/build.rs b/crates/re_web_viewer_server/build.rs index 9183175f470a..97bde3a85bfa 100644 --- a/crates/re_web_viewer_server/build.rs +++ b/crates/re_web_viewer_server/build.rs @@ -45,6 +45,10 @@ fn main() { eprintln!("__ci feature detected: Skipping building of web viewer wasm."); } else { let release = std::env::var("PROFILE").unwrap() == "release"; - re_build_web_viewer::build(release, is_tracked_env_var_set("RERUN_BUILD_WEBGPU")).unwrap(); + if let Err(err) = + re_build_web_viewer::build(release, is_tracked_env_var_set("RERUN_BUILD_WEBGPU")) + { + panic!("Failed to build web viewer: {}", re_error::format(err)); + } } }