WebXR+Unity构建包曾正常运行,现无法在Quest Browser中渲染的问题排查
Let’s break down the most likely causes and actionable fixes for your stuck loading screen issue—since you’re not seeing any errors and commit records don’t show obvious changes, we’ll focus on silent failure points common to Unity WebGL + WebXR setups:
1. Browser Cache & WebXR Permission Glitches
WebGL + WebXR projects are notoriously sensitive to browser cache, especially Unity’s bundled assets. Start here because it’s quick to rule out:
- Clear your browser’s site-specific data (not just general cache) for your test URL, then restart the browser.
- Test in an incognito/private window to eliminate cached resources or persistent permission states.
- Verify browser WebXR flags: For Chrome/Edge, check
chrome://flags/#webxrto ensure WebXR isn’t disabled, and your site is allowed to request VR permissions.
2. Adjust XR Initialization Timing
Your code triggers XR session requests right after Unity instance creation, but Unity 6.3’s VR template might need a moment to fully initialize the XREnabler object. Try adding a short delay to your enableVR function:
function enableVR(enabled) { // Give Unity time to initialize the XREnabler GameObject setTimeout(() => { if (enabled) { unityInstance.SendMessage("XREnabler", "Enable", 1); } else { unityInstance.SendMessage("XREnabler", "Enable", 0); } }, 500); }
Also, consider ditching the WebXR Polyfill—modern browsers (Chrome 81+, Edge 81+) have native WebXR support, and the polyfill might conflict with Unity 6.3’s built-in XR handling. Modify your getXR function to skip it:
function getXR() { return navigator.xr || null; }
3. Check Unity’s Internal Logs & Hidden Project Changes
Even if your commit history looks clean, Unity’s auto-generated files or XR settings might have shifted silently:
- Enable Unity’s WebGL console output to catch internal errors the browser console misses. Add a log callback to your
createUnityInstancecall:createUnityInstance(canvas, config, (progress) => { document.querySelector("#unity-progress-bar-full").style.width = 100 * progress + "%"; }, (logMessage) => { console.log("Unity Internal Log:", logMessage); // Logs Unity's internal runtime output }).then((instance) => { instat(instance); }).catch((message) => { alert(message); }); - Reset Unity’s XR settings: Go to
Edit > Project Settings > XR Plug-in Managementand double-check the WebGL platform has WebXR enabled, with no extra conflicting plugins active. - Rebuild from scratch: Delete the
Libraryfolder in your Unity project, then rebuild the WebGL build. This clears Unity’s internal cache which can cause silent build failures. - Verify the XREnabler object: Ensure the
XREnablerGameObject in your scene is active, has the correct script attached, and theEnablemethod is public and functional.
4. Secure Context & Permission Reset
WebXR requires a secure context (HTTPS) except for localhost. If you’re testing on a non-localhost HTTP server, switch to HTTPS (even a self-signed cert works for testing). Also:
- Go to your browser’s site settings for your test URL, reset all permissions (especially XR/VR related), then re-test the session request.
内容的提问来源于stack exchange,提问作者Samson Afolabi

