-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Race condition in Cesium3DTileset / Reconsider readyPromise
pattern
#10909
Comments
I already found one race condition, https://github.com/CesiumGS/cesium/blob/main/packages/engine/Source/Scene/Cesium3DTileset.js#L978 is missing a |
That seems likely. We'll take a look at this further and see if we can get to the root of the rogue code path. In the meantime, is it possible to await the tileset's ready promise as a workaround? |
That will certainly work around the trivial reproduction case above, but not sure how much work it will take to update the actual codebase I'm working with. In general, the entire I wish there was a way to synchronously create a tileset, like it just doesn't load anything until you call |
Awaiting the promise in the real code did fix part of the problem, but I then discovered fit("crash jasmine", function () {
const viewer = new Viewer(document.createElement("div"));
viewer.destroy();
});
Cesium seems to have unhandled promise failures sprinkled throughout the code, largely because of the flawed |
The I think I can work around this one in my tests by telling the Viewer not to create imagery, but it's still a nasty underlying bug that should be addressed. |
I do agree that this is a fundamental problem that needs fixing. I think this is alluded to in a few other issues, but does not have its own, so we can use this one to track it. |
readyPromise
pattern
This will necessitate a breaking change in |
This should work for most/all cases in Cesium that are following this pattern. Basically constructors should never be async or do async work. See |
An alternative, perhaps shorter-term, fix would be to just make sure that every promise is either exposed as part of the API or handled internally; but my personal bias would be the suggestion I had above. |
Thanks, I agree the first option is preferable as we've used it elsewhere in the codebase. I think I misunderstood because of the mention of the new |
When reviewing the handling of promise chains and
that is present in the former. (Omitting this may or may not be intentional, but that could be part of the review - maybe the code block could be moved into a method to handle both target types equally...?) |
I'm not deeply involved in the process and state here (and I assume that the Specifically, the current First, it should be moved into a |
aTrivialSpec.js
intopackages/engine/Specs/Scene/
.npm -- run test --browsers ChromeHeadless
, but since it's a race condition it's hard to say why.I'm fairly certain what's happening is that
Cesium3DTileset
has an async code path that keeps running, even afterdestroy
is called (and therefore after the test is finished). In 99.99% of the times I've seen this error from karma/jasmine, that's always been the case in general.The text was updated successfully, but these errors were encountered: