You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WebXR+Unity构建包曾正常运行,现无法在Quest Browser中渲染的问题排查

Troubleshooting WebXR Immersive-Vr Stuck on Loading Screen in Unity 6.3 WebGL

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/#webxr to 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 createUnityInstance call:
    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 Management and double-check the WebGL platform has WebXR enabled, with no extra conflicting plugins active.
  • Rebuild from scratch: Delete the Library folder 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 XREnabler GameObject in your scene is active, has the correct script attached, and the Enable method 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 06:38:22