SIGN IN SIGN UP

Marshal Form.TopMost to the GUI thread in the WinForms backend (#1831)

set_on_top assigned Form.TopMost directly on the calling thread. When called
from a non-GUI thread (e.g. a js_api handler, which pywebview runs on a worker
thread), this is an unmarshaled cross-thread operation on a WinForms control,
and the message pump can deadlock permanently while the system is doing window
activation work — the window goes to Not Responding with no exception raised.

Every other window operation in this backend already marshals via Invoke
(show, hide, toggle_fullscreen, maximize, minimize, restore); set_on_top was
the exception. This applies the same pattern, with the InvokeRequired guard
used by toggle_fullscreen so calls already on the GUI thread stay direct.
F
fjmarson committed
14407ce98f65a288ec21dadc7cfb0ff54c5aa2eb
Parent: 350810f
Committed by GitHub <noreply@github.com> on 8/27/2026, 12:28:53 PM