Issue with Distributed Engine Binary: "No valid session manager" error despite successful wasm loading
Hi 8th Wall Team, I am integrated the Distributed Engine Binary into a self-hosted Three.js project. My package contains xr.js, xr-slam.js, and the resources/ folder (with media-worker.js). Environment: Engine Version: 0.0.0.0s (Standalone Binary) Framework: Vanilla Three.js (No A-Frame) Files: xr.js, xr-slam.js, media-worker.js The Problem: Whenever I call XR8.run(), the camera light flashes briefly and then turns off. The console consistently throws the following error: [XR] Error: Error: No valid session manager to handle this session. Best regards,
My code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>8th Wall 核心版 - 硬件激活方案</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="./libs/xr.js"></script>
<style>
body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #000; font-family: sans-serif; }
#camera-canvas { width: 100vw; height: 100vh; display: block; position: fixed; top: 0; left: 0; }
#overlay {
position: absolute; z-index: 100; width: 100%; height: 100%;
background: rgba(0,0,0,0.8); color: white;
display: flex; flex-direction: column; align-items: center; justify-content: center;
cursor: pointer; text-align: center;
}
.loading-spinner {
width: 40px; height: 40px; border: 4px solid #f3f3f3;
border-top: 4px solid #3498db; border-radius: 50%;
animation: spin 1s linear infinite; margin-bottom: 20px; display: none;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
</style>
</head>
<body>
<div id="overlay" onclick="handleStart()">
<div id="spinner" class="loading-spinner"></div>
<h2 id="btn-text">点击开启摄像头</h2>
<p id="status-text" style="color: #aaa; font-size: 14px; margin-top: 10px;">
提示:请确保在 HTTPS 环境或 Localhost 下运行
</p>
</div>
<canvas id="camera-canvas"></canvas>
<script>
let scene, camera, renderer, cube;
let isStarted = false;
const initThreeScene = (canvas) => {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.01, 1000);
renderer = new THREE.WebGLRenderer({
canvas: canvas,
context: canvas.getContext('webgl') || canvas.getContext('experimental-webgl'),
alpha: true,
antialias: true
});
renderer.autoClear = false;
renderer.setSize(window.innerWidth, window.innerHeight);
const geometry = new THREE.BoxGeometry(0.2, 0.2, 0.2);
const material = new THREE.MeshNormalMaterial();
cube = new THREE.Mesh(geometry, material);
cube.position.set(0, 0, -1);
scene.add(cube);
console.log("Three.js finish");
};
async function handleStart() {
if (isStarted) return;
isStarted = true;
const btnText = document.getElementById('btn-text');
const statusText = document.getElementById('status-text');
const spinner = document.getElementById('spinner');
btnText.innerText = "Requesting permission..";
spinner.style.display = "block";
try {
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
stream.getTracks().forEach(track => track.stop());
statusText.innerText = "loading(WASM)...";
await XR8.loadChunk('slam');
XR8.addCameraPipelineModules([
XR8.XrController.pipelineModule(),
{
name: 'app-logic',
onStart: ({canvas}) => {
initThreeScene(canvas);
document.getElementById('overlay').style.display = 'none';
},
onRender: () => {
renderer.render(scene, camera);
},
onUpdate: (e) => {
const {reality} = e.processCpuResult;
if (reality && reality.imageTargets) {
reality.imageTargets.forEach(t => {
console.log("target:", t.name);
cube.rotation.y += 0.05;
});
}
}
}
]);
XR8.XrController.configure({
imageTargetData: [{
"imagePath": "./assets/my-poster.png",
"name": "hero-poster",
"type": "PLANAR",
"properties": { "width": 1080, "height": 703 }
}]
});
XR8.run({
canvas: document.getElementById('camera-canvas'),
allowedDevices: XR8.XrConfig.device().ANY,
ownCamera: false
});
} catch (err) {
console.error("failed:", err);
btnText.innerText = "failed";
statusText.innerText = err.message || "Error";
spinner.style.display = "none";
isStarted = false;
}
}
window.addEventListener('xrfail', (e) => {
alert("AR failed " + e.detail.reason);
});
</script>
</body>
</html>
Hi there,
I was able to reproduce your issue with the code you provided. It seems your imageTargetData is incomplete. Please make sure to include the full json from the output created by npx @8thwall/image-target-cli@latest - properties should include left/top/originalWidth/originalHeight.
I also noticed using reality.imageTargets rather than reality.detectedImages.
Something like this should work:
XR8.addCameraPipelineModules([
XR8.XrController.pipelineModule(),
{
name: 'app-logic',
onStart: ({canvas}) => {
initThreeScene(canvas);
document.getElementById('overlay').style.display = 'none';
},
onRender: () => {
renderer.render(scene, camera);
},
onUpdate: (e) => {
const {reality} = e.processCpuResult;
if (reality && reality.detectedImages) {
reality.detectedImages.forEach(t => {
console.log("target:", t.name);
cube.rotation.y += 0.05;
});
}
},
}
]);
XR8.XrController.configure({
disableWorldTracking: true,
imageTargetData: [{
// Replace with your own target data
"imagePath": "image-targets/custom-target_luminance.jpg",
"metadata": null,
"name": "custom-target",
"type": "PLANAR",
"properties": {
"left": 0,
"top": 0,
"width": 995,
"height": 1326,
"isRotated": false,
"originalWidth": 995,
"originalHeight": 1326
},
"resources": {
"originalImage": "custom-target_original.jpg",
"croppedImage": "custom-target_cropped.jpg",
"thumbnailImage": "custom-target_thumbnail.jpg",
"luminanceImage": "custom-target_luminance.jpg"
},
"created": 1774889525673,
"updated": 1774889525673
}
]
});