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

Unify web_viewer/index.html and index_bundled.html #4720

Merged
merged 2 commits into from
Jan 8, 2024
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
2 changes: 1 addition & 1 deletion crates/re_web_viewer_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ include = [

# Matches the files in crates/re_web_viewer_server/src/lib.rs
"web_viewer/favicon.svg",
"web_viewer/index_bundled.html",
"web_viewer/index.html",
"web_viewer/re_viewer_bg.wasm",
"web_viewer/re_viewer.js",
"web_viewer/sw.js",
Expand Down
2 changes: 1 addition & 1 deletion crates/re_web_viewer_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod data {
#![allow(clippy::large_include_file)]

// If you add/remove/change the paths here, also update the include-list in `Cargo.toml`!
pub const INDEX_HTML: &[u8] = include_bytes!("../web_viewer/index_bundled.html");
pub const INDEX_HTML: &[u8] = include_bytes!("../web_viewer/index.html");
pub const FAVICON: &[u8] = include_bytes!("../web_viewer/favicon.svg");
pub const SW_JS: &[u8] = include_bytes!("../web_viewer/sw.js");
pub const VIEWER_JS: &[u8] = include_bytes!("../web_viewer/re_viewer.js");
Expand Down
84 changes: 45 additions & 39 deletions web_viewer/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<!-- The version of index.html that will be served by app.rerun.io -->
<!-- Rerun SDK-bundled web viewer. -->
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Expand Down Expand Up @@ -146,12 +146,6 @@
<!-- The Wasm code will resize the canvas dynamically -->
<canvas id="the_canvas_id" class="hidden"></canvas>

<script
src="https://fifteen-thirtyeight.rerun.io/script.js"
data-site="QKMCQFTQ"
defer
></script>

<script>
// The `--no-modules`-generated JS from `wasm-bindgen` attempts to use
// `WebAssembly.instantiateStreaming` to instantiate the wasm module,
Expand All @@ -169,6 +163,14 @@
<script src="re_viewer.js"></script>

<script>
if (window.location.hostname == "app.rerun.io") {
const script = document.createElement("script");
script.src = "https://fifteen-thirtyeight.rerun.io/script.js";
script.dataset.site = "QKMCQFTQ";
script.defer = true;
document.body.appendChild(script);
}

function show_center_html(html) {
center_text_elem = document.getElementById("center_text");
center_text_elem.innerHTML = html;
Expand Down Expand Up @@ -199,12 +201,13 @@
)
) {
show_center_html(`
<p>
Rerun is not yet supported on mobile browsers.
</p>
<p>
<a class="button" href="#" id="try_anyways">Try anyways</a>
</p>`);
<p>
Rerun is not yet supported on mobile browsers.
</p>
<p>
<a class="button" href="#" id="try_anyways">Try anyways</a>
</p>
`);
document
.querySelector("#try_anyways")
.addEventListener("click", function (event) {
Expand Down Expand Up @@ -312,13 +315,14 @@
"`navigator.gpu` is undefined. This indicates lack of WebGPU support.",
);
show_center_html(`
<p class="strong">
Missing WebGPU support.
</p>
<p class="subdued">
This version of Rerun requires WebGPU support which is not available in your browser.
Either try a different browser or use the WebGL version of Rerun.
</p>`);
<p class="strong">
Missing WebGPU support.
</p>
<p class="subdued">
This version of Rerun requires WebGPU support which is not available in your browser.
Either try a different browser or use the WebGL version of Rerun.
</p>
`);
return;
}

Expand All @@ -333,16 +337,17 @@
document.getElementById("the_canvas_id").remove();

show_center_html(`
<p class="strong">
Rerun has crashed.
</p>
<pre align="left">${handle.panic_message()}</pre>
<p>
See the console for details.
</p>
<p>
Reload the page to try again.
</p>`);
<p class="strong">
Rerun has crashed.
</p>
<pre align="left">${handle.panic_message()}</pre>
<p>
See the console for details.
</p>
<p>
Reload the page to try again.
</p>
`);
} else {
let delay_ms = 1000;
setTimeout(check_for_panic, delay_ms);
Expand Down Expand Up @@ -381,15 +386,16 @@

hide_canvas();
show_center_html(`
<p>
An error occurred during loading:
</p>
<p style="font-family:Courier New">
${error}
</p>
<p style="font-size:14px">
Make sure you use a modern browser with ${render_backend_name} and Wasm enabled.
</p>`);
<p>
An error occurred during loading:
</p>
<p style="font-family:Courier New">
${error}
</p>
<p style="font-size:14px">
Make sure you use a modern browser with ${render_backend_name} and Wasm enabled.
</p>
`);
}
</script>
</body>
Expand Down
Loading
Loading