{"record":{"id":"57be26e4c2dc76c9","repo":"BabylonJS/Babylon.js","slug":"deleting-persistent-anchors-is-not-supported-in-th","errorCode":null,"errorMessage":"Deleting persistent anchors is not supported in this environment/browser","messagePattern":"Deleting persistent anchors 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":383,"sourceCode":"     * Restore all persistent anchors known to the current XR session\r\n     * @returns A promise that resolves after all restored anchors are tracked by an XR frame\r\n     * @throws If persistent anchor enumeration or restoration is not supported by the current session\r\n     */\r\n    public async restorePersistentAnchorsAsync(): Promise<IWebXRAnchor[]> {\r\n        return await Promise.all(this.persistentAnchors.map(async (handle) => await this.restorePersistentAnchorAsync(handle)));\r\n    }\r\n\r\n    /**\r\n     * Delete a persistent anchor from native storage\r\n     * @param handle The persistent anchor handle to delete\r\n     * @returns A promise that resolves after native persistent storage is deleted\r\n     * @throws If deleting persistent anchors is not supported by the current session\r\n     */\r\n    public async deletePersistentAnchorAsync(handle: string): Promise<void> {\r\n        const session = this._xrSessionManager.session;\r\n        const deletePersistentAnchor = session?.deletePersistentAnchor;\r\n        if (!deletePersistentAnchor) {\r\n            throw new Error(\"Deleting persistent anchors is not supported in this environment/browser\");\r\n        }\r\n\r\n        await deletePersistentAnchor.call(session, handle);\r\n        for (const anchor of this._trackedAnchors) {\r\n            if (anchor.persistentHandle === handle) {\r\n                anchor._removed = true;\r\n            }\r\n        }\r\n        for (const futureAnchor of this._futureAnchors) {\r\n            if (!futureAnchor.resolved && futureAnchor.persistentHandle === handle) {\r\n                futureAnchor.resolved = true;\r\n                futureAnchor.reject(new Error(\"The persistent anchor was deleted before tracking began\"));\r\n            }\r\n        }\r\n    }\r\n\r\n    /**\r\n     * detach this feature.\r","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/XR/features/WebXRAnchorSystem.pure.ts#L365-L401","documentation":"WebXR persistent anchors let anchors survive sessions, but the API (XRSession.deletePersistentAnchor) is only available in browsers/runtimes that implemented the persistent-anchors extension. Babylon's WebXRAnchorSystem checks for the method on the active XRSession and throws this Error when it is absent, instead of failing silently. It means you attempted to delete a stored anchor in an environment that cannot support persistent anchor deletion.","triggerScenarios":"Calling xrFeature.deletePersistentAnchorAsync(handle) on a session whose XRSession object has no deletePersistentAnchor function (browser lacking the persistent anchors capability or a session not requested with the required feature descriptors).","commonSituations":"Testing on desktop browsers or headsets/OS versions where anchors-modal/persistent-anchors is unsupported; forgetting that persistent anchors require explicit session feature request; running older WebXR runtimes (e.g. older Oculus/Quest browser) that never shipped deletePersistentAnchor.","solutions":["Feature-detect support before calling: check `xrSessionManager.session?.deletePersistentAnchor` and gate your delete UI/flow on it.","Ensure persistent anchors are requested when creating the session (e.g. requiredFeatures/options for anchors with persistent support) and use a browser that implements them.","Wrap the call in try/catch and degrade gracefully (e.g. hide persistent anchors, inform the user) when the API is missing.","Update the device's browser/OS to a version that implements WebXR persistent anchors."],"exampleFix":"// before\nawait anchors.deletePersistentAnchorAsync(handle);\n// after\nconst session = xrSessionManager.session;\nif (typeof session?.deletePersistentAnchor === \"function\") {\n    await anchors.deletePersistentAnchorAsync(handle);\n} else {\n    console.warn(\"Persistent anchor deletion not supported here\");\n}","handlingStrategy":"type-guard","validationCode":"const canDelete = typeof xrSessionManager.session?.deletePersistentAnchor === \"function\";\nif (!canDelete) { /* hide delete UI or use fallback */ }","typeGuard":"function supportsPersistentAnchorDelete(session: XRSession | undefined): session is XRSession & { deletePersistentAnchor: (handle: string) => Promise<void> } {\n    return typeof session?.deletePersistentAnchor === \"function\";\n}","tryCatchPattern":"try {\n    await anchors.deletePersistentAnchorAsync(handle);\n} catch (e) {\n    if (String((e as Error).message).includes(\"not supported\")) {\n    console.warn(\"Persistent anchor deletion unavailable\");\n    } else { throw e; }\n}","preventionTips":["Feature-detect deletePersistentAnchor before building persistent-anchor UI","Test on target headsets/browsers early; persistent anchors vary widely by runtime","Wrap persistent-anchor operations in a capability-aware wrapper","Keep device browsers updated to versions implementing persistent anchors"],"tags":["webxr","browser-support","anchors","feature-detection"],"backgroundTag":"webxr-api-not-supported","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}