Commit 54d7443
linux: fix window-close hang, popup lifecycle, PDF frame crash
Three independent fixes for the CEF 146 Linux embedding path:
1. window_utils_linux: _on_configure — replace XResizeWindow+XSync with
NotifyMoveOrResizeStarted()+SetBounds(). XSync() blocks the Python GIL
on every GTK configure-event; when the GIL is held the GLib event loop
stalls, the window manager marks the window as unresponsive, and sends a
spurious WM_DELETE_WINDOW that closes the browser unexpectedly.
SetBounds() already calls XConfigureWindow+XFlush internally, so the
explicit XResizeWindow was redundant. NotifyMoveOrResizeStarted() is
required before SetBounds() so the CEF compositor can prepare.
2. window_utils_linux: _on_delete / QuitMessageLoop — two related fixes:
a. Add _linux_close_popup_browsers() called from _on_delete so that any
JS-created popup browsers are queued for close in the same drain pass
as the main browser, avoiding Shutdown()'s emergency force-close path.
b. Always call gtk_main_quit() in _on_delete. When _on_delete returns
False, GTK destroys the X11 parent window which also destroys CEF's
embedded child window via the X11 parent-child relationship. CEF does
not fire OnBeforeClose through its normal path after that, so
QuitMessageLoop() would never be called and the GLib timer would spin
MessageLoopWork() at 100% CPU indefinitely. The drain loop in
_linux_message_loop() handles remaining cleanup after gtk_main()
returns.
c. Guard QuitMessageLoop()'s gtk_main_quit() with gtk_main_level() > 0
to suppress the "assertion 'main_loops != NULL' failed" GTK warning
that fires when QuitMessageLoop() runs during the post-gtk_main() drain
after _on_delete has already called gtk_main_quit().
3. frame: GetPyFrame — replace the blanket assert on frameId/browserId with
a targeted Exception for browserId==0 only. CEF 146 fires OnLoadStart
with an empty frameId for internal frames created before the renderer
frame is ready (e.g. the PDF-viewer extension frame). The assert was
incorrectly blocking the frameId.empty() handling that already existed
below it, causing an AssertionError → ExceptHook → abort when loading
any PDF URL.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 509f2ac commit 54d7443
3 files changed
Lines changed: 51 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
959 | 959 | | |
960 | 960 | | |
961 | 961 | | |
962 | | - | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
963 | 969 | | |
964 | 970 | | |
965 | 971 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
261 | 280 | | |
262 | 281 | | |
263 | 282 | | |
| |||
285 | 304 | | |
286 | 305 | | |
287 | 306 | | |
288 | | - | |
289 | | - | |
290 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
291 | 314 | | |
292 | 315 | | |
293 | 316 | | |
| |||
301 | 324 | | |
302 | 325 | | |
303 | 326 | | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
304 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
305 | 340 | | |
306 | 341 | | |
307 | 342 | | |
| |||
0 commit comments