Tk Source Code

View Ticket
Login
Ticket UUID: 2031258
Title: problem with Aqua Tk_Text in Tk>8.4
Type: Bug Version: obsolete: 8.5.3
Submitter: vaclav042 Created on: 2008-07-29 10:29:17
Subsystem: 18. [text] Assigned To: cc_benny
Priority: 5 Medium Severity:
Status: Open Last Modified: 2026-10-08 12:36:10
Resolution: None Closed By:
    Closed on:
Description:
I have come across a problem with Tk-text widgets for Tk>8.4, i.e  the new improved widgets. 
Up to and including 8.4.x, text widgets took a long single logical line and handled it quite gracefully. 8.5 or 8.6 gets stuck really quickly. This code snippet will illustrate:
<begin code>
   package require Tk

       font create dnafont  -family [font actual courier -family] -size 11
   text .t -yscrollcommand {.s set} -font dnafont -width 60 -wrap char  -setgrid true
   scrollbar .s -command {.t yview}
   pack .s -side right -fill y
   pack .t -side left -fill both -expand 1

       set insertion "ACGT"
       set data $insertion

       for { set i 1 } { $i <= 5000 } { incr i } {
       append data $insertion
       } # create a mock sequence of 20000 bases (long, but not terribly long)
   .t insert 0.0 $data
<end code>
Under 8.4 the window is reasonably responsive, under 8.5 it is a dead dog. This difference is not there under Windows.
Tested using Tcl/Tk 8.5.3 and 8.6. Have used two different Macs, both PPC, running OS X 10.4.11.

Looking at the platform-specific TkAqua code, it looks as if the whole thing is being passed off to system code in MeasureStringChars and ATSUBreakLine. I have been readin some of the old discussion on this area before posting and it seems as if there is a serious performance problem with ATSUBreakLine when faced with this kind of problem.
I posted this on tcl-mac and was asked to post it as a bug here for the attention of 'benny' (Benjamin Riefenstahl).
User Comments: serhiy.storchaka added on 2026-10-08 12:36:10:

The ATSUI code is gone since the Cocoa port. But on macOS each display line of a long logical line is still measured with the rest of the segment as context (TK_LAYOUT_WITH_BASE_CHUNKS), and TkpMeasureCharsInContext builds a CoreText typesetter for that whole context. So laying out one long logical line is quadratic in its length. Could someone with a Mac time the script above with Tk 9.0.5 or 9.1.0, e.g. for 20000 and 80000 characters?