From a12e7c22672c01b113ed1e2073f8d6ab2064400d Mon Sep 17 00:00:00 2001 From: Alex Cooper Date: Wed, 21 Jan 2026 13:11:19 -0800 Subject: [PATCH 1/5] Allow UAs to enforce a max number of layers per render state Addes a `maxRenderLayers` attribute to XrSession and updates the `updateRenderState` algorithm to throw if a render state is provided with too many layers specified. --- webxrlayers-1.bs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/webxrlayers-1.bs b/webxrlayers-1.bs index 09194f9..850ce10 100755 --- a/webxrlayers-1.bs +++ b/webxrlayers-1.bs @@ -2154,6 +2154,7 @@ This module replaces the steps given by "[=/update the pending layers state=]" f 1. Set |session|'s [=pending render state=]'s {{XRRenderState/layers}} to null. 1. If |newState|'s {{XRRenderStateInit/layers}} is set: 1. If |session| was not created with "[=feature descriptor/layers=]" enabled and |newState|'s {{XRRenderStateInit/layers}} contains more than 1 instance, throw a {{NotSupportedError}} and abort these steps. + 1. If |newState|'s {{XRRenderState/layers}} contains more than {{XRSession/maxRenderLayers}} entries, throw a {{NotSupportedError}} and abort these steps. 1. If |session|'s [=pending render state=] is null, set it to a copy of |activeState|. 1. If |newState|'s {{XRRenderStateInit/layers}} contains duplicate instances, throw a {{TypeError}} and abort these steps. 1. For each |layer| in |newState|'s {{XRRenderStateInit/layers}}: @@ -2205,7 +2206,15 @@ with {{XRSession/renderState}} |state|, the user agent MUST run the following st XRSession changes {#xrsessionchanges} ----------------- -This module adds the following to the [=XRSession interface=]: +This module extends and adds the following to the [=XRSession interface=]: + +
+[SecureContext, Exposed=Window] partial interface XRSession {
+  readonly attribute unsigned long maxRenderLayers;
+};
+
+ +The maxRenderLayers represents the maximum amount of layers that a session can render at a given time. It SHOULD be possible to create more than this number of layers at a given time, but they may not all be set via {{XRSession/updateRenderState()}} at once. Each {{XRSession}} has an internal [=WeakSet=] bindings that holds weak references to each {{XRWebGLBinding}} that was created with that session. From e2fdf15bc6d823f1b9d581d0557e684ed78bff1f Mon Sep 17 00:00:00 2001 From: Alex Cooper Date: Wed, 21 Jan 2026 14:50:29 -0800 Subject: [PATCH 2/5] Tweak language --- webxrlayers-1.bs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webxrlayers-1.bs b/webxrlayers-1.bs index 850ce10..77fc5be 100755 --- a/webxrlayers-1.bs +++ b/webxrlayers-1.bs @@ -2214,7 +2214,9 @@ This module extends and adds the following to the [=XRSession interface=]: }; -The maxRenderLayers represents the maximum amount of layers that a session can render at a given time. It SHOULD be possible to create more than this number of layers at a given time, but they may not all be set via {{XRSession/updateRenderState()}} at once. +The maxRenderLayers represents the maximum number of layers that the compositor can handle, and thus the maximum size of any {{XRRenderStateInit}}'s {{XRRenderStateInit/layers}} array . It SHOULD be possible to create more than this number of layers at a given time. + +NOTE: This guidance is not intended to provide a limit on the number of layers allocatable by the user agent, as described in [[#xrlayerallocation | Allocation of layers]]. User Agents may allow e.g. for 20 layers to be created, while only allowing 10 at a time to be set via {{XRSession/updateRenderState()}}. Each {{XRSession}} has an internal [=WeakSet=] bindings that holds weak references to each {{XRWebGLBinding}} that was created with that session. From b482bb4c68f47f397afbbc2ca922fa4cc6f5055e Mon Sep 17 00:00:00 2001 From: Alex Cooper Date: Wed, 21 Jan 2026 14:51:53 -0800 Subject: [PATCH 3/5] Fix trailing whitespace --- webxrlayers-1.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webxrlayers-1.bs b/webxrlayers-1.bs index 77fc5be..28685ae 100755 --- a/webxrlayers-1.bs +++ b/webxrlayers-1.bs @@ -2214,7 +2214,7 @@ This module extends and adds the following to the [=XRSession interface=]: }; -The maxRenderLayers represents the maximum number of layers that the compositor can handle, and thus the maximum size of any {{XRRenderStateInit}}'s {{XRRenderStateInit/layers}} array . It SHOULD be possible to create more than this number of layers at a given time. +The maxRenderLayers represents the maximum number of layers that the compositor can handle, and thus the maximum size of any {{XRRenderStateInit}}'s {{XRRenderStateInit/layers}} array. It SHOULD be possible to create more than this number of layers at a given time. NOTE: This guidance is not intended to provide a limit on the number of layers allocatable by the user agent, as described in [[#xrlayerallocation | Allocation of layers]]. User Agents may allow e.g. for 20 layers to be created, while only allowing 10 at a time to be set via {{XRSession/updateRenderState()}}. From 25112348f1b90820a929dac8b9c0f70a71030655 Mon Sep 17 00:00:00 2001 From: Alex Cooper Date: Wed, 21 Jan 2026 15:18:02 -0800 Subject: [PATCH 4/5] Fix link --- webxrlayers-1.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webxrlayers-1.bs b/webxrlayers-1.bs index 28685ae..97159fd 100755 --- a/webxrlayers-1.bs +++ b/webxrlayers-1.bs @@ -2216,7 +2216,7 @@ This module extends and adds the following to the [=XRSession interface=]: The maxRenderLayers represents the maximum number of layers that the compositor can handle, and thus the maximum size of any {{XRRenderStateInit}}'s {{XRRenderStateInit/layers}} array. It SHOULD be possible to create more than this number of layers at a given time. -NOTE: This guidance is not intended to provide a limit on the number of layers allocatable by the user agent, as described in [[#xrlayerallocation | Allocation of layers]]. User Agents may allow e.g. for 20 layers to be created, while only allowing 10 at a time to be set via {{XRSession/updateRenderState()}}. +NOTE: This guidance is not intended to provide a limit on the number of layers allocatable by the user agent, as described in [[#xrlayerallocation|Allocation of layers]]. User Agents may allow e.g. for 20 layers to be created, while only allowing 10 at a time to be set via {{XRSession/updateRenderState()}}. Each {{XRSession}} has an internal [=WeakSet=] bindings that holds weak references to each {{XRWebGLBinding}} that was created with that session. From 33ee74bed1957a91f5dfcf007e107709a1708bc2 Mon Sep 17 00:00:00 2001 From: Alex Cooper Date: Wed, 21 Jan 2026 15:22:41 -0800 Subject: [PATCH 5/5] can->MUST --- webxrlayers-1.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webxrlayers-1.bs b/webxrlayers-1.bs index 97159fd..0c3e178 100755 --- a/webxrlayers-1.bs +++ b/webxrlayers-1.bs @@ -2214,9 +2214,9 @@ This module extends and adds the following to the [=XRSession interface=]: }; -The maxRenderLayers represents the maximum number of layers that the compositor can handle, and thus the maximum size of any {{XRRenderStateInit}}'s {{XRRenderStateInit/layers}} array. It SHOULD be possible to create more than this number of layers at a given time. +The maxRenderLayers represents the maximum number of layers that the compositor MUST handle, and thus the maximum size of any {{XRRenderStateInit}}'s {{XRRenderStateInit/layers}} array. It SHOULD be possible to create more than this number of layers at a given time. -NOTE: This guidance is not intended to provide a limit on the number of layers allocatable by the user agent, as described in [[#xrlayerallocation|Allocation of layers]]. User Agents may allow e.g. for 20 layers to be created, while only allowing 10 at a time to be set via {{XRSession/updateRenderState()}}. +NOTE: This guidance is not intended to provide a limit on the number of layers allocatable by the user agent, as described in [[#xrlayerallocation|Allocation of layers]]. User Agents may allow e.g. for 20 layers to be created, while only allowing 10 at a time to be set via {{XRSession/updateRenderState()}}. It is also worth noting that because different layers may require a different amount of backend power or objects, user agents have some discretion in setting the `maxRenderLayers` value to ensure that at least that many layers can be rendered. However, user agents still need to reject whenever more layers are passed in, and cannot reject when less are passed in to updateRenderState. Each {{XRSession}} has an internal [=WeakSet=] bindings that holds weak references to each {{XRWebGLBinding}} that was created with that session.