Skip to content

Fix deadlock in ImageLoader, FileLoader, EhttpLoader#7494

Merged
lucasmerlin merged 4 commits intomainfrom
lucas/fix-image-loader-deadlock
Sep 4, 2025
Merged

Fix deadlock in ImageLoader, FileLoader, EhttpLoader#7494
lucasmerlin merged 4 commits intomainfrom
lucas/fix-image-loader-deadlock

Conversation

@lucasmerlin
Copy link
Copy Markdown
Collaborator

This fixes the deadlock and adds the basic deadlock detection we also added to Mutexes in #7468.

Also, interestingly, the more sophisticated deadlock detection (behind the deadlock_detection feature) didn't catch this for some reason. I wonder why it exists in the first place, when parking_lot also has built in deadlock detection? It also seems to make tests slower, widget_tests usually needs ~30s, with the deadlock detection removed its only ~12s.

@lucasmerlin lucasmerlin added bug Something is broken egui_extras labels Sep 3, 2025
@lucasmerlin lucasmerlin changed the title Fix deadlock in ImageLoader, FileLoader, EhttpLoader Fix deadlock in ImageLoader, FileLoader, EhttpLoader Sep 3, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 3, 2025

Preview available at https://egui-pr-preview.github.io/pr/7494-lucasfix-image-loader-deadlock
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

Copy link
Copy Markdown
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Nice - good catch 🙏

if cfg!(debug_assertions) {
self.0
.try_lock_for(std::time::Duration::from_secs(30))
.try_lock_for(DEADLOCK_DURATION)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We should document this on the docstrings for Mutex and RwLock, i.e. that they are meant for very short locks, and are meant for internal use in egui

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ill do this in a seperate PR where I also remove the deadlock_detection feature

@lucasmerlin lucasmerlin added this to the 0.32.2 milestone Sep 4, 2025
@lucasmerlin lucasmerlin merged commit fa4bee3 into main Sep 4, 2025
49 checks passed
@lucasmerlin lucasmerlin deleted the lucas/fix-image-loader-deadlock branch September 4, 2025 08:31
emilk pushed a commit that referenced this pull request Sep 4, 2025
* related #7494 

Removes the `deadlock_detection` feature, since we now have a more
primitive panic-after-30s deadlock detection which works well enough and
even detects kinds of deadlocks that the `deadlock_detection` feature
never supported.
lucasmerlin added a commit that referenced this pull request Sep 4, 2025
* Recently CI runs started to hang randomly:
https://github.com/emilk/egui/actions/runs/17427449210/job/49477714447?pr=7359

This fixes the deadlock and adds the basic deadlock detection we also
added to Mutexes in #7468.

Also, interestingly, the more sophisticated deadlock detection (behind
the deadlock_detection feature) didn't catch this for some reason. I
wonder why it exists in the first place, when parking_lot also has built
in deadlock detection? It also seems to make tests slower, widget_tests
usually needs ~30s, with the deadlock detection removed its only ~12s.
lucasmerlin added a commit that referenced this pull request Sep 4, 2025
* related #7494 

Removes the `deadlock_detection` feature, since we now have a more
primitive panic-after-30s deadlock detection which works well enough and
even detects kinds of deadlocks that the `deadlock_detection` feature
never supported.
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
* Recently CI runs started to hang randomly:
https://github.com/emilk/egui/actions/runs/17427449210/job/49477714447?pr=7359

This fixes the deadlock and adds the basic deadlock detection we also
added to Mutexes in emilk#7468.

Also, interestingly, the more sophisticated deadlock detection (behind
the deadlock_detection feature) didn't catch this for some reason. I
wonder why it exists in the first place, when parking_lot also has built
in deadlock detection? It also seems to make tests slower, widget_tests
usually needs ~30s, with the deadlock detection removed its only ~12s.
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
* related emilk#7494

Removes the `deadlock_detection` feature, since we now have a more
primitive panic-after-30s deadlock detection which works well enough and
even detects kinds of deadlocks that the `deadlock_detection` feature
never supported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is broken egui_extras

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants