{"record":{"id":"9277cb9f615f92c6","repo":"BabylonJS/Babylon.js","slug":"persistent-anchor-enumeration-is-not-supported-in","errorCode":null,"errorMessage":"Persistent anchor enumeration is not supported in this environment/browser","messagePattern":"Persistent anchor enumeration is not supported in this environment/browser","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/XR/features/WebXRAnchorSystem.pure.ts","lineNumber":302,"sourceCode":"     * Whether the current XR session exposes all session-level persistent anchor APIs\r\n     * @returns Whether all session-level persistent anchor APIs are supported\r\n     */\r\n    public get isPersistentAnchorSupported(): boolean {\r\n        const session = this._xrSessionManager.session;\r\n        return (\r\n            !!session && session.persistentAnchors !== undefined && typeof session.restorePersistentAnchor === \"function\" && typeof session.deletePersistentAnchor === \"function\"\r\n        );\r\n    }\r\n\r\n    /**\r\n     * Get the persistent anchor handles known to the current XR session\r\n     * @returns The persistent anchor handles\r\n     * @throws If persistent anchor enumeration is not supported by the current session\r\n     */\r\n    public get persistentAnchors(): ReadonlyArray<string> {\r\n        const persistentAnchors = this._xrSessionManager.session?.persistentAnchors;\r\n        if (persistentAnchors === undefined) {\r\n            throw new Error(\"Persistent anchor enumeration is not supported in this environment/browser\");\r\n        }\r\n        return persistentAnchors;\r\n    }\r\n\r\n    /**\r\n     * Request a persistent handle for a tracked anchor\r\n     * @param anchor The Babylon anchor to persist\r\n     * @returns A promise that resolves with the persistent handle\r\n     * @throws If requesting persistent handles is not supported by the native anchor\r\n     */\r\n    public async requestPersistentHandleAsync(anchor: IWebXRAnchor): Promise<string> {\r\n        const requestPersistentHandle = anchor.xrAnchor.requestPersistentHandle;\r\n        if (!requestPersistentHandle) {\r\n            throw new Error(\"Requesting persistent anchor handles is not supported in this environment/browser\");\r\n        }\r\n        const handle = await requestPersistentHandle.call(anchor.xrAnchor);\r\n        this._setPersistentHandle(anchor, handle);\r\n        return handle;\r","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/XR/features/WebXRAnchorSystem.pure.ts#L284-L320","documentation":"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'.","triggerScenarios":"Reading anchorSystem.persistentAnchors when _xrSessionManager.session.persistentAnchors is undefined — session created without anchors/persistent-anchors support, or browser lacking the persistent anchor API.","commonSituations":"Devices/browsers implementing anchors but not persistence, missing feature negotiation in optionalFeatures, calling before the session is fully created or after it ended.","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"],"exampleFix":"// before\nconst handles = anchorSystem.persistentAnchors;\n// after\nconst session = xrSessionManager.session;\nif (session && 'persistentAnchors' in session) {\n  const handles = anchorSystem.persistentAnchors;\n} else {\n  console.warn('persistent anchors not supported');\n}","handlingStrategy":"type-guard","validationCode":"const canEnumerate = typeof xrSessionManager.session?.persistentAnchors !== 'undefined';","typeGuard":"function supportsPersistentEnumeration(session: XRSession | undefined): session is XRSession & { persistentAnchors: ReadonlyArray<string> } {\n  return !!session && 'persistentAnchors' in session;\n}","tryCatchPattern":"try {\n  const handles = anchorSystem.persistentAnchors;\n} catch {\n  console.warn('persistent anchors not supported; skipping restore flow');\n}","preventionTips":["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"],"tags":["webxr","anchors","persistence","feature-detection"],"backgroundTag":"missing-browser-api","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}