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

Windows DispatcherQueue freezes #941

Closed
6 tasks
dalyIsaac opened this issue Jul 5, 2024 · 2 comments
Closed
6 tasks

Windows DispatcherQueue freezes #941

dalyIsaac opened this issue Jul 5, 2024 · 2 comments
Labels
bug Something isn't working core Whim

Comments

@dalyIsaac
Copy link
Owner

dalyIsaac commented Jul 5, 2024

The DispatcherQueue will eventually stop executing enqueued callbacks. At the same time, the Bar freezes and no longer updates.

  • Remove InitializeCoreDispatcher
  • Does the queue get overloaded?
  • Does .NET 8 upgrade #677 help?
  • Reduce the number of TryEnqueues, based on whether there are events to dispatch.
  • What does attaching debug symbols show?
  • Move back to WPF?
@dalyIsaac dalyIsaac added this to Whim Jul 5, 2024
@dalyIsaac dalyIsaac converted this from a draft issue Jul 5, 2024
@dalyIsaac dalyIsaac added bug Something isn't working core Whim labels Jul 5, 2024
@urob urob mentioned this issue Jul 6, 2024
1 task
dalyIsaac added a commit that referenced this issue Jul 6, 2024
Whim would previously enqueue at the end of every transform, even if there weren't any queued events. I suspect that this may be the case of #941 (without any evidence at this stage). Regardless of whether it is, I think it's a worthy check to put in place.
@dalyIsaac
Copy link
Owner Author

dalyIsaac commented Jul 6, 2024

I have a higher level of confidence that it's because number of DispatchEvents callbacks gets too large which crashes the UI thread:

2024-07-06 22:47:04.474 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.477 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.480 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.483 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.487 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.492 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.495 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.499 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.502 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.505 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.508 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.510 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.512 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.515 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.518 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.521 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.523 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.526 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.528 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.531 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.533 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.536 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.538 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.541 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.543 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.546 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.549 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.552 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.554 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.557 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.559 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.562 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.564 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.566 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.569 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.572 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.574 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.577 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.580 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.582 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.584 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.586 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.589 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.591 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.594 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.596 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.599 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.601 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.603 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.606 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.609 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.612 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.615 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.617 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.621 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.624 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.627 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.630 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.633 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.635 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.638 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.641 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.643 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.646 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.649 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.652 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.654 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.656 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.658 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.660 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.663 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.665 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.668 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.670 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.673 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.676 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.678 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.680 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.683 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.685 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.688 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.690 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events
2024-07-06 22:47:04.693 +10:00 [DBG] MutableRootSector:37           [DispatchEvents]               Dispatching events

Proposed fix:

  • Only enqueue if no other DispatchEvents are enqueued.
  • Have a lock to protect this.

dalyIsaac added a commit that referenced this issue Jul 7, 2024
This PR reduces the amount of event dispatches being enqueued onto the STA thread. Previously, it was possible to have the STA thread execute >80 callbacks queued and for them all to execute within 300ms.

This is related to #941.
dalyIsaac added a commit that referenced this issue Jul 28, 2024
Previously, Whim would enqueue a `DoLayout` whenever a window moved. This was done to account for windows doing atypical things, like trying to restore their own position.

This worked prior to Whim becoming multi-threaded. Now that it is, this is no longer a viable approach. The `WindowMovedTransform` is triggered many times by Whim. Accordingly, the enqueueing of `DoLayout` similarly is done many times, sometimes overloading the main thread (related issues: #941, #944).

This PR allows custom logic for handling events for specific types of windows. `IWindowProcessor` s specify whether to ignore the current Windows event. A `FirefoxWindowProcessor` has been implemented to account for atypical behavior by Firefox during startup.
@dalyIsaac
Copy link
Owner Author

Likely addressed in aforementioned issues and PRs.

@github-project-automation github-project-automation bot moved this from In progress to Done in Whim Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core Whim
Projects
Status: Done
Development

No branches or pull requests

1 participant