9 ms·
A Taste of WebGPU in Firefox
- MaxBarraclough 7y agoWill this API be opt-in, or can we expect another security disaster like with WebGL? https://news.ycombinator.com/item?id=16457791 https://news.ycombinator.com/item?id=16457791 , https://www.contextis.com/en/blog/webgl-a-new-dimension-for-browser-exploitation https://www.contextis.com/en/blog/webgl-a-new-dimension-for-... , https://www.contextis.com/en/blog/webgl-more-webgl-security-flaws https://www.contextis.com/en/blog/webgl-more-webgl-security-... Edit I should have given a quote from one of the articles covering the issue, so here's one: > anyone running Firefox 4 with WebGL support is vulnerable to having malicious web pages capture screenshots of any window on their system
- kvark 7y agoIt's up to the browser to decide if it's enabled by default at some point in the future. There is nothing in a Web API saying that it has to be forcefully enabled. I do share the concern that security of talking to the GPUs is hard. We'll do our best. I think it's important for the Web platform to reach this capability. Interestingly, the implementations are more diverse, because there isn't a single Angle-like library that everyone is going to use. This may mean that it's easier to find a vulnerability in a concrete browser, but harder to make an exploit that works portably.
- JulienSchmidt 7y agoI feel like this should require the user's explicit permission, just like audio, camera, location or Flash and Java Applets at the end of their life. WebGPU is a great innovation, but we have both privacy and security concerns here. It should be available where and when the user wants it, not silently in the background.
- vasco 7y agoWhy don't you say the same about CPU or RAM? In the end it's just resources that are abstracted away to the user, used with the purpose of performing tasks in the most efficient way possible.
- _jal 7y agoBecause some resources have mature security controls around them, and some don't. Why do you care if someone can see your bank account number? In the end they're just numbers.
- e12e 7y ago> Because some resources have mature security controls around them So we thought, then ROWHAMMER arrived..
- indolering 7y agoWhat you really want is a security first web browser, not something that must prioritize feature completeness to achieve commercial success. I would love a spin-off of the Tor browser sans Tor.
- ericflo 7y agoWhether or not the API is opt-in is orthogonal to its security hardening - this is a false dichotomy.
- jeswin 7y agoBut that's not what parent was saying, I think. He was saying that WebGL not being opt-in was a security disaster; while saying nothing about the security hardening of the WebGL module itself. Even when a module is well tested, I'd like non-essential modules to be opt-in too.
- m_eiman 7y agoI’d like Javascript to be opt-in. Turning it on by default was a mistake.
- hutzlibu 7y agoYou are free to disable it as a very small minority. The web is not a static document viewing anymore. Now I agree, that sites should have a static fallback, as I also do not want to run a full webapp, when all I want is a static article for example. But this is because of a different problem - the financing of most of the web, through advertisment and not the fault of javascript.
- tracker1 7y agoMuch like frames, iframes and window.open are really useful features... advertisers and abusers made it bad. I remember the first time I saw a popup in the 90's, my first thought was, "oh this is going to get bad." And I would never buy a product from X10.
- MaxBarraclough 7y agoI'm not suggesting any false dichotomy, I'm trying to reason about the likely security consequences given what we saw with WebGL in Firefox: serious security flaws in its implementation, with the features enabled in the browser by default. See my links above, one of which summarises with anyone running Firefox 4 with WebGL support is vulnerable to having malicious web pages capture screenshots of any window on their system. My thoughts are along these lines: ┌────────────────────┬──────────────────────────┬──────────────────────────────┐ │ │ Secure implementation │ Insecure implementation │ ├────────────────────┼──────────────────────────┼──────────────────────────────┤ │ Opt-in │ Minimal security impact │ Significant security impact │ │ Enabled by default │ Minimal security impact │ Security disaster │ └────────────────────┴──────────────────────────┴──────────────────────────────┘
- ape4 7y agoFingerprinting is one security concern.
- notyourday 7y agoBrowsers should be run in a VM, via a fake GPU which is mapped to a window ( possibly root window ) of a main desktop. Giving code fetched from the internet in real time full access to hardware, especially complex hardware, is lunacy. I'm shocked that neither Google nor Mozilla still have internalized this lesson.
- MaxBarraclough 7y agoThe browser should simply disable WebGPU by default. It's already intended to be sandboxed, but given what happened with WebGL, I'm not convinced we can trust it. There's nothing to gain by faking a GPU. Edit For clarity, I'm saying you may as well just disable WebGPU. A CPU-based simulated GPU would indeed improve security, but its performance would be so atrocious that there would be no point having it compared to the existing drawing APIs.
- notyourday 7y agoThere is - it is a GPU with all the bells and whistles but even if the browser's security context is broken, the browser cannot access anything on a real desktop.
- MaxBarraclough 7y agoIt's not clear what you have in mind here, but I think you're referring to using a CPU-based virtual GPU to power the browser's WebGPU engine, to avoid GPU-related security issues. A CPU-based fake GPU is guaranteed to have performance so poor that it isn't worth doing. This is the reason modern graphics APIs don't make provisions for CPU-based implementations. If we aren't confident in the security of the WebGPU implementation (and we're agreed that we aren't), the solution is simply to disable support for WebGPU in the browser. The browser can still offer facilities like the Canvas API.
- notyourday 7y ago> It's not clear what you have in mind here, but I think you're referring to using a CPU-based virtual GPU to power the browser's WebGPU engine, to avoid GPU-related security issues. That was my mistake - i was not clear. I'm talking about virtualized GPUs that can be passed to a VM running a minimum system needed to boot a browser.
- ddevault 7y agoThe web is an ever growing rube goldberg machine of security vunlerabilities. The web is impossible to secure and the web will never be secure. Only browse sites that you trust, with JavaScript disabled and adblocking enabled, and hope that they haven't been compromised. This is the best you can do in the face of the reckless behavior of browser vendors.
- fulafel 7y agoA lot of other web APIs and features had rce vulnerable implementations in stable browser releases when they were new, some worse than others. Eg webaudio, SVG, etc. Not an excuse of course but tells of the cross cutting systemic problems.
- moron4hire 7y agoThis is really old information
- dchyrdvh 7y agoI know some people coded up raytracers with glsl texture shaders, but rayracers are massive parrallel with no shared state needed algorithms (the entire scene is tiny in those examples). Would this new API enable shared state (to some extent)? For example, someone may want to solve numerically the diff equation of the liquid flow. This usually involves dealing with big lattices where parts of the lattices can be updated in parallel, but on the edges, there need to be some data sharing involved. Same question, but for multiplying big matrices, as many of those numerical methods allow to reduce the task to multiplying huge matrices.
- lachlan-sneff 7y agoYes, compute shaders will enable slightly more ability to do computations that are less parallel than just fragment shaders can handle.
- kvark 7y agoWe are exposing writable storage buffers and textures in all shader stages (there is a caveat discussion [1] on the topic though), which means you can write data out directly. Sharing data between shader threads can be efficiently in the compute shaders (via the shared group memory), which are included in the core of WebGPU. P.S. vange-rs [2] is written on wgpu-rs and uses ray-tracing in fragment shaders for the terrain. I hope to run it in the browser one day! [1] https://github.com/gpuweb/gpuweb/issues/639 [2] https://github.com/kvark/vange-rs
- gpugpugpugpu 7y ago> writable storage buffers and and textures in all shader stages Beware the behaviour of writes will not be consistent between vendors or shader stages, and may be surprising.
- kvark 7y agoYes, we are fully aware of that. There must be a line drawn somewhere between work that we can make portable, and the work that is platform-dependent. Enforcing any ordering on storage writes is completely unfeasible.
- gmueckl 7y agoSo this WebGPU stuff is pretty much a Javascript binding to Vulkan. The design is almost 1:1 identical. Good luck securing that! I find bugs in the standard Vulkan validation layer pretty regularly after it has been in development for a couple of years. Sure, some of the stuff is pretty hard to check like device memory addresses. But just this week I had the validation layer blow up spectacularly because I simply dared to give it an unrealistically high index for a vertex binding and the layer attempted to resize its internal state tracking array for vertex bindings to accomodate that. Vulkan has another fun aspect to it: the application doesn't have full control over the layer loading mechanisms in the mandatory driver wrapper. A user's system can be configured to load arbitrary validation layers in various ways and the application cannot prevent any of that. It can only ask for more layers to be loaded. This is great for development, but it also means that browsers can't generally assume that the Vulkan API does what they think it does. There might be a little extra in there.
- enos_feedler 7y agoIs this unique to Vulkan or would the same hold true for DX12 or Metal? If it’s unique, perhaps WebGPU could steer Vulkan closer to the others in this regard. I don’t think WebGPU is meant to be a Vulkan binding exactly but pushing secure and safe low level GPU computing across platforms. If Vulkan isn’t good enough implementation layer it will just need to evolve
- gmueckl 7y agoVulkan itself is what it is now: an abstraction of (reasonably) modern GPUs on a very low level. It is certainly very useful in that it allows applications to use GPUs in ways that are very efficient and simply impossible with older APIs, especially OpenGL. The flipside is that this flexibility and the intentional thinness of the abstraction makes it hard and actually undesirable to check the validity of the API usage in actual production use. That's why the debug layer is an optional layer and not part if the Vulkan loader. I need to check out a few things, but if WebGPU prevents access to a few hairy bits of Vulkan like explicit synchronization and memory management (the Vulkan app has to provide that), it might be securable. There are still some benefits over OpenGL left like the entire pipeline state being expressed in pipeline objects. I don't know about DX12 or Metal in practice, so I will not comment on that.
- lisamillercool 7y agoWOW! Finally WebGPU. Web Games will become a thing now!
- kart23 7y agoWould this enable bitcoin mining using gpu in a browser?
- deleted 7y ago[deleted]
- Widdershin 7y agoIt's already possible, see https://gpu.rocks/ https://gpu.rocks/. Would likely just make it faster as you wouldn't have to read the results out of a canvas, although I haven't checked what the pure data API for WebGPU looks like. After a bit more searching: https://bitcointalk.org/index.php?topic=27056.0 https://bitcointalk.org/index.php?topic=27056.0
- suyash 7y agoThis is not working for me on Safari even with turning on the experimental feature, when will this land on regular Safari ? Excited to see WebGPU possibilities.
- kvark 7y agoSafari implements a large surface of the API ([1]), but they don't accept SPIR-V shaders. When WGSL design is complete, and we have it supported in the browsers, it will be time for truly cross-browser applications. [1] https://webkit.org/blog/9528/webgpu-and-wsl-in-safari/ https://webkit.org/blog/9528/webgpu-and-wsl-in-safari/
- thewebcount 7y agoI love how much this is like Metal! I've been really getting into Metal lately and I find it so much easier to use than I did OpenGL. The one glaring exception is binding. It's the thing I hate most about OpenGL. I don't really have to think about it in Metal at all. The fragment shader just takes a texture or buffer as a function argument and I can use it just like I'd use any other C++ object or struct in the shader. From the calling side, I just say, here's the texture that goes with that argument (by name in the code, not by some random ID assigned at runtime). No figuring out which texture unit to use, or which texture target. No cases of accidentally forgetting to enable a texture unit or bind a texture to it, or using the wrong texture target. All of that fiddling around makes OpenGL such a pain in the ass to use. But it seems like WebGPU kept some of that nastiness. Why?
- kvark 7y agoThe binding model of WebGPU is nothing like OpenGL. I don't know where you get that idea, especially considering a dedicated section in the article describing this. Metal binding model works well because each buffer can contain references to other resources (`MTLArgumentBuffer`). So you can change whole packs of resources at once with this. But argument buffers are not implementable on other APIs. We chose Vulkan's descriptor set-like model as the least common denominator.
- moonchild 7y agoIn modern OpenGL with DSA[1] (Direct State Access), you barely have to bind anything at all. 1: https://www.khronos.org/opengl/wiki/Direct_State_Access https://www.khronos.org/opengl/wiki/Direct_State_Access
- zapttt 7y agofirefox should be fixing their privacy settings and adding all those new tech in the settings screen instead. but no, we get experiment addons installed, canvas fingerprinting even though i have less use for canvas then i did for flash, etc, ect. trying to play catch up with google crapping features on chrome is one thing, but also copying their irresponsability on hidding/not giving control to the end user is not what an open source company should do.
- touchpadder 7y agoI hope it will bring real performance gains besides just easier API that is abstracted away in most apps. I have 2 projects using Three.js and pure WebGL: https://bad.city https://bad.city (multiplayer browser game engine + editor) and http://fonted.io http://fonted.io (shader toy + fonts)
- kvark 7y agoRight. I think, if by 1.0 we aren't able to show significant performance gains in a wide sense (latency, frame stability, and the actual frame time), it will be a failure.
- bartread 7y agoI'd love to give bad.city a go but the need to sign up to play is a little offputting. Do you mind if I ask what the reason is, please?
- WhyNotHugo 7y agoI really dislike when these articles say "works on Linux" (Reminds me of people that say "works on PC" when it actually only runs on a single OS. Some Linux setups run Xorg, others run Wayland (with the world moving towards the latter). Yet, many times these new features (especially things related to rendering!) only work on older Xorg setups, but not on Wayland. For anyone Linux users out there: these updates only work if you're still running Xorg.
- kvark 7y agoI don't know why it wouldn't work on Wayland. We are currently using "software" presentation, which is a CPU roundtrip, as described in the article. This means we don't depend much on the actual Linux compositor. As long as WebRender can run on it, and you have Vulkan support, WebGPU will be available. If you are having issues, please file a bug!
- WhyNotHugo 7y agoSetting `gfx.webrender.all = true` makes sites like google maps render as just plain black (eg: no image). I'll try to debug in further detail and open a bug when I have clear reproduction details.
- kvark 7y agoThat's worrying! Mozilla gfx team would be interested in fixing that, as we are trying to roll WebRender on more platforms.
- AtlasBarfed 7y agoNow the cryptominer JS scripts can REALLY get some performance while you are on their site! And of course its another way to do unique profiling of users.
- kimown 7y agoCan I debug shader in webgpu like JavaScript in devtools?