From 3610d8bb35a6129baed6f110efcc2a7aaa5fe900 Mon Sep 17 00:00:00 2001 From: HMITCHR <265609730+HMITCHR@users.noreply.github.com> Date: Thu, 29 Oct 2026 13:43:38 -0600 Subject: [PATCH] Do not prebuild pages while a modal dialog is open (#16994) On macOS the app could hang at 100% CPU when a project with customized presets was opened into a running app and the message box was closed while the idle prebuild was building the Project page's web view. The web view waits for WebKit in a wxYield() loop, and closing the dialog aborts the modal session, so the reply never arrives. The idle scheduler now runs a slice only in the main event loop, so no pages are built while a modal dialog is open. Building resumes when the dialog closes. --- src/slic3r/GUI/IdleScheduler.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/IdleScheduler.cpp b/src/slic3r/GUI/IdleScheduler.cpp index bd40288678..309ffcb194 100644 --- a/src/slic3r/GUI/IdleScheduler.cpp +++ b/src/slic3r/GUI/IdleScheduler.cpp @@ -45,11 +45,13 @@ bool input_pending() #endif } -// True inside a wxYield(), where a slice would build pages in the middle of the code that yielded. -bool yielding() +// True inside a wxYield() or a nested loop such as a modal dialog's, where a slice would build pages in +// the middle of the code that is waiting. A new web view waits for WebKit in a yield loop; if the dialog +// closes meanwhile, macOS aborts its modal session, the reply never arrives and the app hangs. +bool in_nested_loop() { const wxEventLoopBase* loop = wxEventLoopBase::GetActive(); - return loop != nullptr && loop->IsYielding(); + return loop != nullptr && (loop->IsYielding() || !loop->IsMain()); } } // namespace @@ -79,7 +81,7 @@ void IdleScheduler::tick() stop(); return; } - if (m_input_idle_ms() < quiet_ms || input_pending() || yielding()) { + if (m_input_idle_ms() < quiet_ms || input_pending() || in_nested_loop()) { start(); return; }