Replies: 7 comments 21 replies
-
Lot of different issues here, so I'm just getting some time to respond. I think there are a number of fascinating questions you raise, only partly in the domain of a Native version. WebGPU for MapLibreJSAdding WebGPU support for the Javascript version of MapLibre is probably a great idea. I suspect MapLibreJS is not particularly well optimized for WebGL2, let alone WebGPU. Doing a WebGPU version would give you an opportunity to optimize things. These are some of the same issues we see for OpenGL ES, like the lack of instancing, single uniforms and overly simple shaders. There are opportunities for Native even in OpenGL ES 3.0 to greatly improve performance. We're just starting to take advantage of those for Metal. WebGPU for the JS version would allow you to explore those on the JS side. WebGPU for Native: Technical SidePurely from an engineering perspective, it should be easier now. We've got two renderer SDKs going so adding a third should not be a huge burden. Getting it performant.... well that's impossible to say at this point. You're going through a translation step here from WebGPU to some local SDK, so it could be fine or it could be absolutely horrible. You'd just have to see. If there's enough interest and budget, sure! But I'm not sure it'll meet your expectations. Who is This For?On mobile we've seen a lot of these cross-platform attempts come and go. The one approach that seems to have stuck are toolkits like React Native which are careful to point out they use native components and organize them with custom logic. But we have a path forward for Metal and Vulkan and a better OpenGL ES 3 version if we want it, so this isn't about mobile. A lot of those cross-platform toolkits were just Javascript in a wig. WebAssembly allows us to turn the tables on the web, but with C++. I'm not sure JS developers are going to react better than Native developers did. I'd tread carefully. One more thing to ask is how many organizations really develop for multiple platforms? In my experience it's usually one or the other and even when it's both, one is often vestigial. Actually a good argument for "a" WebAssembly version. Maybe Do It AnywayThat's not to say it isn't worth trying, I just wouldn't bet the future of the toolkit on it. How do you try this out with scaring off any of your users?
To expand on that last one, I don't see why a developer would want to use the version you're talking about. You need to give them new functionality that they care about. That's how you make the case. |
Beta Was this translation helpful? Give feedback.
-
Actually, I think developers like to use modern tools, even if they don't add new functionality. |
Beta Was this translation helpful? Give feedback.
-
Thanks @sjg-wdw , that was very insightful, and it's a great advice to consider this as an experimental solution for the foreseeable future, rather than bet heavily on it before it's significantly more proven. I have a few comments regarding some big trends in the mobile/web ecosystem, that I believe this would play nicely into. Portability and consistency appear be desired - the approach React Native took was good, because using the native UI make the apps feel like they belong on the respective platforms - but it does come with the cost of demanding some amount of platform-specific work done, and if you really want a fully consistent experience cross-platform that can be very hard, bordering impossible, to achieve. This problem gave room for Flutter, where the entire canvas is controlled similar to a game engine like Unity, and with Flutter for Web/iOS/Android the deployment target can be considered almost like an afterthought. This flexibility seems to be very desired by a lot of app devs who suddenly can take their native apps and make a browser version, and we currently mix GL JS / Native to reach something similar which bring some inconsistency: Scaring off users - I'm generally not so worried about i.e. presenting a native library to the web community if there is decent api, because there are examples of popular libraries that does exactly that. An example would be the most popular image manipulation library, sharp, which is largely C++, and as long as it's fast nobody seem to take any issue with that. As a sidenote - they're soon shipping a wasm version for increased portability: |
Beta Was this translation helpful? Give feedback.
-
In my experience it's harder to mess with things in wide distribution. You have to be careful you don't change too much because you risk the new version not being adopted. But when you're doing something new, you have a lot more freedom. That's part of the thinking behind the Optimized Vector Map Pipeline proposal. If we take a step back and look at what most users are trying to do (display a vector map) and ask how we can simplify that process, a lot more opens up. In that proposal I talk about "Teeny Tiny Toolkits" that only read optimized style and vector data and display it. One of those would be a good candidate for cross compiling to WASM and having a unified core. Then it's up to the devs of that toolkit to make it more appealing than the current versions. You replace yourself with yourself, essentially. |
Beta Was this translation helpful? Give feedback.
-
Hi, I've been slowly developing a library that provides React bindings for Dear Imgui based on React Native's Fabric engine, (https://reactnative.dev/architecture/fabric-renderer), emscripten, GLFW3, WGPU, ReactivePlusPlus, rxjs, Yoga, IconFontCppHeaders. Yoga support in particular is very much WIP however I've made good progress overall and I'm hoping to merge my own PR into the main branch soon. What will still be missing is the possibility to embed maps. I see that what I am after is already achievable: https://github.com/maplibre/maplibre-rs I was wondering whether you or anyone else has managed to compile maplibre native using emscripten. If you do, please get in touch! Thank you. |
Beta Was this translation helpful? Give feedback.
-
I am not sure if this is helpful but we are working on a WebGPU binding for React Native and we can provide you with the prebuilt binaries for Dawn WebGPU (C++). We build them via github actions. From our experience, setting up a Vulkan and/or a Metal backend from it is pretty straightforward. |
Beta Was this translation helpful? Give feedback.
-
It's interesting to revisit this discussion a year later. The Native Development team implemented a direct Metal renderer and is partway through direct Vulkan support. Having been through that experience I'm glad we didn't try a translation layer. WebGPU support is probably even easier now if someone wants to add it to the Native version. The argument for it is more complex now, though, since we've got Metal, OpenGL and soon Vulkan. |
Beta Was this translation helpful? Give feedback.
-
With the Modularization and Metal work finalizing, there is an opportunity to leverage it to add another target, focused on running the MapLibre Native through the WebGPU API.
It's still early days for WebGPU, but it's a good time to start exploring the space.
Browser usage
After years in the making the WebGPU API is slowly stabilizing, and already now active in Chrome Desktop by default. WebGPU has a modern architecture, more aligned with i.e. Metal than OpenGL 2, and having a target that utilizes the webgpu.h, and WGSL shaders, would allow for a WebAssembly build using Emscripten. This build would use the Dawn/wgpu backend that is shipped with the browser.
It's been demonstrated that MapLibre Native can run in the browser as WebGL, by utilizing the OpenGL target and Qt for WebAssembly. A modern WebGPU target would allow us to see much more clearly what the boundaries of this approach are. Here is MapLibre RS in WebGPU, so get a feel of this approach.
Alternative Portable Desktop Target.
By including Dawn or wgpu, a WebGPU target can, similar to the OpenGL target, act as a portable desktop target, and it would be able to tap into the more modern DX12, Vulkan, Metal backends. A WebGPU target can thus be considered a more future-proof general-purpose target, that doesn't get affected by i.e. Apple sunsetting OpenGL v3.
Beta Was this translation helpful? Give feedback.
All reactions