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.
This commit is contained in:
HMITCHR authored and GitHub committed 2026-10-29 14:43:38 -05:00
1 parent 6112429980
commit 3610d8bb35
1 file changed
+6 -4
+6 -4
View File
@@ -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;
}