Skip to content

Temporary fix to prevent panics on loading Gltf assets in parallel due to stack overlows #18186

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

john-sharratt
Copy link

Objective

Temporary fix for
#15271

Solution

Disables the inline invocation of the task engine after loading a Gltf as the blocking call is causing task engine re-entrance and stack overflow

Testing

Tested on my local branch which is a fork, not directly tested on the issue raiser.
Further testing would be required before accepting this however this does fix my issue

Copy link
Contributor

github-actions bot commented Mar 6, 2025

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added A-Assets Load files from disk to use for things like images, models, and sounds P-Crash A sudden unexpected crash S-Needs-Review Needs reviewer attention (from anyone!) to move forward C-Bug An unexpected or incorrect behavior A-Tasks Tools for parallel and async work labels Mar 6, 2025
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you say more about why this fixes the issue observed?

Note that we won't merge commented out code, but let's work on getting the fix nice before working on polish.

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 6, 2025
@john-sharratt
Copy link
Author

john-sharratt commented Mar 6, 2025

Yeah no worries, this is mainly just to help out victor if he can't wait for a proper patch.

Basically the bug is because blocking code is running within async code which is generally a bit of an anti-pattern, what tokio and others do is shift blocking code to a dedicated blocking thread pool so edge cases like this don't happen.

Ultimately you could fix this and make it work but its not really deterministic or easy to rationalize. Better would be to make sure all your blocking code and async code run on different thread pools.

@john-sharratt
Copy link
Author

Here's some background information you can read up on blocking inside async contexts

https://docs.rs/tokio/latest/tokio/task/fn.block_in_place.html
https://tokio.rs/tokio/topics/bridging
https://ryhl.io/blog/async-what-is-blocking/

@john-sharratt
Copy link
Author

john-sharratt commented Mar 6, 2025

B.t.w. Now we are talking a bit more in actively and given we're on the topic of task management - I've solved the multi-threading problem in WASM running in the main browsers for other projects if you want some tips.

@alice-i-cecile
Copy link
Member

@john-sharratt notes over in #4078 would be hugely appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Tasks Tools for parallel and async work C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants