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

TSX files not loading in WASM #6

Open
stevepryde opened this issue Jul 28, 2024 · 4 comments
Open

TSX files not loading in WASM #6

stevepryde opened this issue Jul 28, 2024 · 4 comments
Labels
limitation Something could work better / does not work but there is an available work-around

Comments

@stevepryde
Copy link
Collaborator

stevepryde commented Jul 28, 2024

The current approach for loading TSX files relies on futures_lite which doesn't work in WASM builds.

We need a new approach for loading these assets in WASM

@stevepryde
Copy link
Collaborator Author

For anyone who encounters this, the workaround I used was to embed the tilesets in the tilemaps in Tiled.

There are two ways to do this:

  1. When creating a new tileset there is a checkbox on the right saying "Embed in map"
  2. OR, when editing a map, in the tileset pane at the bottom right, see the buttons along the bottom. The second button from the left says "Embed". If you click this, it will embed the tileset into the map. Make sure to only use the tiles from the embedded set.

This embeds the tileset info into the TMX file rather than just referencing a TSX file that contains the same info. The actual tile images are still separate regardless. But it just means Bevy doesn't need to load the TSX file separately, which is where the issue occurs.

It's related to the fact that the Tiled hook for fetching the TSX file is sync while the Bevy way to fetch asset data is async. So it needs to call an async method from a sync method, and currently it does this by using futures_lite. That works on most platforms but not WASM.

@adrien-bon adrien-bon added the limitation Something could work better / does not work but there is an available work-around label Aug 6, 2024
@Niashi24
Copy link
Contributor

Niashi24 commented Sep 8, 2024

Here is the issue in rs-tiled for async loading, which when closed should make closing this issue trivial: mapeditor/rs-tiled#304

@Amelia-Mowers
Copy link

Amelia-Mowers commented Sep 22, 2024

Hi,

I believe I am having the same problem. When I used this plugin, and attempt to serve my project with Trunk the wasm seems to fail and I get:

Uncaught TypeError: The specifier “env” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”. bevy_game-39230fd36e2500b.js:1:30

After searching around I found your (@stevepryde) post here and that you managed to get it working on your project dizzy-ducks, and successfully exported a working wasm build to itchio.

But when I cloned the dizzy ducks repo and tried to serve it locally using Trunk, I get the same issue:

Uncaught TypeError: The specifier “env” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”. dizzy-ducklings-46bff8eb8e30afb.js:1:30

Did you have the same issue, or is it a problem with my local dev environment? If so, how did you get a web build working for itchio/how did you test your web build locally?

Thank you in advance, and thank you for everything you have posted so far!

@Amelia-Mowers
Copy link

Hi,

I believe I am having the same problem. When I used this plugin, and attempt to serve my project with Trunk the wasm seems to fail and I get:

Uncaught TypeError: The specifier “env” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”. bevy_game-39230fd36e2500b.js:1:30

After searching around I found your (@stevepryde) post here and that you managed to get it working on your project dizzy-ducks, and successfully exported a working wasm build to itchio.

But when I cloned the dizzy ducks repo and tried to serve it locally using Trunk, I get the same issue:

Uncaught TypeError: The specifier “env” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”. dizzy-ducklings-46bff8eb8e30afb.js:1:30

Did you have the same issue, or is it a problem with my local dev environment? If so, how did you get a web build working for itchio/how did you test your web build locally?

Thank you in advance, and thank you for everything you have posted so far!

So turns the ZSTD dependency of rs-tiled, even though it was supposed to be compiled without that feature? It might be a bug with WASM bindgen or something. As a quick fix I just forked rs-tiled, removed the ZSTD dependency, then forked bevy-ecs-tiled and had it depend on that modified rs-tiled repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
limitation Something could work better / does not work but there is an available work-around
Projects
None yet
Development

No branches or pull requests

4 participants