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

Instant is not available on WASM + Proposed Solution #926

Closed
ryanisaacg opened this issue Jun 15, 2019 · 3 comments
Closed

Instant is not available on WASM + Proposed Solution #926

ryanisaacg opened this issue Jun 15, 2019 · 3 comments

Comments

@ryanisaacg
Copy link
Contributor

Instant is part of the public API of EventLoop 2.0, which makes sense but unfortunately Instant cannot be constructed on WASM. As of right now, wasm (via stdweb or wasm-bindgen) is essentially only able to access core and alloc.

One solution is to wait until Instant becomes available on wasm via the experimental system call interface. However, there is no timeline for this and it's not clear how long that will take.

What I propose is winit have its own Instant type, with an API identical to std::time::Instant, except it has a private constructor that allows wasm to construct instances of it from web time APIs. The upside is that the public API is more or less the same and fully compatible with wasm; the downside is that users may be confused about why winit has its own Instant type. A possible fix for that would be to intentionally change the type's name to a synonym like Timestamp, so that it is obviously distinct from the type in the standard library.

I would be willing to make the change as part of #797 as long as the maintainers of other platforms would be amenable to it.

@mitchmindtree
Copy link
Contributor

I think the instant crate exists for this purpose, that is to get the same behaviour as std Instant that also works on WASM.

@ryanisaacg
Copy link
Contributor Author

Looks like it, and maintained by a fairly prominent author. That’s probably the best solution then, if it’s amenable to everyone.

@ryanisaacg
Copy link
Contributor Author

Okay, Instant required minimal changes on the stdweb branch. Any future discussion is probably best there.

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

No branches or pull requests

3 participants