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

[Question] Curious what is the state of WebAssembly Web API #1221

Open
redradist opened this issue Jul 15, 2020 · 13 comments
Open

[Question] Curious what is the state of WebAssembly Web API #1221

redradist opened this issue Jul 15, 2020 · 13 comments

Comments

@redradist
Copy link

@redradist redradist commented Jul 15, 2020

I am curious what is the state of WebAssembly Web API ?

@ngzhian
Copy link
Member

@ngzhian ngzhian commented Jul 15, 2020

The Web Embedding API is at https://webassembly.github.io/spec/web-api/index.html
If you're looking for the JavaScript interface, it is at https://webassembly.github.io/spec/js-api/index.html

Both documents are linked from https://webassembly.github.io/spec/

@redradist
Copy link
Author

@redradist redradist commented Jul 15, 2020

@ngzhian

The Web Embedding API is at https://webassembly.github.io/spec/web-api/index.html
If you're looking for the JavaScript interface, it is at https://webassembly.github.io/spec/js-api/index.html

Both documents are linked from https://webassembly.github.io/spec/

Yeah, I am interested in Web API from WebAssembly without JavaScript ... first spec ...
But there is no the percent of progress and it does not describe when spec will be published

@ShadowJonathan
Copy link

@ShadowJonathan ShadowJonathan commented Aug 6, 2020

There are also no proposals related to the Web API that'd finalize the specification into WASM itself, has all development stalled regarding this?

@binji
Copy link
Member

@binji binji commented Aug 6, 2020

The current wasm-web-api is a W3C REC, and can be found here: https://www.w3.org/TR/wasm-web-api/

@redradist
Copy link
Author

@redradist redradist commented Aug 6, 2020

The current wasm-web-api is a W3C REC, and can be found here: https://www.w3.org/TR/wasm-web-api/

@binji But what is more interesting is how many done in specification ... I mean, is it 50% complete, maybe 20% or maybe 60% ?

For me it seems like 10% done according the size of document ...

@binji
Copy link
Member

@binji binji commented Aug 6, 2020

The WebAssembly specification is layered. The Web API spec builds on the JS API spec, which builds on the core API spec. What functionality are you expecting that is missing? If you are asking about being able to access web APIs without using JS, then you may want to take a look at the interface-types proposal.

Edit: I was a bit unclear here, interface-types doesn't let you access Web APIs without using JavaScript, but it provide a nicer mechanism for using Web APIs from WebAssembly.

@redradist
Copy link
Author

@redradist redradist commented Aug 6, 2020

The WebAssembly specification is layered. The Web API spec builds on the JS API spec, which builds on the core API spec. What functionality are you expecting that is missing? If you are asking about being able to access web APIs without using JS, then you may want to take a look at the interface-types proposal.

@binji Yes, I am asking about accessing Web API without JS ...
But interface type will allow to bypass data, but I think there will be separate specification for WebAssembly Web API without JS ?

@tlively
Copy link
Member

@tlively tlively commented Aug 6, 2020

@redradist No, there are no plans to expose Web APIs to WebAssembly directly without going through JS.

@ShadowJonathan
Copy link

@ShadowJonathan ShadowJonathan commented Aug 7, 2020

@tlively can I get a source on this? I have only seen direct assertions that this is on the roadmap, even mozilla's website says so.

@tlively
Copy link
Member

@tlively tlively commented Aug 7, 2020

Ah, I guess there is some nuance depending on what you mean by "direct access" to Web APIs.

  • If you mean new versions of Web APIs that are defined in terms of WebAssembly concepts: This is not on any roadmap.

  • If you mean being able to call Web APIs without explicitly importing them from the environment: This is not on any roadmap, either. As far as I can tell, even the ESM integration proposal would require writing an ES module wrapping Web APIs to make them available to import, but I'm not super familiar with ES modules, so I could be wrong about that. Either way, the APIs still need to be imported.

  • If you mean being able to hold handles to objects used in Web APIs and pass them directly to imported Web APIs without redirecting through JS glue: This is possible using reference types, but it is not expressible in many source languages and ultimately still uses JS objects. A GC proposal might make it possible for those handles to behave more like first-class JS objects inside WebAssembly, but that still would be incompatible with many source languages and would still ultimately be using JS objects.

@redradist
Copy link
Author

@redradist redradist commented Aug 10, 2020

Ah, I guess there is some nuance depending on what you mean by "direct access" to Web APIs.

* If you mean new versions of Web APIs that are defined in terms of WebAssembly concepts: This is not on any roadmap.

* If you mean being able to call Web APIs without explicitly importing them from the environment: This is not on any roadmap, either. As far as I can tell, even the [ESM integration](https://github.com/WebAssembly/esm-integration) proposal would require writing an ES module wrapping Web APIs to make them available to import, but I'm not super familiar with ES modules, so I could be wrong about that. Either way, the APIs still need to be imported.

* If you mean being able to hold handles to objects used in Web APIs and pass them directly to imported Web APIs without redirecting through JS glue: This is possible using reference types, but it is not expressible in many source languages and ultimately still uses JS objects. A GC proposal might make it possible for those handles to behave more like first-class JS objects inside WebAssembly, but that still would be incompatible with many source languages and would still ultimately be using JS objects.

@tlively The topic is mostly about calling Web API without JavaScript, through WebAssembly directly to browser ...

@tlively
Copy link
Member

@tlively tlively commented Aug 10, 2020

But interface type will allow to bypass data, but I think there will be separate specification for WebAssembly Web API without JS ?

To summarize, no, there is no such proposal at the moment. But proposals such as ES Module integration and interface types might help make the JS more invisible when calling Web APIs.

@redradist
Copy link
Author

@redradist redradist commented Aug 10, 2020

But interface type will allow to bypass data, but I think there will be separate specification for WebAssembly Web API without JS ?

To summarize, no, there is no such proposal at the moment. But proposals such as ES Module integration and interface types might help make the JS more invisible when calling Web APIs.

@tlively Don't you think this is strange ?

JavaScript compiles to intermediate representation that than executed by Engine, but WebAssembly is closer to Engine execution step than JavaScript

JavaScript -> Parsing ->Optimizations -> WebAssembly -> Intermediate Representation -> Engine

And every time WebAssembly call should go from:
Execute WebAssembly API Call
|---------------------------------------------------------------------------------------------------------|
JavaScript -> Parsing ->Optimizations -> WebAssembly -> Intermediate Representation -> Engine
|__________________________________________________|
Web API Call

It is strange and due to this in engine you should implement a lot of workarounds as my opition

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

Successfully merging a pull request may close this issue.

None yet
6 participants
@binji @ngzhian @redradist @tlively @ShadowJonathan and others
You can’t perform that action at this time.