Skip to content

WebXRManager session events listeners never released #31038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
WORMSS opened this issue May 3, 2025 · 1 comment
Closed

WebXRManager session events listeners never released #31038

WORMSS opened this issue May 3, 2025 · 1 comment
Labels
Milestone

Comments

@WORMSS
Copy link
Contributor

WORMSS commented May 3, 2025

Description

I am going to prefix this with a "I may be wasting your time".
I don't have a direct way to observe if this is a memory leak or not as my Meta Quest browser doesn't have debugging.

But in WebXRManager setSession the internal session is overwritten and the new one has all the events added to it.

But, if you were to call setSession again before endSession event triggers, either with a new session or a null, it becomes impossible to remove the event listeners.

I can understand this is by far not a priority, and any booboos this causes is all at the fault of the developer calling setSession twice..

I just happened to spot it as a potential problem and wanted to highlight it.

If it's deemed as not a problem then I will know not to highlight any other similar issues I may spot in the future when looking through the code.

Reproduction steps

const session = await navigator.xr?.offerSession('immersive-ar', {
  requiredFeatures: ['local'],
});
renderer.xr.setReferenceSpaceType('local');
await renderer.xr.setSession(session);
await renderer.xr.setSession(null);

Code

const session = await navigator.xr?.offerSession('immersive-ar', {
  requiredFeatures: ['local'],
});
renderer.xr.setReferenceSpaceType('local');
await renderer.xr.setSession(session);
await renderer.xr.setSession(null);

Live example

Screenshots

No response

Version

176

Device

Headset

Browser

Quest Browser

OS

Linux

@Mugen87 Mugen87 added the WebXR label May 4, 2025
@Mugen87
Copy link
Collaborator

Mugen87 commented May 4, 2025

But, if you were to call setSession again before endSession event triggers, either with a new session or a null, it becomes impossible to remove the event listeners.

Does this actually matter? If the session is overwritten with a new session or null, it should be GC collected. Besides, the event listener functions onSessionEvent(), onSessionEnd() and onInputSourcesChange() are only defined once and reused. So I doubt there are any side effects.

as my Meta Quest browser doesn't have debugging.

If you connect the Quest with USB to a computer, you can debug your WebXR application with Chrome and chrome://inspect/#devices. You must enable USB debugging on your Quest though which requires enabling development mode first.

@Mugen87 Mugen87 closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2025
@Mugen87 Mugen87 added this to the r177 milestone May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants