BabylonJS/Babylon.js · error
Resuming WebXR depth sensing requires an active XR session.
Error message
Resuming WebXR depth sensing requires an active XR session.
What it means
resumeDepthSensingAsync resumes depth sensing on the active XR session. Like pause, it requires an active immersive session; Babylon throws this Error when inXRSession is false or the session object is missing. Resuming only makes sense within a live XRSession.
Source
Thrown at packages/dev/core/src/XR/features/WebXRDepthSensing.pure.ts:571
if (!this._xrSessionManager.inXRSession || !session) {
throw new Error("Pausing WebXR depth sensing requires an active XR session.");
}
if (typeof session.pauseDepthSensing !== "function") {
throw new Error("XRSession.pauseDepthSensing is not supported by this XR runtime.");
}
return await session.pauseDepthSensing();
}
/**
* Resumes depth sensing for the active XR session.
* @returns A promise that resolves when the native resume operation completes.
* @throws If there is no active XR session or resuming depth sensing is not supported by the runtime.
* @see https://immersive-web.github.io/depth-sensing/
*/
public async resumeDepthSensingAsync(): Promise<void> {
const session: IWebXRDepthSensingSession | undefined = this._xrSessionManager.session;
if (!this._xrSessionManager.inXRSession || !session) {
throw new Error("Resuming WebXR depth sensing requires an active XR session.");
}
if (typeof session.resumeDepthSensing !== "function") {
throw new Error("XRSession.resumeDepthSensing is not supported by this XR runtime.");
}
return await session.resumeDepthSensing();
}
/**
* Latest cached InternalTexture which containing depth buffer information.
* This can be used when the depth usage is "gpu".
* @deprecated This will be removed in the future. Use latestDepthImageTexture
*/
public get latestInternalTexture(): Nullable<InternalTexture> {
if (!this._cachedWebGLTexture) {
return null;
}
return this._getInternalTextureFromDepthInfo();
View on GitHub (pinned to 0592b347b8)
Solutions
- Check `xrSessionManager.inXRSession` before calling resumeDepthSensingAsync.
- Trigger resume from within session-lifetime events (frame loop, sessionstart) instead of external timers.
- Re-init depth sensing as part of session start if depth sensing is needed each session.
- Wrap in try/catch to absorb the race between session end and the resume call.
Example fix
// before
await depthSensing.resumeDepthSensingAsync();
// after
if (xrSessionManager.inXRSession && xrSessionManager.session) {
await depthSensing.resumeDepthSensingAsync();
} else {
console.warn("Cannot resume depth sensing without an active XR session");
} Defensive patterns
Strategy: validation
Validate before calling
if (!xrSessionManager.inXRSession || !xrSessionManager.session) {
throw new Error("Cannot resume depth sensing: no active XR session");
} Try / catch
try {
await depthSensing.resumeDepthSensingAsync();
} catch (e) {
if (String((e as Error).message).startsWith("Resuming WebXR depth sensing requires")) {
// re-init on next session start instead
} else { throw e; }
} Prevention
- Check inXRSession before resume calls
- Re-enable depth sensing at session start rather than resuming across sessions
- Handle session-end events to cancel queued resume operations
- Centralize depth-sensing state transitions in one module
When it happens
Trigger: Calling feature.resumeDepthSensingAsync() with no active session: before entering XR, after session end, or after the runtime terminated the session asynchronously.
Common situations: A 'resume depth' button clicked after the user exited the headset; an async continuation (setTimeout/promise chain) that runs post session end; calling resume during app initialization before requestSession completes.
Related errors
- Pausing WebXR depth sensing requires an active XR session.
- XRSession.pauseDepthSensing is not supported by this XR runt
- XRSession.resumeDepthSensing is not supported by this XR run
- Expected a WebGL graphics binding for WebXR Depth Sensing.
- Invalid Space Warp framebuffer
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/e4c1704491838eb3.
Report an issue: GitHub.