-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Reprise: Ability to turn a JsValue to/from an i32 #1766
Comments
But I think you'll still run into difficulties with version mismatches, because the real problem is all the glue code. The For example, here is a list of the type descriptors that can be sent to JS. This is in the As the comment suggests, there is a corresponding list in the These two lists must be kept in sync, or else you will get extremely bizarre errors at build-time. This is the primary reason why your The reason why the lists might get out of sync is because wasm-bindgen might add a new type which can be passed to JS, so both lists need to be updated. Do you think exposing a |
Yeah it looked like the argument in the previous issue for not exposing the So, speaking as someone who isn't a maintainer in either project, but just an interested observer who wants to use them... I think exposing |
Thanks for the report! In addition to what's already been said I'll also link to my previous thoughts about how we want to retain flexibility in what It may be easiest here to basically just consider wasm an exempt target from the crate's semver policy, since wasm in general is just far more unstable than all other platforms. |
Just stumbled across this issue, figured I'd remark that #999 is still an active problem for me. Here's what I've been using as stopgap. |
Thanks for the workaround @RSSchermer, I needed this to replicate the ability to use JS Objects as Map keys like you can in Javascript. let map = new Map()
let key1 = {};
let key2 = {};
map.set(key1, "foo")
map.set(key2, "foo") |
Motivation
This was talked about in #999 but that was nearly a year ago so I wanted to see how people's thoughts on the matter have changed, if at all. Essentially, https://github.com/rust-windowing/raw-window-handle wants to solve the problem of version breaking between windowing implementations and graphics libraries by adding a layer of indirection that can be represented as primitive types such as integers or pointers. As it is, if a graphics library is designed to work with a
JsValue
fromwasm-bindgen
0.2.49 and a windowing system insists on one fromwasm-bindgen
0.2.48, there's absolutely zero ways to really make them cooperate, even if nothing about theJsValue
or how they work has changed between versions.This is a real and persistent problem:
gfx-hal
0.2's DX12 backend relies on Winit 0.19, so if you're usinggfx-hal
0.2 you're going to be using winit 0.19, and that's that unless you write your own windowing code. If you're usinggfx-hal
0.3 you're going to be still using winit 0.19 even whenwinit
0.20 gets released; you can't use any of the 0.20 release candidates, and whenwinit
0.20 gets released it will require a breaking change forgfx-hal
to also be released. But, ifwinit
exposes types thatraw-window-handle
can work with, andraw-window-handle
exposes types thatgfx-hal
can work with, then it breaks the link tyinggfx-hal
andwinit
to specific versions of each other.This solution is similar to how the
mint
crate provides interoperability between vector math libraries, so libraries likeggez
don't tie their users to a particular version ofnalgebra
orcgmath
. It basicallysolveshelps the problem of different crates moving at different speeds, since no matter what else the API binding them together moves at the speed of the interoperability crate, which is intended to be pretty stable.Proposed Solution
So, anyway. This is a long-winded way of saying "it would be useful if we could turn a
JsValue
into a raw handle of some kind that doesn't depend on a particular version ofwasm-bindgen
, even unsafely".Alternatives
raw-window-handle
could expose handles based on the version ofwasm-bindgen
, such asWasmHandle02(JsValue)
,WasmHandle03(JsValue)
, and so on, and use feature flags to offer the right ones at compile time. It would work. But it would kinda suck.The root problem is really that
raw-window-handle
goes for its portability by handing out the OS's underlying types, which are all either pointers and integers. And it's hard for an API to get more stable than Windows and X11's basic windowing junk. Wasm is a much younger system, and still evolving.The text was updated successfully, but these errors were encountered: