{"record":{"id":"e12e3fad3b96e5d3","repo":"BabylonJS/Babylon.js","slug":"xrcompositionlayer-control-is-not-supported-by","errorCode":null,"errorMessage":"XRCompositionLayer.${control} is not supported by this XR runtime.","messagePattern":"XRCompositionLayer\\.(.+?) is not supported by this XR runtime\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/XR/features/Layers/WebXRCompositionLayer.ts","lineNumber":144,"sourceCode":"        public override readonly layerType: LayerTypeT,\r\n        /**\r\n         * Whether the layer renders both views into a texture array.\r\n         */\r\n        public readonly isMultiview: boolean,\r\n        public createRTTProvider: (xrSessionManager: WebXRSessionManager) => WebXRLayerRenderTargetTextureProvider<LayerTypeT>,\r\n        public _originalInternalTexture: Nullable<InternalTexture> = null,\r\n        private readonly _destroyLayerOnDispose = false,\r\n        /**\r\n         * Whether the layer can only be rendered when its native `needsRedraw` flag is set.\r\n         */\r\n        public readonly isStatic = false\r\n    ) {\r\n        super(getWidth, getHeight, layer, layerType, createRTTProvider);\r\n    }\r\n\r\n    private _assertControlSupported(control: \"opacity\" | \"quality\" | \"forceMonoPresentation\"): void {\r\n        if (!(control in this.layer)) {\r\n            throw new Error(`XRCompositionLayer.${control} is not supported by this XR runtime.`);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Disposes the Babylon render-target resources and destroys the native layer when this wrapper owns it.\r\n     */\r\n    public override dispose(): void {\r\n        super.dispose();\r\n        if (this._destroyLayerOnDispose) {\r\n            this.layer.destroy();\r\n        }\r\n    }\r\n}\r\n\r\n/**\r\n * Wraps a positionable XR composition layer and synchronizes it with a Babylon transform node.\r\n * The node's scaling does not affect the physical dimensions of the layer.\r\n * @typeParam LayerT the concrete positionable WebXR layer type\r","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/XR/features/Layers/WebXRCompositionLayer.ts#L126-L162","documentation":"WebXRCompositionLayer wraps a native XRCompositionLayer and allows controlling opacity, quality, and forceMonoPresentation. These controls only exist if the underlying XRCompositionLayer object actually exposes the corresponding property. The helper _assertControlSupported checks `control in this.layer` and throws when the active XR runtime's native layer lacks that capability.","triggerScenarios":"Setting opacity, quality, or forceMonoPresentation on a WebXRCompositionLayer whose underlying native XRCompositionLayer (from the XR runtime, e.g. some WebXR implementations or emulators) does not implement the corresponding property on the native object.","commonSituations":"Running on a browser/device whose WebXR composition layer support is partial (property missing from the spec implementation), using an emulator or polyfill that creates layers without these members, assuming desktop Chrome behavior applies to mobile/headset runtimes.","solutions":["Check `control in nativeLayer` (e.g. 'opacity' in layer.layer) before setting the property","Feature-detect once after layer creation and gate UI code that exposes these controls","Update the browser/XR runtime to a version implementing the full XRCompositionLayer API","Catch the error and skip the control silently when the runtime lacks support"],"exampleFix":"// before\ncompositionLayer.opacity = 0.5;\n// after\nif ('opacity' in compositionLayer.layer) {\n  compositionLayer.opacity = 0.5;\n} else {\n  console.warn('opacity not supported by this XR runtime');\n}","handlingStrategy":"type-guard","validationCode":"const supports = (layer: WebXRCompositionLayer, c: 'opacity'|'quality'|'forceMonoPresentation') => c in layer.layer;","typeGuard":"function supportsControl(layer: XRCompositionLayer, control: string): boolean {\n  return control in layer;\n}","tryCatchPattern":"try {\n  compositionLayer.opacity = 0.5;\n} catch {\n  console.warn('XRCompositionLayer control unsupported; skipping');\n}","preventionTips":["Feature-detect native layer properties right after layer creation","Gate control UI on detected capabilities","Test on all target XR runtimes, not just desktop Chrome","Update browser/runtime when controls are required"],"tags":["webxr","feature-detection","runtime-support"],"backgroundTag":"missing-browser-api","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}