{"record":{"id":"a53e3d2d88a80b28","repo":"BabylonJS/Babylon.js","slug":"requesting-persistent-anchor-handles-is-not-suppor","errorCode":null,"errorMessage":"Requesting persistent anchor handles is not supported in this environment/browser","messagePattern":"Requesting persistent anchor handles 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":316,"sourceCode":"     */\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\n    }\r\n\r\n    /**\r\n     * Restore a persistent anchor into the Babylon anchor lifecycle\r\n     * @param handle The persistent anchor handle to restore\r\n     * @returns A promise that resolves after the restored anchor is tracked by an XR frame\r\n     * @throws If restoring persistent anchors is not supported by the current session\r\n     */\r\n    public async restorePersistentAnchorAsync(handle: string): Promise<IWebXRAnchor> {\r\n        if (!this.attached) {\r\n            throw new Error(\"Restoring persistent anchors requires the anchor system to be attached\");\r\n        }\r\n\r\n        const session = this._xrSessionManager.session;\r","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/XR/features/WebXRAnchorSystem.pure.ts#L298-L334","documentation":"requestPersistentHandleAsync asks the native XRAnchor for a persistent handle. Native anchors only expose requestPersistentHandle in environments supporting anchor persistence; when the method is missing on the anchor object, the method throws immediately rather than calling an undefined function. This signals the runtime cannot persist this anchor.","triggerScenarios":"Calling requestPersistentHandleAsync(anchor) where anchor.xrAnchor.requestPersistentHandle is undefined — runtime lacks persistent anchor support, or the anchor came from a session without persistence negotiated.","commonSituations":"Targeting devices that support transient anchors only, session created without the persistence feature, running on emulators or older WebXR implementations.","solutions":["Check typeof anchor.xrAnchor.requestPersistentHandle === 'function' before calling","Request anchor persistence features during session creation","Skip persistence (keep anchor for session lifetime only) when unsupported","Update device OS/browser to a version implementing persistent anchors"],"exampleFix":"// before\nconst handle = await anchorSystem.requestPersistentHandleAsync(anchor);\n// after\nif (typeof anchor.xrAnchor.requestPersistentHandle === 'function') {\n  const handle = await anchorSystem.requestPersistentHandleAsync(anchor);\n} else {\n  console.warn('anchor persistence unsupported; skipping');\n}","handlingStrategy":"type-guard","validationCode":"const canPersist = typeof anchor.xrAnchor.requestPersistentHandle === 'function';","typeGuard":"function canRequestHandle(a: IWebXRAnchor): boolean {\n  return typeof a.xrAnchor.requestPersistentHandle === 'function';\n}","tryCatchPattern":"try {\n  const handle = await anchorSystem.requestPersistentHandleAsync(anchor);\n} catch {\n  console.warn('anchor persistence unsupported; anchor kept for this session only');\n}","preventionTips":["Check requestPersistentHandle existence before calling","Request persistence features at session creation","Store persistence availability per device and adapt UX","Skip persistence gracefully instead of failing the whole flow"],"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"}