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

AsyncFileDialog blocks on Windows #190

Closed
valadaptive opened this issue Apr 28, 2024 · 5 comments
Closed

AsyncFileDialog blocks on Windows #190

valadaptive opened this issue Apr 28, 2024 · 5 comments

Comments

@valadaptive
Copy link
Contributor

AsyncFileDialog should allow the application to continue running while the file dialog is open, but on Windows, it causes it to freeze and eventually cause a "not responding" popup. This seems to be due to mutex shenanigans where ThreadFuture locks the mutex immediately in the thread that it spawns, then blocks on it when you poll it.

@Dangerise
Copy link

In fact, even AsyncFileDialog is block, .await means the task will blocked until it complete

to solve it, I think you should spawn another task to call AsyncFileDialog , and let your main loop check whether it is completed.

@valadaptive
Copy link
Contributor Author

In fact, even AsyncFileDialog is block, .await means the task will blocked until it complete

That's not how Futures work in Rust. When you await a future, it doesn't block the thread; it causes the task to "yield" (within whatever executor you're using, it'll move on to the next task to be executed, and probably won't poll that future again until the task is awoken).

@Dangerise
Copy link

@valadaptive I mean, the thread won't be blocked, but the task will be blocked, even it's async

@valadaptive
Copy link
Contributor Author

Yes, but in the current code, the thread that the executor is running on is blocked, because the future blocks when polled. This means that no other futures can be executed while the file dialog is open, and if the executor is running on the main thread, the application itself will freeze. That's what I'm fixing.

@valadaptive
Copy link
Contributor Author

Resolved by #191

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

No branches or pull requests

2 participants