mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-03 08:54:04 +00:00
728a874b1e
Some checks are pending
CI / Check Postgres and Protobuf migrations, mergability (push) Waiting to run
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Linux) Build Remote Server (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Linux x86_x64 release bundle (push) Blocked by required conditions
CI / Linux arm64 release bundle (push) Blocked by required conditions
CI / Auto release preview (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
Script / ShellCheck Scripts (push) Waiting to run
Closes #22653 After some investigation, I found this bug is due to that sometimes `foreground_task` is not dispatched to the main thread unless there is user input. The current Windows implementation works as follows: when the `WindowsDispatcher` receives a `foreground_task`, it adds the task to a queue and uses `SetEvent(dispatch_event)` to notify the main thread. The main thread then listens for notifications using `MsgWaitForMultipleObjects(&[dispatch_event])`. Essentially, this is a synchronous method, but it is not robust. For example, if 100 `foreground_task`s are sent, `dispatch_event` should theoretically be triggered 100 times, and `MsgWaitForMultipleObjects(&[dispatch_event])` should receive 100 notifications, causing the main thread to execute all 100 tasks. However, in practice, some `foreground_task`s may not get a chance to execute due to certain reasons. As shown in the attached video, when I don't move the mouse, there are about 20-30 `foreground_task`s waiting in the queue to be executed. When I move the mouse, `run_foreground_tasks()` is called, which processes the tasks in the queue. https://github.com/user-attachments/assets/83cd09ca-4b17-4a1f-9a2a-5d1569b23483 To address this, this PR adopts an approach similar to `winit`. In `winit`, an invisible window is created for message passing. In this PR, we use `PostThreadMessage` to directly send messages to the main thread. With this implementation, when 100 `foreground_task`s are sent, the `WindowsDispatcher` uses `PostThreadMessageW(thread_id, RUNNABLE_DISPATCHED)` to notify the main thread. This approach enqueues 100 `RUNNABLE_DISPATCHED` messages in the main thread's message queue, ensuring that each `foreground_task` is executed as expected. The main thread continuously processes these messages, guaranteeing that all 100 tasks are executed. Release Notes: - N/A |
||
---|---|---|
.. | ||
app | ||
elements | ||
keymap | ||
platform | ||
text_system | ||
window | ||
action.rs | ||
app.rs | ||
arena.rs | ||
asset_cache.rs | ||
assets.rs | ||
bounds_tree.rs | ||
color.rs | ||
element.rs | ||
executor.rs | ||
geometry.rs | ||
global.rs | ||
gpui.rs | ||
input.rs | ||
interactive.rs | ||
key_dispatch.rs | ||
keymap.rs | ||
platform.rs | ||
prelude.rs | ||
scene.rs | ||
shared_string.rs | ||
shared_uri.rs | ||
style.rs | ||
styled.rs | ||
subscription.rs | ||
svg_renderer.rs | ||
taffy.rs | ||
test.rs | ||
text_system.rs | ||
util.rs | ||
view.rs | ||
window.rs |