Skip to content

toggleOverlay proposal#1439

Open
cabanier wants to merge 4 commits into
immersive-web:mainfrom
cabanier:toggleOverlay
Open

toggleOverlay proposal#1439
cabanier wants to merge 4 commits into
immersive-web:mainfrom
cabanier:toggleOverlay

Conversation

@cabanier

@cabanier cabanier commented Jun 29, 2026

Copy link
Copy Markdown
Member

Comment thread index.bs Outdated
1. Set |session|'s [=XRSession/browser overlay shown=] boolean to `true`.
1. If no other user agent UI or platform state requires the [=XRSession/visibility state=] to be {{XRVisibilityState/"hidden"}}, set |session|'s [=XRSession/visibility state=] to {{XRVisibilityState/"visible-blurred"}}.
1. Abort these steps.
1. Otherwise, [=Shut down the session|shut down=] |session|.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIthout a way to feature detect support this feels like a bit of a footgun. At minimum I think if we want this behavior we need to add a member boolean that can indicate support; but I wonder if returning a bool (that indicates if toggling was succesful) or a promise (bool is true for shown, false for hidden and rejected if overlay couldn't be toggled), would also be acceptable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The developer will call this API if they want the user to enter some information on the 2D web page. I can't think of a scenario where they wouldn't want to exit WebXR if overlay is not supported.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe they can work around it, or if they can summon their own keyboard maybe they can pipe the data through? If it's payment, maybe there's some improvements that could be made to the payments API, etc.

Requesting a feature leading to an exit without a way to validate just feels like a massive footgun to me; maybe the reason the page wanted the overlay was optional to begin with.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they go through the trouble of building an alternate input systen, they will likely choose that as their only option.
If we do NOT exit, developers will just assume it worked since they only test on Quest which leaves a broken workflow on other platforms.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In thinking about it a bit more, I think I'm not opposed to failure meaning you end the session (since we have the event you should be listening for), but I do think we should have a way to feature detect. At the very least, maybe you want to switch to display a message and a button or a different message if you know the overlay won't work.

Comment thread index.bs
Add a note that browser overlays can display cross-origin content, unlike the HTML-in-Canvas API.

Require XRSession.toggleOverlay() to be invoked with transient activation and throw SecurityError otherwise.
@cabanier

cabanier commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

/agenda toggleOverlay proposal

@probot-label probot-label Bot added the agenda Request discussion in the next telecon/FTF label Jul 6, 2026
@Yonet Yonet removed the agenda Request discussion in the next telecon/FTF label Jul 6, 2026
@cabanier
cabanier requested a review from alcooper91 July 7, 2026 20:56
Comment thread index.bs

1. Let |session| be [=this=].
1. If |session|'s [=XRSession/ended=] value is `true`, throw an "{{InvalidStateError}}" {{DOMException}} and abort these steps.
1. If |session| is not an [=immersive session=], throw a "{{NotSupportedError}}" {{DOMException}} and abort these steps.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I think redundant with the line that this feature shouldn't ever be granted to non-immersive sessions above?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that listed somewhere else in this algorithm?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this one, but it's in the spec text you have about when the feature should be granted. I don't think we have algorithms for enabling most of those features though. I'm fine with leaving this line in but just wanted to raise the potential (IMO) redundancy

Comment thread index.bs Outdated
@alcooper91

Copy link
Copy Markdown
Contributor

This seems reasonable to me with these changes as we discussed (and a couple of minor nitpicks). I'd like to allow the others to weigh in though.

@mwyrzykowski mwyrzykowski left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the use cases for this? Payments are mentioned, but all major browsers already support the payments API which seems preferable to opening a browser window. E.g., some UAs may open native system UI for payments instead of the entire browser.

It would be good to understand what the goals are here and if they are already achievable via existing web APIs. Opening a browser window seems like it does not exactly fit with the rest of the WebXR API.

@cabanier

Copy link
Copy Markdown
Member Author

What are the use cases for this? Payments are mentioned, but all major browsers already support the payments API which seems preferable to opening a browser window. E.g., some UAs may open native system UI for payments instead of the entire browser.

FWIW Quest browser does not support payments. Is there any browser that supports payments inside of a WebXR session?

It would be good to understand what the goals are here and if they are already achievable via existing web APIs. Opening a browser window seems like it does not exactly fit with the rest of the WebXR API.

The goal is to have a 2d page that can potentially open another tab or display third party content.

@mwyrzykowski

Copy link
Copy Markdown

FWIW Quest browser does not support payments. Is there any browser that supports payments inside of a WebXR session?

I don't think so but support couldn't be added if that was needed.

The goal is to have a 2d page that can potentially open another tab or display third party content.

Specifically Apple is wondering, what content would be displayed that is relevant to an immersive session? It seems a bit out of place with the rest the WebXR API to be showing browser windows. We are wondering if all content desired could be displayed via existing web APIs?

@cabanier

Copy link
Copy Markdown
Member Author

FWIW Quest browser does not support payments. Is there any browser that supports payments inside of a WebXR session?

I don't think so but support couldn't be added if that was needed.

It's very hard to do so which is why it hasn't happened yet. It unclear if users can trust UI that is displayed inside an immersive session.

The goal is to have a 2d page that can potentially open another tab or display third party content.

Specifically Apple is wondering, what content would be displayed that is relevant to an immersive session? It seems a bit out of place with the rest the WebXR API to be showing browser windows. We are wondering if all content desired could be displayed via existing web APIs?

It's mostly convenience + the ability to show third party content

  • payments
  • upsells (ie the webxr site is a demo of a native app)
  • tutorials
  • game lobby

@alcooper91

Copy link
Copy Markdown
Contributor

It's mostly convenience + the ability to show third party content

payments
upsells (ie the webxr site is a demo of a native app)
tutorials
game lobby

TBH, I think HTML in canvas could likely handle the last 2 and maybe even the last 3. Though I guess cross-origin libraries would be banned?

@cabanier

Copy link
Copy Markdown
Member Author

It's mostly convenience + the ability to show third party content

payments
upsells (ie the webxr site is a demo of a native app)
tutorials
game lobby

TBH, I think HTML in canvas could likely handle the last 2 and maybe even the last 3. Though I guess cross-origin libraries would be banned?

Sure, it could do those things in VR but it's a lot easier to just do it in 2D especially if your site also supports a 2d experience.

@alcooper91

Copy link
Copy Markdown
Contributor

If you just smack a canvas on a quad texture can you not basically create a 2D page with HTML-in-Canvas? It's just restricted to your origin?

@cabanier

Copy link
Copy Markdown
Member Author

If you just smack a canvas on a quad texture can you not basically create a 2D page with HTML-in-Canvas? It's just restricted to your origin?

Not right now because we have not defined hit testing with html-in-canvas

Comment thread index.bs
undefined updateRenderState(optional XRRenderStateInit state = {});
Promise<undefined> updateTargetFrameRate(float rate);
[NewObject] Promise<XRReferenceSpace> requestReferenceSpace(XRReferenceSpaceType type);
undefined toggleOverlay();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might need to be a promise and we update the algorithm to reject if it's still changing/pending. I'm looking into if we could implement this, and even if we have a path that's not the suspend/resume session bit, I think it's going to be async for us.

@mwyrzykowski

Copy link
Copy Markdown

It's mostly convenience + the ability to show third party content

payments
upsells (ie the webxr site is a demo of a native app)
tutorials
game lobby

TBH, I think HTML in canvas could likely handle the last 2 and maybe even the last 3. Though I guess cross-origin libraries would be banned?

And payments is possible with existing web APIs, UAs would just need to support it. It would be their choice to exit the immersive session or remain within it.

It doesn't seem like there is a compelling use case to justify adding this to the WebXR specification at this time

@cabanier

Copy link
Copy Markdown
Member Author

It's mostly convenience + the ability to show third party content

payments
upsells (ie the webxr site is a demo of a native app)
tutorials
game lobby

TBH, I think HTML in canvas could likely handle the last 2 and maybe even the last 3. Though I guess cross-origin libraries would be banned?

And payments is possible with existing web APIs, UAs would just need to support it. It would be their choice to exit the immersive session or remain within it.

Not all sites want or can use the web payments API.
Today, they lose a lot of business from the friction of exiting WebXR and then having to re-enter. This API would get rid of this friction by either blurring or suspending/resuming the session

It doesn't seem like there is a compelling use case to justify adding this to the WebXR specification at this time

I don't quite follow. This is something developers have asked for. Why would we not let them use the browser if it's available? It seems anti-web that we force them to do everything in script.

@alcooper91

Copy link
Copy Markdown
Contributor

Not right now because we have not defined hit testing with html-in-canvas

To me that's more an argument for us working to try to solve that than implement this, but l do agree that payments is the big workflow that this enables that html-in-canvas doesn't, and maybe there's others. There's also the simplicity argument.

I think @mwyrzykowski was implying that the UA could override the payments implementation if there's a WebXR session to create a way to show it within the WebXR session if they so desired, which achieves your goal.

@mwyrzykowski

Copy link
Copy Markdown

I think @mwyrzykowski was implying that the UA could override the payments implementation if there's a WebXR session to create a way to show it within the WebXR session if they so desired, which achieves your goal.

Exactly. There doesn't seem to be any reason to add API surface to WebXR here.

@cabanier

Copy link
Copy Markdown
Member Author

I think @mwyrzykowski was implying that the UA could override the payments implementation if there's a WebXR session to create a way to show it within the WebXR session if they so desired, which achieves your goal.

Exactly. There doesn't seem to be any reason to add API surface to WebXR here.

I disagree that there is no reason at all to add this.

@mwyrzykowski

Copy link
Copy Markdown

@cabanier Apple discussed a bit would like to understand the use cases as the justification for adding this is not obvious.

For instance, why can't the sites use the payments API?

Are there other use cases which are not possible with existing web APIs and, if so, which ones?

@alcooper91

Copy link
Copy Markdown
Contributor

FWIW, I think this may be better discussed in a meeting at this point?

/agenda

@probot-label probot-label Bot added the agenda Request discussion in the next telecon/FTF label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agenda Request discussion in the next telecon/FTF

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants