Skip to content
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

Avoiding race conditions in parallel exclusive session requests #343

Closed
offenwanger opened this issue Apr 18, 2018 · 5 comments
Closed

Avoiding race conditions in parallel exclusive session requests #343

offenwanger opened this issue Apr 18, 2018 · 5 comments
Assignees
Milestone

Comments

@offenwanger
Copy link

Currently the spec does not define how race conditions between multiple exclusive session requests should be handled.
https://immersive-web.github.io/webxr/#dom-xrdevice-requestsession

For example: If Request A starts and is held up in stage 7, then Request B starts while A is outstanding, what should the behavior of B be?

Proposal:

  • Request A
  • Request B
  • B is blocked while A is outstanding
  • If A succeeds reject B
  • If A fails allow B to proceed
@RafaelCintron
Copy link

RafaelCintron commented Apr 23, 2018

I suggest we reject new exclusive mode session requests while there are any outstanding. Since exclusive mode requests involve user consent UI, reducing the number of interleaving prompts is desired.

Edge currently takes this approach for WebVR.

@Artyom17
Copy link

Artyom17 commented May 1, 2018

Rafael's solution sounds totally reasonable to me.

@jsantell
Copy link
Contributor

jsantell commented May 1, 2018

Third'ing Rafael's solution, and seems to work nice with attempting multiple potential session configurations outside of exclusivity when probing for overlaps between supported feature sets by device and the application:

  async onStart() {
    const device = await navigator.xr.requestDevice();
    const featureSets = [{ exclusive: true, featureA: true }, { exclusive: true, featureB: true }];
    let session;

    while (!session && featureSets.length) {
      try {
        session = await device.requestSession(featureSets.shift());
      } catch (e) {}
    }
  }

It seems to be dangerous from an application logic perspective to allow multiple in-flight exclusive requests, although interested in learning more about why a request would take "too long" (10 seconds?) in order to queue up another request. Is that something that can happen?

@toji
Copy link
Member

toji commented May 15, 2018

FWIW I believe that Rafael's solution was what was agreed to on the previous WebXR call as well. I'll put up a pull request soon to document it.

@AdaRoseCannon
Copy link
Member

@toji Does this PR close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants