Skip to content

Commit 1b73558

Browse files
committed
Update wgpu-hal to 0.16.1 to fix mobile Safari (#2296)
The release contains gfx-rs/wgpu#3780 Closes #2032 ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) <!-- This line will get updated when the PR build summary job finishes. --> PR Build Summary: https://build.rerun.io/pr/2296 <!-- pr-link-docs:start --> Docs preview: https://rerun.io/preview/9ebf96a/docs <!-- pr-link-docs:end -->
1 parent beb6350 commit 1b73558

File tree

8 files changed

+32
-7
lines changed

8 files changed

+32
-7
lines changed

Cargo.lock

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/re_build_web_viewer/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ all-features = true
1717

1818

1919
[dependencies]
20+
re_error.workspace = true
21+
2022
anyhow.workspace = true
2123
cargo_metadata = "0.15"
2224
wasm-bindgen-cli-support = "0.2.86"

crates/re_build_web_viewer/src/lib.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,27 @@ pub fn build(release: bool, webgpu: bool) -> anyhow::Result<()> {
108108
.join(format!("{crate_name}.wasm"));
109109

110110
// wasm-bindgen --target web target_wasm_path --no-typescript --out-name target_name --out-dir build_dir
111-
wasm_bindgen_cli_support::Bindgen::new()
111+
if let Err(err) = wasm_bindgen_cli_support::Bindgen::new()
112112
.no_modules(true)?
113113
.input_path(target_wasm_path.as_str())
114114
.typescript(false)
115115
.out_name(target_name.as_str())
116116
.generate(build_dir.as_str())
117-
.context("Failed to run wasm-bindgen")?;
117+
{
118+
if err
119+
.to_string()
120+
.starts_with("cannot import from modules (`env`")
121+
{
122+
// Very common error: "cannot import from modules (`env`) with `--no-modules`"
123+
anyhow::bail!(
124+
"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\
125+
wasm2wat {target_wasm_path} | rg '\"env\"'\n\
126+
wasm2wat {target_wasm_path} | rg 'call .now\\b' -B 20"
127+
);
128+
} else {
129+
return Err(err.context("Failed to run wasm-bindgen"));
130+
}
131+
}
118132

119133
// --------------------------------------------------------------------------------
120134

crates/re_build_web_viewer/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn main() -> ExitCode {
3434
};
3535

3636
if let Err(err) = re_build_web_viewer::build(release, webgpu) {
37-
eprintln!("Failed to build web viewer: {err}");
37+
eprintln!("Failed to build web viewer: {}", re_error::format(err));
3838
ExitCode::FAILURE
3939
} else {
4040
ExitCode::SUCCESS

crates/re_error/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
/// Format an error, including its chain of sources.
44
///
5-
/// Always use this when displaying an error.
5+
/// Always use this when displaying an error, especially `anyhow::Error`.
66
pub fn format(error: impl AsRef<dyn std::error::Error>) -> String {
77
fn format_impl(error: &dyn std::error::Error) -> String {
88
let mut string = error.to_string();

crates/re_renderer/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static_assertions = "1.1"
6666
thiserror.workspace = true
6767
type-map = "0.5"
6868
wgpu.workspace = true
69+
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
6970

7071
# optional
7172
arrow2 = { workspace = true, optional = true }

crates/re_web_viewer_server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ re_analytics = { workspace = true, optional = true }
6666
[build-dependencies]
6767
re_build_build_info.workspace = true
6868
re_build_web_viewer.workspace = true
69+
re_error.workspace = true

crates/re_web_viewer_server/build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ fn main() {
4545
eprintln!("__ci feature detected: Skipping building of web viewer wasm.");
4646
} else {
4747
let release = std::env::var("PROFILE").unwrap() == "release";
48-
re_build_web_viewer::build(release, is_tracked_env_var_set("RERUN_BUILD_WEBGPU")).unwrap();
48+
if let Err(err) =
49+
re_build_web_viewer::build(release, is_tracked_env_var_set("RERUN_BUILD_WEBGPU"))
50+
{
51+
panic!("Failed to build web viewer: {}", re_error::format(err));
52+
}
4953
}
5054
}

0 commit comments

Comments
 (0)