| Ticket UUID: | deca13e833cb782ce20f666df27c5dfdfab168d0 | |||
| Title: | Tests fail at high display scale | |||
| Type: | Bug | Version: | 9.1.0 | |
| Submitter: | serhiy.storchaka | Created on: | 2026-10-02 13:45:42 | |
| Subsystem: | 86. Test Tools | Assigned To: | aku | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Open | Last Modified: | 2026-11-20 14:55:41 | |
| Resolution: | None | Closed By: | nobody | |
| Closed on: | ||||
| Description: |
Many tests fail when the display scale is higher than 100% (96 DPI), e.g. about 300 tests on Windows at 350%. At least some of them fail on macOS too, e.g. frame-12.3 and textImage-4.2. The causes:
Proposed fix in branch tests-high-dpi, a separate commit for every item. With it all tests pass on Windows at 100% to 350% and on X11 at 96 to 336 DPI, with and without a window manager. It was not tested on macOS. Test bind-34.2 also needs the fix for [3f1ad1ff50]. For the first item, the new test utility removeTitleBar removes the title bar of the test windows at high scale. It is only one possible solution. The alternative is to make all sizes in these tests larger than the minimal width, computed so that the windows still fit the screen, but this would change many more lines. | |||
| User Comments: |
jan.nijtmans added on 2026-11-20 14:55:41:
> Please cancel one of them. I canceled core-tests-high-dpi, instead ran everything under my own (nijtmans/tk) github account. Everything passed, so I merged everything to trunk and core-9-0-branch. serhiy.storchaka added on 2026-11-20 09:19:06: None of the four custom core-* tags (core-tests-high-dpi, core-mojibake_integration, core-ftd-progstate, core-ftd-eyefriendly) got a CI run tonight: the nightly sync holds back when more than three tags are set. Please cancel one of them. serhiy.storchaka added on 2026-11-15 22:06:31: It comes from Windows. "Courier" there is an old raster font with only a few sizes, and at 150% courier 12 gets a size for which GDI reports variable pitch, although all its characters have the same width. Tk only passes this on, so font metrics -fixed returns 0. That is surprising, but probably not critical. font-10.9 mainly checks that these options are accepted; only the result of the last one is compared. Using TkFixedFont (Courier New on Windows), as on X11, avoids depending on the raster font. erikleunissen added on 2026-11-15 20:53:09: Hi Serhiy, Regarding:
I don't quite understand whether the shortcoming originates from MS Windows or from Tk. Could you please explain? serhiy.storchaka added on 2026-11-08 10:49:46: Branch tests-high-dpi is rebased on trunk:
The other changes are already merged. With the branch, of the changed test files only winWm-11.1 and wm-geometry-2.2 fail on Windows at 350%. serhiy.storchaka added on 2026-11-07 18:33:42: Branch tests-min-width is merged into trunk [672afed883] and backported to core-9-0-branch [21892ec6c4] and core-8-6-branch [d6121ae3be]. On the wayland branch the notWayland constraint was removed from the tests fixed by it [17d0ac78cf]. Still failing on Windows at 350%: most of pack.test, 11 grid tests, and textDisp-27.7, textDisp-27.7.1 and textDisp-27.7.2. serhiy.storchaka added on 2026-10-20 09:20:19: Branch tests-min-width tries the alternative to removeTitleBar: the windows are made wider (480 pixels), or the widgets are laid out in a frame which is not resized with the toplevel, so the expected results do not change. The workaround with wm overrideredirect in textDisp.test and text.test is no longer needed. An additional argument for this way: the same tests fail on the wayland branch, where a toplevel with client-side decorations is at least 180 pixels wide, and there the title bar cannot be removed. So far it covers only the tests which fail on Wayland. About 110 tests, mostly in pack.test, still fail on Windows at 350%; most of them could be fixed in the same way. serhiy.storchaka added on 2026-10-08 05:08:19: Thank you for the idea. I tested it on Windows 11: the title does not matter. The minimal width of a toplevel is the same for the title "tktest", an empty title, or a long title: 120 pixels at 100% and 404 pixels at 350%. It is determined by the frame and the buttons of the title bar. It applies to the root window and to any other toplevel, but not to toolwindows (wm attributes -toolwindow 1) and override-redirect windows. Other alternatives are using toolwindows in tests on Windows, or testing geometry managers on a frame of fixed size instead of on a toplevel. The latter would be the most reliable, but even more invasive, and it would not help the event and wm tests, which test the toplevel itself. In the text tests [96ca9851d7] already does something similar: the text widget is no longer packed with -fill, so it keeps its own size. erikleunissen added on 2026-10-07 21:06:28: Correction: where I wrote "the width of the title bar", I meant:
"the minimum width of the title bar"
erikleunissen added on 2026-10-07 20:54:02: Here is another idea:
Presumption: the width of the titlebar is core to the issue.
The width of the titlebar is determined by the elements that it contains,
which are buttons (for closing, iconifying and maximizing the window) and
the title. A less intrusive, generic measure could be to target the title:
Currently the title of the main window is set to "tktest" here:
[https://core.tcl-lang.org/tk/file?ci=eec7513de860b2a7&name=tests%2Fmain.tcl&ln=
25]
What if we set it to the empty string?
serhiy.storchaka added on 2026-10-07 19:04:26: Thank you for your review and for merging the fixes, Erik! Most modern HiDPI monitors use a display scale above 100%. If the tests passed only at 100%, we could not run them on such computers, and the tests we run would not test what is really used. Forcing 100% in tests/main.tcl would not help either. It can only set tk scaling, which converts points to pixels. That would fix the tests that use fonts and lengths in points, but not the real display scale: on Windows the minimal width of a toplevel (the width of its title bar) and the size of the scrollbar arrows are system metrics, which follow the display scale whatever tk scaling is. I am not happy with the fix for the title bar width [96ca9851d7] either, but the alternative is to change all sizes used in these tests, which is even more invasive. I am not sure my solution is the best, and I will be glad to see a better alternative. erikleunissen added on 2026-10-07 18:38:23: General considerations regarding this ticket:
* Thus far, I selected three changes from this ticket for merging. My reason
for agreeing to them doesn't actually involve the scaling factor (which is
a subject that I'm not very familiar with).
* Requiring display scaling to work as intended is one thing (and merits its
own tests). However, requiring all Tk tests to PASS at any or various setting
for display scaling is an entirely different matter. I am not convinced that
that is entirely useful.
Also, when looking at the fix for this issue:
* Windows does not let a toplevel be narrower than its title bar
(404 pixels at 350%). pack, grid, place, panedwindow, listbox,
canvWind, wm, winWm, event and text tests.
at [96ca9851d7] I find the changes quite intrusive, which contributes
to my being unconvinced.
Alternatively, we could limit ourselves to requiring that Tk tests PASS with
a single scaling factor (100 % would be a natural choice), and enforce that
by hard-coding that scaling factor in tests/main.tcl for a global effect
across all test files in the Tk test suite.
That said, my gut isn't always right, and as I said: I'm not very familiar
with display scaling. Therefore, I think that more people expressing their
opinion regarding the matter would be valuable.
serhiy.storchaka added on 2026-10-07 04:41:48: No, I do not test on macOS. I took frame-12.3 and textImage-4.2 from your report "test failures in 8.6" on tcl-core (1 October), and assumed the same cause, since both fail on X11 and Windows at high display scale. If they fail on macOS only in 8.6, the cause there is probably different. marc_culler (claiming to be Marc Culler) added on 2026-10-07 01:55:17: As far as I know, the macOS failures of frame-12.3 and textImage-4.2 only occur in 8.6. Have you seen macOS failures caused by screen resolution in 9.0 or 9.1? erikleunissen added on 2026-10-06 18:33:56: Regarding: * bind-34.1 moves a window off a small screen, e.g. 800x600. Agreed and merged into trunk and core-9-0-branch. erikleunissen added on 2026-10-05 10:22:20: I agree with:
* State left by other tests: pack-20.6 did not restore
<tt>pack propagate .</tt>, event.test leaves the pointer over the
larger windows of focus.test.
The latter change slightly adapted to be robust against any screen size.
Merged into trunk and core-9-0-branch. Thanks!
erikleunissen added on 2026-10-02 19:56:34: And I merged that particular change into trunk and core-9-0-branch, commits [7517b79368] and [6e42783e36] respectively. erikleunissen added on 2026-10-02 19:36:12: Regarding the changes to test event-c3f5c85322: I agree that they are an improvement. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki