Document user text is read in O(n²) and freezes the UI on open

dut_a_25k.3dm (2.5 MB)
Version: Rhino 8 SR32 (8.32.26160.13001, 2026-06-09), Windows 11
Not tested on later service releases (SR34/SR35 are available): I don’t have administrator rights on this machine and can’t update Rhino. If this no longer reproduces on a current build, please let me know.

Repro (rhino3dm 8.32.2, synthetic file; dut_a_25k.3dm, 2.5 MB, also attached):

import rhino3dm
f = rhino3dm.File3dm(); f.Objects.AddPoint(0, 0, 0)
S = ["SecOpen", "SecSubject", "SecDescription", "SecClose"]
for i in range(25000): f.Strings["%s\\%d" % (S[i % 4], i // 4)] = "value %d" % i
f.Write("dut_25k.3dm", 8)

Open the file in Rhino 8 with the Document User Text panel docked, then run _DocumentText.

Expected: about 25k entries load in well under a second, as other 25k-row tables do.

Actual: the UI is unresponsive for 18 s with the panel visible. With the panel hidden it’s 45–50 s, which is not understood (see below).

Measurements:

Entries Panel load (OpenPanel call) GetKey(i) for every entry, headless doc (no UI) Cost per GetKey
1,000 0.13 s 0.015 s 10 µs
5,000 0.76 s 0.30 s 52 µs
10,000 2.85 s 1.13 s 105 µs
25,000 17.4 s 7.13 s 270 µs
50,000 70.5 s – 542 µs
  • Cost depends on table size, not position. At 25k, GetKey on the first 200 entries took 54.5 ms and on the last 200 took 54.1 ms. Opening the same file headless (RhinoDoc.OpenHeadless) took 0.018 s, so reading the file is not the cost; each indexed read is.

  • UI blocked while opening the 25k file, measured as main-window WM_NULL timeouts:

    Panel state Blocked
    Visible 18.05 s, one block
    Hidden 45.5 s and 50.2 s (two runs)
    Panel event watchers disabled by reflection 42.9 s

    Adding objects, rerunning _DocumentText and toggling the panel afterwards cause no stalls.

Analysis (IL inspection of Rhino.UI / RhinoCommon 8.32):

  • The panel’s load routine makes 2n native calls. UserStringsPanelControl.LoadDocumentStrings loops over StringTable.get_Count → GetKey(int) → GetValue(string). That is 2n calls into CRhinoDoc_GetDocTextString / GetDocTextString2, each O(n) by the timings, so O(n²) on the UI thread.
  • When it runs: EndOpenDocument and ActiveDocumentChanged set UpdateDocumentStrings, and PanelShown triggers a load. The idle handler (RhinoApp_Idle → LoadDocumentStrings) has no visibility check in its IL.
  • Not attributed: why opening with the panel hidden blocks longer than with it visible. No third-party assembly calls StringTable (IL scan of every loaded assembly).
  • The same pattern exists elsewhere in RhinoCommon. GetSectionNames, GetEntryNames, DocumentUserTextCount and DocumentDataCount all loop GetKey(i), so every plug-in that reads the table pays O(n²) too.

Suggested fixes:

  1. Make indexed access O(1) natively, or add a bulk accessor in one native call (e.g. StringTable.GetAll() returning key/value pairs in O(n)).
  2. In LoadDocumentStrings, use the bulk call, or at least GetValue(int) instead of GetValue(string).
  3. Skip the reload when the panel isn’t visible. Merge the reloads from EndOpenDocument and ActiveDocumentChanged into one. Load off the UI thread or in steps (RH-84210 asks the same for the attribute panel).
  4. Rebase GetSectionNames, GetEntryNames and the count properties on the bulk accessor.

Related: RH-94017 (fixed in 9.x, attribute panel, managed side), RH-76189, RH-84210, RH-53945.

Hi @locivir,

Has your AI bot tested the Rhino 9 Beta?

– Dale

Hi Dale,

Unfortunately I do currently not have access to Rhino 9 right now as I do not have admin rights on my work computer. I can reach out to IT if it’s required but that will take a few days.

Regards,

Ernst Plaatsman

Hi @locivir,

I’ve logged a ticket so a developer can investigate.

– Dale