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

Consider using AbortController/AbortSignal instead of cancelRequestAnimationFrame #335

Closed
kenchris opened this issue Mar 22, 2018 · 2 comments

Comments

@kenchris
Copy link

Current API

  long requestAnimationFrame(XRFrameRequestCallback callback);
  void cancelAnimationFrame(long handle);

So something like:

dictionary XRFrameOptions {
  AbortSignal? signal;
}
void requestAnimationFrame(XRFrameRequestCallback callback, XRFrameOptions);

And usage:

const controller = new AbortController();
const signal = controller.signal;
requestAnimationFrame(callback, { signal });

controller.abort();
@mkeblx
Copy link
Contributor

mkeblx commented Mar 26, 2018

What are benefits of this approach for WebXR?

@toji
Copy link
Member

toji commented Mar 26, 2018

Thanks for the suggestion! We've discussed using AbortController in other areas of the API, and certainly I think if we find a need for cancellable promises we'll be happy to make use of them. requestAnimationFrame is something of a special case, though, because we've done some negotiation with other parts of the web platform to ensure that it meshes nicely with window.requestAnimationFrame and can become part of a more generic interface that encapsulates both cases in the future if needed.

TL;DR: We're unlikely to see XR rAF change in format much because it's intentionally retaining compatibility with window rAF. I'm sold on using AbortController elsewhere, though.

@toji toji closed this as completed Mar 26, 2018
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

3 participants