Skip to content

Commit

Permalink
Update wgpu-hal to 0.16.1 to fix mobile Safari (#2296)
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
emilk committed Jun 15, 2023
1 parent beb6350 commit 1b73558
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 7 deletions.
7 changes: 5 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/re_build_web_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
18 changes: 16 additions & 2 deletions crates/re_build_web_viewer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}

// --------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion crates/re_build_web_viewer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/re_error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn std::error::Error>) -> String {
fn format_impl(error: &dyn std::error::Error) -> String {
let mut string = error.to_string();
Expand Down
1 change: 1 addition & 0 deletions crates/re_renderer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
1 change: 1 addition & 0 deletions crates/re_web_viewer_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion crates/re_web_viewer_server/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}

0 comments on commit 1b73558

Please sign in to comment.