Skip to content

Commit

Permalink
Show a warning by default on mobile browsers (#1670)
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs authored Mar 22, 2023
1 parent 4b52ef0 commit 2e64016
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 14 deletions.
50 changes: 43 additions & 7 deletions web_viewer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
text-align: center;
}

a {
display: inline-block;
background: white;
color: black;
padding: .75rem 1rem;
border-radius: 8px;
text-decoration: none;
font-weight: 500;
}

/* ---------------------------------------------- */
/* Loading animation from https://loading.io/css/ */
.lds-dual-ring {
Expand Down Expand Up @@ -99,6 +109,14 @@
<body>
<!-- The Wasm code will resize the canvas dynamically -->
<canvas id="the_canvas_id"></canvas>
<div class="centered" id="mobile_text" style="visibility:hidden">
<p style="font-size:16px">
Rerun is not yet supported on mobile browsers.
</p>
<p style="font-size:16px">
<a href="#" id="try_anyways">Try anyways</a>
</p>
</div>
<div class="centered" id="center_text">
<p style="font-size:16px">
Loading…
Expand All @@ -123,13 +141,31 @@
<script src="re_viewer.js"></script>

<script>
// We'll defer our execution until the wasm is ready to go.
// Here we tell bindgen the path to the wasm file so it can start
// initialization and return to us a promise when it's done.
console.debug("loading wasm…");
wasm_bindgen("./re_viewer_bg.wasm")
.then(on_wasm_loaded)
.catch(on_wasm_error);
// On mobile platforms show a warning, but provide a link to try anyways
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
document.querySelector('#center_text').style.visibility = 'hidden';
document.querySelector('#mobile_text').style.visibility = 'visible';
document.querySelector('#try_anyways').addEventListener('click', function (event) {
event.preventDefault();
document.querySelector('#center_text').style.visibility = 'visible';
document.querySelector('#mobile_text').style.visibility = 'hidden';
load_wasm();
});
} else {
load_wasm();
}

function load_wasm() {
// We'll defer our execution until the wasm is ready to go.
// Here we tell bindgen the path to the wasm file so it can start
// initialization and return to us a promise when it's done.

console.debug("loading wasm…");
wasm_bindgen("./re_viewer_bg.wasm")
.then(on_wasm_loaded)
.catch(on_wasm_error);
}


function on_wasm_loaded() {
console.debug("wasm loaded. starting app…");
Expand Down
49 changes: 42 additions & 7 deletions web_viewer/index_bundled.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
text-align: center;
}

a {
display: inline-block;
background: white;
color: black;
padding: .75rem 1rem;
border-radius: 8px;
text-decoration: none;
font-weight: 500;
}

/* ---------------------------------------------- */
/* Loading animation from https://loading.io/css/ */
.lds-dual-ring {
Expand Down Expand Up @@ -99,6 +109,14 @@
<body>
<!-- The Wasm code will resize the canvas dynamically -->
<canvas id="the_canvas_id"></canvas>
<div class="centered" id="mobile_text" style="visibility:hidden">
<p style="font-size:16px">
Rerun is not yet supported on mobile browsers.
</p>
<p style="font-size:16px">
<a href="#" id="try_anyways">Try anyways</a>
</p>
</div>
<div class="centered" id="center_text">
<p style="font-size:16px">
Loading…
Expand All @@ -123,13 +141,30 @@
<script src="re_viewer.js"></script>

<script>
// We'll defer our execution until the wasm is ready to go.
// Here we tell bindgen the path to the wasm file so it can start
// initialization and return to us a promise when it's done.
console.debug("loading wasm…");
wasm_bindgen("./re_viewer_bg.wasm")
.then(on_wasm_loaded)
.catch(on_wasm_error);
// On mobile platforms show a warning, but provide a link to try anyways
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
document.querySelector('#center_text').style.visibility = 'hidden';
document.querySelector('#mobile_text').style.visibility = 'visible';
document.querySelector('#try_anyways').addEventListener('click', function (event) {
event.preventDefault();
document.querySelector('#center_text').style.visibility = 'visible';
document.querySelector('#mobile_text').style.visibility = 'hidden';
load_wasm();
});
} else {
load_wasm();
}

function load_wasm() {
// We'll defer our execution until the wasm is ready to go.
// Here we tell bindgen the path to the wasm file so it can start
// initialization and return to us a promise when it's done.

console.debug("loading wasm…");
wasm_bindgen("./re_viewer_bg.wasm")
.then(on_wasm_loaded)
.catch(on_wasm_error);
}

function on_wasm_loaded() {
console.debug("wasm loaded. starting app…");
Expand Down

1 comment on commit 2e64016

@github-actions
Copy link

Choose a reason for hiding this comment

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

Rust Benchmark

Benchmark suite Current: 2e64016 Previous: 4b52ef0 Ratio
datastore/insert/batch/rects/insert 569900 ns/iter (± 2358) 556348 ns/iter (± 2300) 1.02
datastore/latest_at/batch/rects/query 1867 ns/iter (± 7) 1847 ns/iter (± 7) 1.01
datastore/latest_at/missing_components/primary 289 ns/iter (± 0) 289 ns/iter (± 0) 1
datastore/latest_at/missing_components/secondaries 448 ns/iter (± 1) 441 ns/iter (± 0) 1.02
datastore/range/batch/rects/query 154597 ns/iter (± 753) 149349 ns/iter (± 553) 1.04
mono_points_arrow/generate_message_bundles 49779355 ns/iter (± 1351686) 50755959 ns/iter (± 743711) 0.98
mono_points_arrow/generate_messages 136042834 ns/iter (± 1401120) 136216051 ns/iter (± 1225649) 1.00
mono_points_arrow/encode_log_msg 164969686 ns/iter (± 702847) 170679538 ns/iter (± 1566680) 0.97
mono_points_arrow/encode_total 355563422 ns/iter (± 1987416) 354764090 ns/iter (± 1658470) 1.00
mono_points_arrow/decode_log_msg 189280399 ns/iter (± 1120549) 185870469 ns/iter (± 1008578) 1.02
mono_points_arrow/decode_message_bundles 72421268 ns/iter (± 1577651) 72707952 ns/iter (± 901084) 1.00
mono_points_arrow/decode_total 259023617 ns/iter (± 2219112) 258644273 ns/iter (± 2153878) 1.00
batch_points_arrow/generate_message_bundles 337325 ns/iter (± 653) 337670 ns/iter (± 981) 1.00
batch_points_arrow/generate_messages 6319 ns/iter (± 16) 6313 ns/iter (± 11) 1.00
batch_points_arrow/encode_log_msg 457993 ns/iter (± 2748) 373602 ns/iter (± 1587) 1.23
batch_points_arrow/encode_total 727078 ns/iter (± 2313) 732660 ns/iter (± 3308) 0.99
batch_points_arrow/decode_log_msg 346901 ns/iter (± 638) 350643 ns/iter (± 982) 0.99
batch_points_arrow/decode_message_bundles 2051 ns/iter (± 2) 2048 ns/iter (± 9) 1.00
batch_points_arrow/decode_total 349640 ns/iter (± 466) 353940 ns/iter (± 1510) 0.99
arrow_mono_points/insert 6859372698 ns/iter (± 24351271) 6922627807 ns/iter (± 55335427) 0.99
arrow_mono_points/query 1765899 ns/iter (± 13401) 1834682 ns/iter (± 15920) 0.96
arrow_batch_points/insert 2600994 ns/iter (± 36458) 2771311 ns/iter (± 51363) 0.94
arrow_batch_points/query 16199 ns/iter (± 73) 16222 ns/iter (± 18) 1.00
arrow_batch_vecs/insert 41724 ns/iter (± 71) 42108 ns/iter (± 390) 0.99
arrow_batch_vecs/query 388657 ns/iter (± 290) 389061 ns/iter (± 606) 1.00
tuid/Tuid::random 34 ns/iter (± 0) 35 ns/iter (± 0) 0.97

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.