|
2026-10-12
| ||
| 05:29 | • Ticket [f1fe739a] Embedded application exits with an X error when its container is destroyed while it draws or claims the focus status still Open with 3 other changes artifact: 010b1fa1 user: chw | |
|
2026-10-10
| ||
| 09:07 | • Ticket [f1fe739a]: 3 changes artifact: 643b9f99 user: serhiy.storchaka | |
| 09:03 | Fix [f1fe739a4f]: An embedded application exited with an X error when its container was destroyed while it drew or claimed the focus. Create pixmaps for the root window of the screen of the drawable, as suggested by chw, so they are created even if the window no longer exists; this also applies to the scratch pixmap for drawing photos with alpha. Create GCs for the root window or a pixmap of the right depth: Tk_GetGC uses the depth of the window, Tk_GCForColor that of the visual of the color, since a shared GC created for a destroyed window was invalid also in live windows. Ignore RenderBadPicture errors when Xft draws text directly into a window, and BadGC for the temporary GC used to draw rotated text without Xft. The events sent to the window of the other application are protected by error handlers. Tests unixEmbed-9.4 to 9.7. leaf check-in: 773aaf31 user: serhiy.storchaka tags: embed-container-destroyed-root-pixmap | |
| 08:50 | Fix [f1fe739a4f]: GCs were created for the window or the drawable passed; if the window of an embedded application had been destroyed by its container, the shared GC was not created and later drawing with it in live windows failed with BadGC. Create GCs for the root window or a pixmap of the right depth: Tk_GetGC uses the depth of the window, Tk_GCForColor that of the visual of the color. Ignore BadGC for the temporary GC used to draw rotated text without Xft. Test unixEmbed-9.7. check-in: 36c75c29 user: serhiy.storchaka tags: embed-container-destroyed-pixmap | |
| 08:20 | Test unixEmbed-9.6 [f1fe739a4f]: a message widget, which draws its text directly into its window, redrawn after the container was destroyed. check-in: dded6fa5 user: serhiy.storchaka tags: embed-container-destroyed-pixmap | |
| 05:34 | • Ticket [f1fe739a] Embedded application exits with an X error when its container is destroyed while it draws or claims the focus status still Open with 6 other changes artifact: 6df919df user: chw | |
|
2026-10-09
| ||
| 15:55 | • Ticket [5f7ba8c5] Leakage in trunk, with --disable-xft build status still Open with 3 other changes artifact: e3e48435 user: serhiy.storchaka | |
| 08:46 | • Ticket [a4fa3ad2] event misbehavior with certain widgets when embedding status still Open with 3 other changes artifact: 1472aeed user: serhiy.storchaka | |
| 08:37 | unixEmbed tests [a4fa3ad2d6]: make the focus tests independent of the previous tests. Restart the child process in the cleanup of unixEmbed-5.4 before destroying the container, so that its focused entry is not redrawn after the container is destroyed (which killed it with an X error, see [f1fe739a4f]) and its focus state does not affect the following tests. Move the pointer away in the setup of unixEmbed-5.1 to 5.4, 7.1 and 7.2, as in 8.1: without a window manager the child got the focus implicitly if its main window appeared under the pointer (see [0c3bb74e37]). check-in: f98ef68b user: serhiy.storchaka tags: x11-embed-focus-return | |
| 07:25 | • Ticket [f1fe739a] Embedded application exits with an X error when its container is destroyed while it draws or claims the focus status still Open with 1 other change artifact: f591a65f user: serhiy.storchaka | |
| 07:08 | • Ticket [f1fe739a]: 3 changes artifact: 31c9c3e5 user: serhiy.storchaka | |
| 07:03 | • New ticket [f1fe739a]. artifact: 53aaf4ed user: serhiy.storchaka | |
| 07:03 | Fix [f1fe739a4f]: An embedded application exited with an X error when its container was destroyed while it drew into a double-buffer pixmap or claimed the focus. A pixmap created for a window which no longer exists is not created; ErrorProc() now ignores the errors for such a pixmap until it is freed, and Xft text drawing ignores RenderBadPicture errors for its picture. The events sent to the window of the other application are protected by error handlers. Tests unixEmbed-9.4 and 9.5. check-in: ea14f65c user: serhiy.storchaka tags: embed-container-destroyed-pixmap | |
| Ticket UUID: | f1fe739a4fbb046d66e20cc82ecdf9fa72106662 | |||
| Title: | Embedded application exits with an X error when its container is destroyed while it draws or claims the focus | |||
| Type: | Bug | Version: | 8.6.18, 9.0.5, 9.1.0 | |
| Submitter: | serhiy.storchaka | Created on: | 2026-10-09 07:03:43 | |
| Subsystem: | 74. Application Embedding | Assigned To: | aku | |
| Priority: | 5 Medium | Severity: | Important | |
| Status: | Open | Last Modified: | 2026-10-12 05:29:46 | |
| Resolution: | None | Closed By: | nobody | |
| Closed on: | ||||
| Description: |
An embedded application still exits with an X error if its container is destroyed while it is drawing or setting the focus, although [4a25f316f7] made ErrorProc() ignore errors for windows which no longer exist. Destroy the container while the embedded application does not process events, then let it redraw an entry or call focus -force (as in unixEmbed-9.3): X Error of failed request: BadDrawable (invalid Pixmap or Window parameter) Major opcode of failed request: 70 (X_PolyFillRectangle) X Error of failed request: BadWindow (invalid Window parameter) Major opcode of failed request: 25 (X_SendEvent) An entry (like other double-buffered widgets) draws into a pixmap created for its window. Creating the pixmap fails, and this error is ignored, but the pixmap does not exist, so the following requests which draw into it fail with errors for the pixmap, which are not ignored; with Xft, drawing text also fails with RenderBadPicture, since the XRender picture for the pixmap is not created either. focus -force sends an event to the container, which is not protected by an error handler. This makes test unixEmbed-5.4 of branch x11-embed-focus-return fail intermittently in CI (the embedded entry keeps the focus and redraws its blinking insertion cursor after the container is destroyed), which kills the embedded application and makes the following unixEmbed tests fail with "broken pipe". | |||
| User Comments: |
chw added on 2026-10-12 05:29:46:
So far so good. Now I wonder, if the logic around "deletedWinTable" is needed at all. Given that BadWindow and BadDrawable errors are dealt with in the tkError.c module (i.e. masked as long as the Window identifier is known), and that at known places e.g. in tkUnixFont.c and friends specific other errors are enclosed with Tk_Create/DeleteErrorHandler, nothing should be left requiring a bookkeeping heuristic of recently destroyed window identifiers. Remember, the latest Pixmap and GC changes decoupled their allocation from (possibly invalid) Window identifiers, since these resources are bound to the Display/Screen combination anyway. There's still Picture from Xft/XRender, which can have a direct relation to a Window, but this can be specifically dealt with using the Tk_ErrorHandler mechanism in the font rendering functions in tkUnixRFont.c. serhiy.storchaka added on 2026-10-10 09:07:13: Thank you, Christian. I tried this in branch embed-container-destroyed-root-pixmap: pixmaps are created for the root window, so tracking the pixmaps which could not be created is not needed, and it is simpler than embed-container-destroyed-pixmap. GCs have the same problem: Tk_GetGC() and Tk_GCForColor() created them for the widget's window or its double-buffer pixmap. A GC created after the container was destroyed is invalid, and since GCs are shared, drawing with it fails also in live windows. Both branches now create GCs for the root window or a pixmap of the right depth. Text drawn by Xft directly into a window (e.g. by a message widget) still needs a handler for RenderBadPicture in both. New tests unixEmbed-9.6 and 9.7. chw added on 2026-10-10 05:34:21: Maybe the BadPixmap error can be avoided entirely. According to the
man page of XCreatePixmap, the Drawable "d" argument has to specify
a drawable of the screen of the display the pixmap is to be used on.
Serendipitously, the root window of the screen of the display is such
a drawable and always available, even if the X11 window of the respective
Tk_Window/TkWindow has been (asynchronously) destroyed.
So in cases where a Tk_Window/TkWindow is involved, this Drawable can
be retrieved by a macro like
#define Tk_DrawableForPixmap(tkwin) \
RootWindow(Tk_Display(tkwin), Tk_ScreenNumber(tkwin))
serhiy.storchaka added on 2026-10-09 07:08:20: Proposed fix in branch embed-container-destroyed-pixmap: ErrorProc() remembers a pixmap whose creation failed because the window no longer exists, and ignores the errors for it until it is freed; Xft text drawing ignores RenderBadPicture errors; the events sent to the window of the other application are protected by error handlers. New tests unixEmbed-9.4 and 9.5. | |||
