Skip to content

Resolve root tile event when Tileset has invalid loader#1316

Merged
azrogers merged 3 commits intomainfrom
resolve-invalid-loader
Mar 9, 2026
Merged

Resolve root tile event when Tileset has invalid loader#1316
azrogers merged 3 commits intomainfrom
resolve-invalid-loader

Conversation

@j9liu
Copy link
Contributor

@j9liu j9liu commented Mar 4, 2026

Currently, getRootTileAvailableEvent never fires if the underlying loader is invalid. This happens in cases where invalid asset IDs are passed in, and the loader rightfully prevents itself from making a bogus request.

I ran into this in Unreal because of how statistics work. It requires loading the tileset's metadata schema after the root tile is available. However, if the promise never resolves, then we just keep waiting for something that will never happen. This resulted in the Editor never being able to close a level that was attempting to load inaccessible tileset metadata. Even if no root tile is actually loaded, the event should resolve when it's clear nothing can be loaded (similar to failed URL loads).

@j9liu j9liu added this to the April 2026 Release milestone Mar 4, 2026
@j9liu j9liu requested a review from azrogers March 5, 2026 21:10
@azrogers
Copy link
Contributor

azrogers commented Mar 6, 2026

It doesn't feel to me like getRootTileAvailableEvent should resolve if there is no root tile, because that means that the root tile is not actually available. Would it be possible to reject the future instead?

@j9liu
Copy link
Contributor Author

j9liu commented Mar 9, 2026

@azrogers Totally agree with you, this just happens to be the pattern that we've established in other parts of the code. In a similar issue in #1299, @kring explained:

[The promise] only rejects in the catch handler, which is when something quite catastrophic goes wrong. A normal load failure (e.g., request for the tileset.json returns a 404, or JSON parsing of the tileset.json response fails) will not invoke that catch continuation.

So the promise not rejecting, even for typical load failures, is intentional at least for now. It might be nice to change that behavior in the future, or at least to rename getRootTileAvailableEvent for that possibility (resolveRootTileEvent?). I'm happy to open an issue for this so we can keep mental tabs on it and avoid confusion later.

@azrogers
Copy link
Contributor

azrogers commented Mar 9, 2026

We should probably have the getRootTileAvailableEvent return a Result with the pointer to the root tile or something to make explicit the implicit requirement being that the subscribers should check to see if the root tile is nullptr when the event fires. But that's a refactor for another time.

@azrogers azrogers merged commit 25f74c1 into main Mar 9, 2026
28 checks passed
@azrogers azrogers deleted the resolve-invalid-loader branch March 9, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants