| Ticket UUID: | 4b705991cfc340daeb6852f70c2d88b6ab0389db | |||
| Title: | ttk/treeview test failures under specific circumstances | |||
| Type: | Bug | Version: | 9.1 | |
| Submitter: | erikleunissen | Created on: | 2025-11-28 09:11:52 | |
| Subsystem: | 88. Themed Tk | Assigned To: | jan.nijtmans | |
| Priority: | 5 Medium | Severity: | Important | |
| Status: | Closed | Last Modified: | 2026-02-05 16:26:19 | |
| Resolution: | Fixed | Closed By: | jan.nijtmans | |
| Closed on: | 2026-02-05 16:26:19 | |||
| Description: |
The following invocation of the ttk test suite:
TESTFLAGS="-file \"spinbox.test treeview.test\"" make test-ttk
makes the tests treeview-10.* fail with the appended test report.
More specifically, the test failures occur if the following conditions hold true:
* Execution of the test file spinbox.test precedes that of treeview.test
* No other test file is executed between spinbox.test and treeview.test.
Notes:
* In a regular invocation of the test suite (without flags: "make test-ttk"),
the test file treetags.test is executed in between these two test files.
That prevents the bug from revealing itself.
* The very first invocation has sometimes been observed to produce no
test failures, but the second and subsequent invocations always did.
* All of this was observed under Linux.
-- test report --
==== treeview-10.0 See command FAILED
==== Contents of test case:
set res ""
lappend res [bbY nn99]
.tv see nn99
lappend res [bbY nn99]
set res
---- Result was:
_ 0
---- Result should have been (exact matching):
_ 180
==== treeview-10.0 FAILED
==== treeview-10.1 See command, auto-open FAILED
==== Contents of test case:
set res ""
lappend res [bbY nn96]
# Not yet visible
lappend res [bbY nn96.n1]
.tv see nn96.n1
lappend res [bbY nn96.n1]
# Pushed out by the opening, not visible
lappend res [bbY nn99]
set res
---- Result was:
_ _ 0 _
---- Result should have been (exact matching):
120 _ 140 _
==== treeview-10.1 FAILED
==== treeview-10.2 See command, height FAILED
==== Contents of test case:
set res ""
lappend res [bbY nn34]
.tv see nn34
lappend res [bbY nn34]
.tv see nn33
lappend res [bbY nn34]
lappend res [bbY nn76]
.tv see nn76
lappend res [bbY nn76]
.tv see nn53
lappend res [bbY nn53]
# Partly visible
lappend res [bbY nn55]
.tv see nn55
# Scrolled to top
lappend res [bbY nn55]
set res
---- Result was:
_ 0 _ _ 0 0 _ 0
---- Result should have been (exact matching):
_ 0 20 _ 100 0 40 0
==== treeview-10.2 FAILED
Tests ended at Fri Nov 28 09:54:19 CET 2025
all.tcl: Total 181 Passed 173 Skipped 5 Failed 3
-- end of message--
| |||
| User Comments: |
jan.nijtmans added on 2026-01-30 14:17:07:
Fixed now, [75303d85d8b436f9|here] @erikleunissen, I fully understand your frustration. As long as we don't fully understand what happened with the unixEmbed-7.1 testcase, it is not fully satisfactory. Still. In your change, you added the line 'wm geometry . +100+100' to the 'resetWindows' function. My tests are indicating that this line is causing the trouble in the unixEmbed-7.1 testcase. Therefore, the best option for now is to revert this tiny part of your change. In return, I added '-geometry +100+100' to the 'childTkProcess' function. That should have the same effect: position the window in a fixed location.
1. What happens to the result of test unixEmbed-7.1 when run on Github CI if:
- we don't remove "wm geometry . +100+100" from proc resetWindows, and
- (as the only change) add/keep "-geometry +100+100" in proc childTkProcess
as it is now in your proposed fix?
I tried this, it doesn't help.
If you find a better solution which doesn't break the unixEmbed-7.1 testcase, please go ahead. It's unfortunate that the current Github CI is broken, otherwise you would have discovered this problem much faster. I hope it will be fixed soon. Thanks for all your efforts. erikleunissen added on 2026-01-29 12:32:40: While the test failures reportedn in this ticket are still gone with
commit [8388321471], I'm not quite comfortable with it.
The fixed position (+100+100) in proc resetWindows was meant to be a uniformity
across test files, as a matter of predictability and convenience for test
authors/maintainers. Why would we want to sacrifice that, just because of
Github CI being the only exception among all other platforms?
That seems like a very big sacrifice to me. Also, it keeps the problematic
aspect at Github CI hidden.
Possible alternatives, in order of (my) decreasing preference:
1. What happens to the result of test unixEmbed-7.1 when run on Github CI if:
- we don't remove "wm geometry . +100+100" from proc resetWindows, and
- (as the only change) add/keep "-geometry +100+100" in proc childTkProcess
as it is now in your proposed fix?
2. Constrain test unixEmbed-7.1 with the test constraint "failsOnCILinux" (or
or a new test constraint "failsOnCIX11" if that's more appropriate) ?
3. (Very, very ugly but it doesn't hide the problem)
Make "wm geometry . +100+100" in proc resetWindows subject to the condition:
if {![info exists ::env(CI)] || ![string match Linux $::tcl_platform(os)]}
jan.nijtmans added on 2026-01-29 10:48:55: I now have a minimal change which fixes this ticket: [83883214712e10ba] Are the "ttk/treeview test failures" still working with this change? erikleunissen added on 2026-01-26 13:08:04: Oops, oops, double negation confusion. The original text:
"Therefore, we can exclude that xvfb makes a difference
when run locally."
was correct.
erikleunissen added on 2026-01-26 13:05:31: Oops, that should be:
a. ... Therefore, we can exclude that using xvfb makes no difference
when run locally.
erikleunissen added on 2026-01-26 11:25:38: In the meantime, without having access to Github, I tested the following hypotheses
for the cause of the test failure on Github (locally):
a. It is due to Github using xvfb instead of a regular X-server plus window manager.
Therefore, I ran test unixEmbed-7.1 at current trunk ([255cf88e30]), using xvfb[1].
Result: the test passes. Therefore, we can exclude that xvfb makes a difference
when run locally [2].
b. Somehow the command "raise ." has an effect on Github/X11.
This can only happen if the raise command operates on toplevel windows created by
the Tk process that issues the raise command ("." in test unixEmbed-7.1), and at
the same time on toplevel windows created by an external process (".t1"), affecting the
stacking order of these toplevels relative to each other. Moreover, it would need
to have an effect if the toplevel .t1 from the external process is embedded in the
toplevel "." (via frame ".f1"). I'm unsure whether all of this is even possible,
but let's assume so for the sake of the present issue.
Therefore, I ran several variants test unixEmbed-7.1, where "." (main process) and
".t1" (external process), are raised or lowered (diff for one variant appended [3]).
Note that in theory all these raise and lower invocations are expected to be futile
because in each process there is only one single toplevel window mapped.
Result: all these test variants could not be made to FAIL, either in a regular wm setup
(KDE/Plasma), or when using xvfb.
Overall conclusion:
* I'm still clueless about what makes test unixEmbed-7.1 FAIL at Github CI.
* Further investigation requires access to Github CI.
* If further experimentation reveals what makes the test pass again at Github,
then it seems to be exceptional and specific for that environment. This, in turn,
would lead me to add an exception for this environment to the test unixEmbed-7.1,
which makes it pass there or which makes it be skipped there.
--
[1] Using the following invocation:
xvfb-run --auto-servernum make test-classic TESTFLAGS="-file unixEmbed.test -match unixEmbed-7.1* -verbose beps"
[2] Moreover but not directly related, test unixEmbed-7.1a, which fails on X11, KDE/Plasma,
passes under xvfb.
[3]
--- tests/unixEmbed.test
+++ tests/unixEmbed.test
@@ -931,14 +931,16 @@
childTkProcess eval {
destroy {*}[winfo children .]
toplevel .t1 -use $w1
}
focus -force .
+ lower .; after 100; update; # <==========
bind . <Key> {lappend x {key %A %E}}
set x {}
set y [childTkProcess eval {
update
+ raise .t1; after 100; update; # <==========
bind .t1 <Key> {lappend y {key %A}}
set y {}
event generate .t1 <Key> -keysym a
set y
}]
erikleunissen added on 2026-01-23 23:24:00: Regarding:
... the forwarding of keystrokes from a child Tk process to the parent
Tk process. I've never heard/read about this facility before, and I don't
see it mentioned in the docs under the options "-use" and "-container".
Ah, that's probably (from man toplevel):
"Be aware that bindings on toplevels may receive events from subwidgets."
where in the present specific case, the subwidget is inside a container.
erikleunissen added on 2026-01-23 22:49:52: * Hmmm, bummer! * I'm unfamiliar with the specific subject of test unixEmbed-7.1, which appears to be the forwarding of keystrokes from a child Tk process to the parent Tk process. I've never heard/read about this facility before, and I don't see it mentioned in the docs under the options "-use" and "-container". If someone knows about where this is documented, then please share a pointer here. * Regardless, right now I don't see how the change brought about by this ticket could logically affect the test. In other words: I haven't got a clue. * We could conduct some experiments that restore the changes in the bug-fix branch one by one, independently, to see whether a particular one leads to the test failure, and hope that that provides a clue. Alas, I can't do that myself as long as Tk CI is non-functional. jan.nijtmans added on 2026-01-23 11:49:15: I'm sorry, having to re-open this ticket. I managed to do CI runs on Github, and there is one testcase failing: unixEmbed.test I cannot reproduce this locally, it only happens in the Github CI environment when X11 is involved. So, I did a fossil bisect: ~/workspace/tk9.0 $ fossil bisect chart 2 BAD 2026-01-23 08:45:50 9971917ac9849160 5 BAD 2026-01-13 22:21:48 89d6a2714814480e 6 BAD 2026-01-13 11:51:26 14df848ebca46307 8 GOOD 2026-01-13 08:09:24 ca119ea2c940090e 7 GOOD 2026-01-12 15:10:00 efb65fb087cfa7d4 4 GOOD 2026-01-12 12:54:01 acd26ce5bca7abbe 3 GOOD 2026-01-05 16:54:50 9dc4ab334626c436 1 GOOD 2025-12-10 21:13:32 0da56f6f8560a36f This shows that [14df848ebca46307|this] commit introduced the issue. I (locally) reverted this commit and pushed everything. The result is that all test-cases are passing now: https://github.com/nijtmans/tk/actions?query=branch%3Amain++ Any idea what could cause this testcase failure? How could this be fixed? Tk 9.0 has the same problem. erikleunissen added on 2026-01-13 11:56:54: Merged the bug-fix branch into trunk and core-9-0-branch. Closing the ticket now. erikleunissen added on 2026-01-08 13:38:11: The full Tk test suite was run on my own development machines to see whether the bug-fix branch introduces any extra test failures or test file failures. This appears not to be the case for all major platforms: Linux/x11, MS Windows/win32, macOS/aqua. Alas, the same exercise is not possible on Github CI since it is inoperative for Tk. Therefore, I'm inclined to err on the safe side and wait until Github CI is up and running again. But I'm OK to carry out the merge without exercising on Github CI if a TCT-member agrees so. erikleunissen added on 2025-12-30 15:26:49: OK. Thanks Jan. jan.nijtmans added on 2025-12-29 21:26:38: Thanks for this elaborate analysis! All looks good to me. Just go ahead! erikleunissen added on 2025-12-29 18:41:46: Review of the fix is welcomed ! erikleunissen added on 2025-12-29 17:02:41: Added proposed fix plus non-regression test to branch [bug-4b705991cf] erikleunissen added on 2025-12-29 16:31:16: Further analysis, targetting proc "resetWindows" on Linux/x11:
* the proc is currently defined in testutils.tcl as follows:
proc resetWindows {} {
deleteWindows
wm geometry . {}
raise .
update
}
* the command "wm geometry . {}" inside "resetWindows" intends to reset the
root window's property to adapt its size to its mapped children.
* the reported misbehaviour does not crop up when when evaluating test file
treetags.test in between spinbox.test and treeview.test. The relevant effect
of evaluating treetags.test in between is an extra execution of proc
resetWindows. It fails to achieve its intended effect the first time
(in treetags.test), and succeeds the second time (in treeview.test).
* the misbehaviour also disappears if:
- an extra "update" is placed between the two immediately successive commands
"wm geometry . {}" and "raise ."
- the command "raise ." is simply removed.
Therefore, the ineffectiveness of "wm geometry . {}" appears to be caused
by interference of the immediately successive command "raise ."
* the issue does not depend on the window manager in use. (I'm guessing that the
X-server is doing something "special" when confronted with these two commands
when in immediate succession.)
* I don't recognize the usefulness of "raise ." at all because, at the time of
evaluating this command, there are no sibling windows of the Tk root window
(at least not in the same process) above which the root window can be raised.
* the position of the root window on the screen is set in main.tcl. This is better
handled by proc resetWindows.
For these reasons, the proposed fix is to remove the command "raise ." from
proc resetWindows, let it reset the size and position of the root window, and
resolve redundancy in main.tcl.
erikleunissen added on 2025-12-29 16:29:06: The cause of the issue is twofold:
1. Test spinbox-3.0 changes the geometry of the Tk root window in a way that
is unsuitable for tests 10.* in treeview.test. This happens at the following
code line:
[https://core.tcl-lang.org/tk/file?ci=b838672ce6e0ff99&name=tests%2Fttk%2Fspinbox.test&ln=233]
2. The Tk root window is not reverted to a suitable geometry before execution
of tests treeview-10.*, unless test file treetags.test is evaluated in the
meantime.
Remarkable aspects:
* the issue occurs on Linux/x11, but not on win32 or macOS/aqua.
* the call to proc "resetWindows" in the section TESTFILE INITIALIZATION of
each test file is (among others) intended to initialize or reset the
widthxheight geometry of the Tk root window. Apparently, this proc falls short.
The observed misbehaviour can be remedied by several methods:
a. use another toplevel window than the root window for test spinbox-3.0.
b. restore the geometry of the Tk root window after having changed it in test
spinbox-3.0. This can be done in test spinbox-3.0 or elsewhere in test file
spinbox.test.
c. adapt the proc "resetWindows" to live up to its expectations.
While methods a. and b. prevent the reported misbehaviour by addressing test
hygiene of test spinbox-3.0, method c. addresses an essential flaw regarding
a basic proc on which all test files ought to be able to rely. Therefore,
method c. supersedes methods a. and b.
My conclusion is that the fix for the present issue should be based on method c.
| |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki