Skip to content

Commit 7c47a89

Browse files
saran-tcopybara-github
authored andcommitted
Add asset file download indicator to the loading screen.
This provides visual feedback to the user while loading large models. PiperOrigin-RevId: 918708877 Change-Id: I77ea475cce6d9718e6cf8b33cb72b3f524a6ee63
1 parent 7174d33 commit 7c47a89

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/experimental/studio/emscripten.cc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,17 @@ class AssetRegistry {
7171
// The caller is responsible for freeing the buffer. Returns 0 on failure.
7272
EM_ASYNC_JS(int, FetchUrl,
7373
(const char* url, char** out_data, std::int32_t* out_size), {
74+
const urlStr = UTF8ToString(url);
75+
const filename = urlStr.split('/').pop() || urlStr;
76+
const dlEl = document.getElementById('loadingDownload');
77+
const dlFileEl = document.getElementById('loadingDownloadFile');
78+
if (dlEl) {
79+
dlEl.style.display = 'block';
80+
}
81+
if (dlFileEl) {
82+
dlFileEl.textContent = filename + '\u2026';
83+
}
7484
try {
75-
const urlStr = UTF8ToString(url);
7685
const response = await fetch(urlStr);
7786
if (!response.ok) {
7887
console.error('Fetch failed: ' + response.status + ' ' +
@@ -89,6 +98,13 @@ EM_ASYNC_JS(int, FetchUrl,
8998
} catch (e) {
9099
console.error('Fetch error:', e);
91100
return 0;
101+
} finally {
102+
if (dlEl) {
103+
dlEl.style.display = 'none';
104+
}
105+
if (dlFileEl) {
106+
dlFileEl.textContent = "";
107+
}
92108
}
93109
});
94110

src/experimental/studio/live.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
font-size: 14px;
2424
opacity: 0.7;
2525
}
26+
.loading-download {
27+
display: none;
28+
margin-top: 24px;
29+
opacity: 0.6;
30+
}
31+
.loading-download-label {
32+
font-size: 13px;
33+
}
34+
.loading-download-file {
35+
font-size: 13px;
36+
}
2637
#dropOverlay {
2738
position: fixed;
2839
top: 0;

src/experimental/studio/live.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
<div class="loading-container">
1111
<div class="loading-title">Loading model&hellip;</div>
1212
<div class="loading-subtitle">This may take a moment for large models.</div>
13+
<div id="loadingDownload" class="loading-download">
14+
<div class="loading-download-label">Downloading asset file</div>
15+
<div id="loadingDownloadFile" class="loading-download-file"></div>
16+
</div>
1317
</div>
1418
</div>
1519
<div id="dropOverlay">

0 commit comments

Comments
 (0)