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

Layers are sometimes not rendered #387

Closed
mattjennings opened this issue Jul 6, 2022 · 9 comments · Fixed by #477
Closed

Layers are sometimes not rendered #387

mattjennings opened this issue Jul 6, 2022 · 9 comments · Fixed by #477
Labels

Comments

@mattjennings
Copy link
Collaborator

mattjennings commented Jul 6, 2022

Sometimes a layer (or layers) in the tilemap will not get rendered when scene is initialized. It's seemingly completely random. I've got a video of it happening below, but it only happened twice in 1.5 minutes of me refreshing the page & clicking play:

CleanShot.2022-07-06.at.16.58.28-converted.mp4

I first noticed this in a larger project with multiple scenes and it was happening a bit more frequently. It seemed to be more likely to happen if I left the tab open for a long time between refreshes (i.e page reloads while I was making changes in my code editor before flipping back to the browser), but I have not been able to track down any specific cause.

There are no errors or warnings in console and the layer's image shows as loaded in the network tab, so as far as I can tell the image resource is properly loaded.

Steps to Reproduce

I've made a repro project here: https://github.com/mattjennings/excalibur-tiled-layer-bug

  • npm install & npm run dev
  • Keep refreshing browser and playing game until it (hopefully) happens.

Expected Result

All layers should render

Actual Result

Sometimes layers are missing

Environment

  • browsers and versions: Chrome 103.0.5060.53, Firefox 102.0. I have not been able to reproduce in Safari, but I have in another Webkit-based browser, Orion (WebKit version 614.1.20)
  • operating system: macOS 12.4
  • Tiled version: 1.8.4
  • Excalibur versions: 0.26
  • Tiled plugin versions: 0.26.2

I had noticed #381 and hoped it would possibly be related to what I was seeing, so I tried a local build from source shortly after iti was merged but sadly it still occurred.

Current Workaround

None

@mattjennings
Copy link
Collaborator Author

It's possible this only happens for tilemaps with external tilesets. If I remember back to when I first noticed this, it was when I switched from embedded to external tilesets.

I'm re-trying my repro now with embedded tilesets and I'm not seeing it happen... so I'll mention it here if I see otherwise.

@eonarheim
Copy link
Member

@mattjennings thanks for the issue! This is definitely bizarre

I think your instinct that external tilesets might be related is on the mark.

If so, this recent PR might have fixed the issue #380 I'll double check locally.

If the tileset ever loaded out of order relative to their first gid it might present like this because it would select the wrong tileset for a tile potentially.

@eonarheim
Copy link
Member

I can reproduce the issue locally pretty consistently by swapping the order of the tilesets in the tmx

image

Dropping my local build of @excaliburjs/plugin-tiled seems to solve the issue? I'm going to refresh a few more times before I declare victory. I'm planning on releasing excalibur and plugins this week so a new version should theoretically fix the external tileset issue.

@eonarheim eonarheim added the bug label Jul 7, 2022
@mattjennings
Copy link
Collaborator Author

Ah! Perhaps I didn't have it properly symlinked when I tried a local build... that would be embarassing 😬. If so, my apologies but I'm glad to see that it could already be fixed!

@eonarheim
Copy link
Member

I've noticed that vite pretty aggressively caches npm dependencies, I've had to manually clear the cache to see changes.

I couldn't get npm link to work with vite when testing locally and wound up copying the built files into the project.

I literally just found this article https://dev.to/hontas/using-vite-with-linked-dependencies-37n7 which suggests optimizeDeps.exclude as a way to do linked deps, but this doesn't seem to work for me either :(

@mattjennings
Copy link
Collaborator Author

Mm yes, I have many (many) hours fiddling around with vite's optimizeDeps and its caching of node_modules... that is probably what happened there and I hadn't realized.

Although I think that article has it backwards, or their scenario was unique, because optimizeDeps.include is what you're supposed to use for linked modules 😅 https://vitejs.dev/config/#optimizedeps-include (and that will put them in the vite cache, so if it changes, you gotta nuke node_modules/.vite)

@mattjennings
Copy link
Collaborator Author

Unfortunately I seem to be seeing this still (albeit less frequently - unless it's placebo). I haven't investigated further yet, just wanted to note that here for the meantime.

@eonarheim
Copy link
Member

@mattjennings I'll look into it. Same reproduction repo that you posted originally in this issue?

If you catch the not loading again, I'd be curious about the order of the resources loaded in your network tab. Maybe there is still and order of operations issue?

@mattjennings
Copy link
Collaborator Author

I haven't tried it with the repro again yet, just have seen it in my own projects. Don't worry about looking into it until I can repro it again as I feel like it might be even more random than before, but I'll keep an eye on the resource load order when I see it next!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants