News for hackers. Stuff that matters.
Re:Using WebAssembly threads from C, C++ and Rust by flohofwoe on Wednesday July 21, 2021 @09:58AM (#27906351)
The bummer with WASM threads is the COOP/COEP headers requirement once it dawns on you that this only works if you have control over the web server configuration (to set the required response headers).

This means WASM threads can't be used with popular hosting solutions like Github Pages, which in turn means that for library authors like me the feature is nearly useless because it splits the audience into people who have control over their web servers, and those who don't, which in turn means maintaining two code paths, one with and one without threading support. And even if you theoretically have control over the web server configuration it's still more hassle because the people who write the code are usually not the same people who configure the web servers. So instead of just dumping a couple of WASM files to IT you also need to find and ask the right people to tweak the web server configuration just for your use case.

Sometimes I don't understand what's going on in the heads of the people thinking this stuff up :/

Re:Using WebAssembly threads from C, C++ and Rust by adkadskhj on Wednesday July 21, 2021 @12:09PM (#27908097)
> Sometimes I don't understand what's going on in the heads of the people thinking this stuff up :/

So this post made me look up[1][2] COOP/COEP, but as far as i can tell this seems to be a security measure. Seemingly because they don't know, at this point in time, how else to enable shared memory in WASM without this limitation.

So what in your mind could have been done better? I agree it really sucks having your WASM apps live in two camps, single and multithreaded, but it seems like we, as users conceptually have two choices:

1. Don't get shared memory at all. Or, 2. Get shared memory in limited scenarios

#2 still seems better than #1, no?

Or do you perhaps think the performance Opt-In is overly aggressive. Ie if we just enabled shared memory always we'd reduce the WASM split with minimal issues. Alternatively we could do the reverse, Opt-Out, such that for resource constrained environments the phone/whatever could connect to `mobile.example.com`.

[1]: https://web.dev/coop-coep/ [2]: https://www.youtube.com/watch?v=XLNJYhjA-0c&t=4s

Re:Using WebAssembly threads from C, C++ and Rust by flohofwoe on Wednesday July 21, 2021 @12:15PM (#27908187)
Well, "obviously" the web should have a mechanism in place that allows to request security sensitive features without having to poke around in the web server configuration, because in many cases this is "off limits" to the people who author the files to be hosted. How this is achieved, I don't really care, I only know that the current solution is half-baked.

The underlying problem is that this is a classic finger-pointing-situation that will probably never be fixed, because the web security people point the finger at the web hosters, and the web hosters shrug it off because 99% of their customers don't need the features because they just host their static blog there.

Re:Using WebAssembly threads from C, C++ and Rust by brabel on Wednesday July 21, 2021 @04:18PM (#27911589)
HTML meta headers used to be the solution to this kind of stuff, like the <meta charset="UTF-8"> tag for example (which contains information you can also provide in a HTTP header).
Re:Using WebAssembly threads from C, C++ and Rust by pjmlp on Wednesday July 21, 2021 @04:49PM (#27911976)
Good use of past tense, given that they aren't the solution any longer.
Re:Using WebAssembly threads from C, C++ and Rust by ori_b on Wednesday July 21, 2021 @09:22PM (#27914267)
> So what in your mind could have been done better?

If it's a security risk, there shouldn't be an option. Setting up a web server is a low bar for malicious actors.

Re:Using WebAssembly threads from C, C++ and Rust by adkadskhj on Thursday July 22, 2021 @11:32AM (#27920058)
It's not a security risk. The security risk was removed, and the provided feature is an expensive workaround to avoid the security risk.
Re:Using WebAssembly threads from C, C++ and Rust by adminscoffee on Friday July 23, 2021 @03:02AM (#27927989)
maybe depending on the app, a layer can be created, so like a wasm inside a wasm, kinda like a docker type thing that would allow an app to live inside a wasm virtual machine
Re:Using WebAssembly threads from C, C++ and Rust by RReverser on Wednesday July 21, 2021 @02:53PM (#27910450)
The Github Pages situation is definitely unfortunate. We tried to contact them for couple of months to ask to add an option for COOP/COEP before the deprecation, but didn't have any luck with our contacts.
Re:Using WebAssembly threads from C, C++ and Rust by Santosh83 on Wednesday July 21, 2021 @10:04AM (#27906443)
Well something as basic as CSP is also crippled without access to the server to set headers. And a lot of other stuff.

The more relevant question here is why so few (if at all) web hosting solutions allow the user to configure custom server rules?

Re:Using WebAssembly threads from C, C++ and Rust by flohofwoe on Wednesday July 21, 2021 @10:07AM (#27906492)
TBH I wonder why response header requirements can't be set right in the meta tags in index.html. Would this be any different than having a provider-specific config file next to index.html from a security pov?
Re:Using WebAssembly threads from C, C++ and Rust by Santosh83 on Wednesday July 21, 2021 @10:21AM (#27906640)
Some of them can be, but not all. Some headers are needed before the content is loaded. With ubiquitous virtualisation these days, I don't see why hosting providers can't allow users more control over their server without compromising security.
Re:Using WebAssembly threads from C, C++ and Rust by littlestymaar on Thursday July 22, 2021 @02:49AM (#27916179)
You don't even need virtualization at all. Apache have allowed this for twenty years!
Re:Using WebAssembly threads from C, C++ and Rust by littlestymaar on Thursday July 22, 2021 @02:47AM (#27916171)
All PHP (Apache) hosting provider I know allow user-defined configuration on a per-directory level.
Re:Using WebAssembly threads from C, C++ and Rust by jhgb on Wednesday July 21, 2021 @11:10AM (#27907353)
> something as basic as CSP is also crippled without access to the server to set headers

Why would communicating sequential processes be crippled by this?

Re:Using WebAssembly threads from C, C++ and Rust by agency on Wednesday July 21, 2021 @11:18AM (#27907469)
Re:Using WebAssembly threads from C, C++ and Rust by jhgb on Wednesday July 21, 2021 @11:43AM (#27907773)
Ah, I see. A different namespace.
Re:Using WebAssembly threads from C, C++ and Rust by atom3 on Wednesday July 21, 2021 @10:06AM (#27906480)
I've not try that but wouldn't the html meta tag work as well?

Something like

  <head>
    <meta http-equiv="Cross-Origin-Embedder-Policy" content="require-corp" />
    <meta http-equiv="Cross-Origin-Opener-Policy" content="same-origin" />
    ...
  </head>
Re:Using WebAssembly threads from C, C++ and Rust by Jasper_ on Wednesday July 21, 2021 @11:01AM (#27907222)
No, http-equiv only supports a hard-coded whitelist of headers. https://html.spec.whatwg.org/multipage/semantics.html#pragma...
Re:Using WebAssembly threads from C, C++ and Rust by infogulch on Wednesday July 21, 2021 @02:16PM (#27909945)
It seems the answer to the question "wouldn't this work" is "no", but I'd ask "shouldn't this work?" what's the problem with this being configured in a meta tag?
Re:Using WebAssembly threads from C, C++ and Rust by flohofwoe on Wednesday July 21, 2021 @10:09AM (#27906505)
Apparently not, but I haven't tried myself:

https://stackoverflow.com/questions/67259043/can-coop-coep-h...

Re:Using WebAssembly threads from C, C++ and Rust by nextaccountic on Wednesday July 21, 2021 @11:31AM (#27907641)
You should still provide a fallback without sharedarraybuffers and atomics because safari doesn't provide them.
Re:Using WebAssembly threads from C, C++ and Rust by dheera on Wednesday July 21, 2021 @05:05PM (#27912156)
> COOP/COEP headers requirement

Just like CORS proxies maybe someone can make a public COOP/COEP proxy.

Stupid requirements will lead to stupid workarounds.

Actually you could probably just use CloudFront if you don't mind spending a couple bucks a month and configure it to add some headers.

Re:Using WebAssembly threads from C, C++ and Rust by alfg on Wednesday July 21, 2021 @03:53PM (#27911254)
Ran into the same issue using Github Pages with an FFmpeg/Wasm project. Hoping they add support for these headers soon.

I could use something like Netlify, but I like the convenience of the gh-pages branch and deployment.

Re:Using WebAssembly threads from C, C++ and Rust by petters on Wednesday July 21, 2021 @02:03PM (#27909780)
Agreed, couldn't "I hereby relinquish my ability to bring other-origin content into this process without their opt-in" be a JS API call (one-way)?

HTTP headers should not affect app functionality in this way.

Re:Using WebAssembly threads from C, C++ and Rust by kristjansson on Wednesday July 21, 2021 @03:48PM (#27911167)
This seems like a GitHub pages problem more than anything. Setting a header is a reasonable way to direct the client to behave a certain way, GH just doesn’t want to set that yet?
Re:Using WebAssembly threads from C, C++ and Rust by NoahKAndrews on Wednesday July 21, 2021 @12:00PM (#27907988)
It's worth noting that Netlify is a much superior solution to GitHub pages that's just as easy to use, and it supports custom headers.
Re:Using WebAssembly threads from C, C++ and Rust by flohofwoe on Wednesday July 21, 2021 @12:09PM (#27908103)
That may be true, but it's up to the library users what hosting service they use. The people that decide to use (for instance) Github Pages shouldn't be left in the cold.