Files
EVEngine/platform/webgpu/shell.html
T
西风逍遥游 b3e5cfc5b2 fix(webgpu): build config, module init, and loading overlay
- Link eve to eve.html via --shell-file so the shell template is actually applied and regenerated on every build; track the shell as a link dependency.
- Keep C++ exception catching enabled under ASYNCIFY so expose() failures abort cleanly instead of asserting on __cxa_throw.
- ModuleManager::exposeVM no longer find()+catch for the eve table: Runtime::initialize() guarantees expose() runs once, and ASYNCIFY-wrapped frames can drop the catch and leak NotFoundException.
- Expose window.hideEVELoading and call it on the first presented frame so the shell's loading overlay is dismissed.
- FileWatch.h includes common/config.h so EVENGINE_WEBGPU is defined before the Poco guard.
2026-08-15 17:06:33 +08:00

101 lines
3.1 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>EVEngine — WebGPU</title>
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #101014;
font-family: system-ui, sans-serif;
}
#loading {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #c8c8d0;
font-size: 14px;
letter-spacing: 0.05em;
z-index: 10;
}
#loading .spinner {
width: 36px;
height: 36px;
border: 3px solid #2a2a34;
border-top-color: #5aa9ff;
border-radius: 50%;
animation: spin 0.9s linear infinite;
margin-bottom: 12px;
}
#loading.failed { color: #ff6b6b; }
@keyframes spin { to { transform: rotate(360deg); } }
canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
</style>
</head>
<body>
<div id="loading">
<div class="spinner"></div>
<span id="status">Loading EVEngine…</span>
</div>
<canvas id="canvas" width="800" height="600"></canvas>
<script>
var Module = {
// PROXY_TO_PTHREAD runs main() on a worker with no DOM; Emscripten
// transfers this canvas to the worker as an OffscreenCanvas when
// OFFSCREENCANVAS_SUPPORT is enabled (OFFSCREENCANVASES_TO_PTHREAD=#canvas).
canvas: document.getElementById('canvas'),
locateFile: function (path) {
// Worker scripts (pthreads) resolve next to the module.
return path;
},
onRuntimeInitialized: function () {
var st = document.getElementById('status');
if (st) st.textContent = 'Engine ready';
}
};
// The engine hides the loading overlay after the first composited frame;
// this is the hook it calls (guarded, in case the page is reused).
window.hideEVELoading = function () {
var el = document.getElementById('loading');
if (el) el.style.display = 'none';
};
// Diagnostic status line: reports WebGPU + SharedArrayBuffer availability
// so engine init failures are visible without DevTools.
(function () {
var st = document.getElementById('status');
var lines = ['crossOriginIsolated=' + (crossOriginIsolated ? 'yes' : 'no')];
if (navigator.gpu) {
navigator.gpu.requestAdapter().then(function (a) {
if (a) {
var info = (a.info && (a.info.vendor || a.info.architecture)) || 'ok';
lines.push('webgpuAdapter=' + JSON.stringify(info));
} else {
lines.push('webgpuAdapter=null');
}
if (st) st.textContent = lines.join(' | ');
}).catch(function (e) { lines.push('adapterError=' + e.message); if (st) st.textContent = lines.join(' | '); });
} else {
lines.push('webgpu=unsupported');
if (st) st.textContent = lines.join(' | ');
}
})();
</script>
{{{ SCRIPT }}}
</body>
</html>