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

Fix file_watcher feature hanging indefinitely #10585

Merged
merged 2 commits into from
Nov 20, 2023

Conversation

nicopap
Copy link
Contributor

@nicopap nicopap commented Nov 16, 2023

Objective

Fix the bevy_asset/file_watcher feature in practice depending on multithreading, while not informing the user of it.

As I understand it (I didn't check it), the file watcher feature depends on spawning a concurrent thread to receive file update events from the notify-debouncer-full crate. But if multithreading is disabled, that thread will never have time to read the events and consume them.

Solution

Add a compile_error! causing compilation failure if file_watcher is enabled while multi-threaded is disabled.

This is considered better than adding a dependency on multi-threaded on the file_watcher, as (according to @mockersf) toggling on/off multi-threaded has a non-zero chance of changing behavior. And we shouldn't implicitly change behavior. A compilation failure prevents compilation of code that is invalid, while informing the user of the steps needed to fix it.

@nicopap nicopap added C-Bug An unexpected or incorrect behavior A-Assets Load files from disk to use for things like images, models, and sounds labels Nov 16, 2023
@mockersf
Copy link
Member

Rather than enabling the multi-threaded feature automatically, I would prefer to add a check in code and panic if it isn't

file_watcher is a dev feature, it shouldn't change the behaviour of the app significantly when enabling it

@nicopap
Copy link
Contributor Author

nicopap commented Nov 16, 2023

I'll update the PR with this in mind

@SludgePhD
Copy link
Contributor

I don't have multi-threading disabled, so this PR won't fix #10576

@nicopap
Copy link
Contributor Author

nicopap commented Nov 17, 2023

@SludgePhD I now removed the reference to #10576 thank for pointing that out!

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Nov 19, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Nov 19, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2023
@mockersf mockersf added this pull request to the merge queue Nov 20, 2023
Merged via the queue into bevyengine:main with commit 96444b2 Nov 20, 2023
22 checks passed
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

Fix the `bevy_asset/file_watcher` feature in practice depending on
multithreading, while not informing the user of it.

**As I understand it** (I didn't check it), the file watcher feature
depends on spawning a concurrent thread to receive file update events
from the `notify-debouncer-full` crate. But if multithreading is
disabled, that thread will never have time to read the events and
consume them.

- Fixes bevyengine#10573 


## Solution

Add a `compile_error!` causing compilation failure if `file_watcher` is
enabled while `multi-threaded` is disabled.

This is considered better than adding a dependency on `multi-threaded`
on the `file_watcher`, as (according to @mockersf) toggling on/off
`multi-threaded` has a non-zero chance of changing behavior. And we
shouldn't implicitly change behavior. A compilation failure prevents
compilation of code that is invalid, while informing the user of the
steps needed to fix it.
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 C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

file_watcher features causing game to freeze
4 participants