Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wgpu-hal to 0.16.1 to fix mobile Safari #2296

Merged
merged 4 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
);
Comment on lines +123 to +127
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice, didn't know about wasm2wat (I use a VSCode plugin for that sort of thing so far)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What plugin?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the" webassembly extension can convert wasm files https://marketplace.visualstudio.com/items?itemName=dtsvet.vscode-wasm

} 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 @@ -67,6 +67,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));
}
}
}