BabylonJS/Babylon.js · error
Persistent anchor enumeration is not supported in this envir
Error message
Persistent anchor enumeration is not supported in this environment/browser
What it means
The persistentAnchors getter enumerates previously persisted anchor handles from the XRSession's persistentAnchors property. That property is part of the optional WebXR persistent anchors extension; when it is undefined (session or browser does not implement it), the getter throws instead of returning an empty list, so callers do not mistake 'unsupported' for 'no persistent anchors'.
Source
Thrown at packages/dev/core/src/XR/features/WebXRAnchorSystem.pure.ts:302
* Whether the current XR session exposes all session-level persistent anchor APIs
* @returns Whether all session-level persistent anchor APIs are supported
*/
public get isPersistentAnchorSupported(): boolean {
const session = this._xrSessionManager.session;
return (
!!session && session.persistentAnchors !== undefined && typeof session.restorePersistentAnchor === "function" && typeof session.deletePersistentAnchor === "function"
);
}
/**
* Get the persistent anchor handles known to the current XR session
* @returns The persistent anchor handles
* @throws If persistent anchor enumeration is not supported by the current session
*/
public get persistentAnchors(): ReadonlyArray<string> {
const persistentAnchors = this._xrSessionManager.session?.persistentAnchors;
if (persistentAnchors === undefined) {
throw new Error("Persistent anchor enumeration is not supported in this environment/browser");
}
return persistentAnchors;
}
/**
* Request a persistent handle for a tracked anchor
* @param anchor The Babylon anchor to persist
* @returns A promise that resolves with the persistent handle
* @throws If requesting persistent handles is not supported by the native anchor
*/
public async requestPersistentHandleAsync(anchor: IWebXRAnchor): Promise<string> {
const requestPersistentHandle = anchor.xrAnchor.requestPersistentHandle;
if (!requestPersistentHandle) {
throw new Error("Requesting persistent anchor handles is not supported in this environment/browser");
}
const handle = await requestPersistentHandle.call(anchor.xrAnchor);
this._setPersistentHandle(anchor, handle);
return handle;
View on GitHub (pinned to 0592b347b8)
Solutions
- Request the persistent anchors feature in the session's optionalFeatures
- Guard the read with typeof session?.persistentAnchors !== 'undefined' before accessing
- Treat the throw as 'persistence unavailable' and skip restore logic
- Update browser/runtime to one implementing XRSession.persistentAnchors
Example fix
// before
const handles = anchorSystem.persistentAnchors;
// after
const session = xrSessionManager.session;
if (session && 'persistentAnchors' in session) {
const handles = anchorSystem.persistentAnchors;
} else {
console.warn('persistent anchors not supported');
} Defensive patterns
Strategy: type-guard
Validate before calling
const canEnumerate = typeof xrSessionManager.session?.persistentAnchors !== 'undefined';
Type guard
function supportsPersistentEnumeration(session: XRSession | undefined): session is XRSession & { persistentAnchors: ReadonlyArray<string> } {
return !!session && 'persistentAnchors' in session;
} Try / catch
try {
const handles = anchorSystem.persistentAnchors;
} catch {
console.warn('persistent anchors not supported; skipping restore flow');
} Prevention
- Negotiate persistent anchors in session features
- Feature-detect session.persistentAnchors before reading
- Treat unsupported persistence as an empty set, not a crash
- Gate persistence UI behind capability checks
When it happens
Trigger: Reading anchorSystem.persistentAnchors when _xrSessionManager.session.persistentAnchors is undefined — session created without anchors/persistent-anchors support, or browser lacking the persistent anchor API.
Common situations: Devices/browsers implementing anchors but not persistence, missing feature negotiation in optionalFeatures, calling before the session is fully created or after it ended.
Related errors
- Requesting persistent anchor handles is not supported in thi
- Restoring persistent anchors is not supported in this enviro
- Anchors not enabled in this environment/browser
- Deleting persistent anchors is not supported in this environ
- XRCompositionLayer.${control} is not supported by this XR ru
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/9277cb9f615f92c6.
Report an issue: GitHub.