-
-
Notifications
You must be signed in to change notification settings - Fork 322
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
emscripten / WebAssembly port #2554
Comments
I am assuming you are setting |
How does it choose emscripten? |
On Windows one would have to run a Visual Studio 2022 developer prompt, then run On Linux one would have to install cmake and ninja then, from a terminal, run I added a reference to emscripten's toolchain: Having said that, I now have some doubts as to whether this is using |
I'm being silly - apologies. I forgot I need to follow these instructions: https://emscripten.org/docs/compiling/Building-Projects.html#integrating-with-a-build-system |
I edited the description of the issue as I now I realized I never actually managed to compile maplibre-native using emscripten - it was just Visual Studio 2022 🤦 Sorry, I'll try harder. |
No problem! What you could do is to check how Qt toolchain file is defined for emscripten and base on that. |
I already was surpised when you said you compiled libuv for WASM. ;-) Keep us posted! |
Aside from making myself look a plum, at least I think I have formulated the right question in the emscripten github project's discussion. Hopefully they'll be able to shed some light. |
Well, I didn't. VCPKG (allegedly) did when I added it as a dependency during my previous attempts. The target I used is |
I am now trying a different approach, I added Also:
|
@louwers emscripten-core/emscripten#22146 (comment) I'll try disabling the warning |
Warnings disabled, I am now getting
I don't get these errors when compiling using VS 2022. Seems like emscripten is getting confused somewhere, or maybe I shouldn't use C++23? |
I also tried importing https://github.com/mapbox/mapbox-gl-native using add_subdirectory() and got even more errors related to using std::variant. |
We're compiling with C++17 right now. |
I temporarily commented out those 3 'offending' types just so I can move forward. I came across this:
https://en.cppreference.com/w/cpp/iterator/inserter I'm using C++ 23 - I guess I'd need to drop to at least C++ 20 if I want to move forward. Problem is, I am using some C++ 23 features. I'll see if I can downgrade somehow. |
I commented out a bunch of these:
|
The good news is, it compiled successfully. Naturally having had to comment out 3 parameters in the |
I'm afraid all I could manage to accomplish so far is create an instance of ( For anything more complex, I'd need help as I'm getting lots of |
I'm light years away from where I want to be - but I am celebrating with an IPA. Cheers! 🍻 |
Another interesting error
|
This is working:
This line isn't working:
due to CURL being unavailable, have to dig deeper |
Can't use CURL, will use https://emscripten.org/docs/api_reference/fetch.html |
I propose you define a new platform for WASM. |
Makes sense. Apologies for the noise here. I suppose I'm kinda treating this issue almost like a diary. I'll likely do a write-up at some point, summarising findings, plan to action, etc. |
I managed to include |
I don't mind and it may be useful as a reference for the future 😊 |
Issues with std::variant encountered on
|
Somehow adding these did not break anything:
|
Naturally, due to having commented out these two lines, this fails
So I need to dig deeper into the issue with std::variant in order to move forward |
|
Understood. I need a level playing field. I think I'm going to try again using a dummy emscripten project using C++ 17. I need to take deprecations and whatnot out of the equation. |
I forked the repo, created a branch and a PR pointing at my fork's main branch for now: andreamancuso#1 The good news: all those issues with std::variant, etc. are gone. They do appear to be related to having used C++23. This leads to me believe that we could load maplibre native as a side module based on https://emscripten.org/docs/compiling/Dynamic-Linking.html The bad news: still lots to do but I am so so glad not having to worry about the issues mentioned above. |
@louwers Unfortunately you were right 😅 vcpkg truly gave me false hope |
Adding these for reference: |
Sorry for troubling you, I imagine you're on holiday, etc. so feel free to answer whenever possible. I need a little guidance. I believe I worked out how to deal with run loop, async tasks, etc. It's basic, but threads run without uv. That said, I could do with a little help with this code:
The render orchestrator returns early:
I know that there are many reasons as to why this could happen. I wanted to ask, off the top of your head, if you can think of obvious reasons - possibly related to the fact that this code is running in a WASM environment. Is (Admittedly, despite having opened dozens of hpp and cpp files, I know very little about the overall architecture, etc.) |
The obvious one: did you implement HTTP requests? |
Good question. I commented out the cURL part, I see an instance of HTTPFileSource being created, however the HTTPFileSource::request() method is never invoked. |
Good luck. You could also try loading a local style with a local GeoJSON source. |
I tried loading the style by passing the static, hard-coded contents of the referenced style JSON file. I am now getting a similar behavior when it comes to loading the tiles. I am taking a break from this for a few days. |
I have spent the past few days reviewing the source code of maplibre gl js and a few other open source npm packages. This has been already quite helpful as I have several years of experience as JavaScript/TypeScript developer and only about 3 months with C++ in a WebAssembly environment - this makes me a newbie at best. I've also been doing "practical exercises": I've come across some sample JS code that generates a static map using OSM raster tiles; the code only works on Node.js so I ported it to the browser (I swapped sharp with jimp). Too bad Jimp does not support SVG rendering. Next I'll try to do basic rendering of vector tiles using WebGPU with some default style(s). It's still a long way but I feel like I'm making some progress, albeit very slowly. |
Hi,
I have been trying to compile maplibre-native using emscripten.
I can't figure out how to run
emcmake
in a way that does not cause errors.I have created a new discussion in the emscripten github space: emscripten-core/emscripten#22146
I shall update this issue accordingly.
(P.S. you can track my PR: xframes-project/xframes#37 )
The text was updated successfully, but these errors were encountered: