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

**URL:** <https://discourse.mcneel.com/t/document-user-text-is-read-in-o-n-and-freezes-the-ui-on-open/223440>\
**Category:** Rhino\
**Tags:** windows, usertext, rhino8, rhino8-bug, document-user-text\
**Created:** [October 9, 2026, 4:22pm UTC](https://discourse.mcneel.com/t/document-user-text-is-read-in-o-n-and-freezes-the-ui-on-open/223440 "2026-10-09T16:22:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![locivir](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/locivir/32/767210_2.png) [@locivir](https://discourse.mcneel.com/u/locivir)\
**Post date:** [October 9, 2026, 4:22pm UTC](https://discourse.mcneel.com/t/document-user-text-is-read-in-o-n-and-freezes-the-ui-on-open/223440/1 "2026-10-09T16:22:00Z")

</div>

[dut\_a\_25k.3dm](https://discourse.mcneel.com/uploads/short-url/hDhViNlCDGQ0wjwZs4BUJwRgCWO.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):

```python
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:

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.

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [October 9, 2026, 6:22pm UTC](https://discourse.mcneel.com/t/document-user-text-is-read-in-o-n-and-freezes-the-ui-on-open/223440/5 "2026-10-09T18:22:12Z")

</div>

Hi @locivir,

Has your AI bot tested the Rhino 9 Beta?

– Dale

---

<div class="post-metadata">

**Author:** ![locivir](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/locivir/32/767210_2.png) [@locivir](https://discourse.mcneel.com/u/locivir)\
**Post date:** [October 9, 2026, 7:08pm UTC](https://discourse.mcneel.com/t/document-user-text-is-read-in-o-n-and-freezes-the-ui-on-open/223440/7 "2026-10-09T19:08:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [October 9, 2026, 10:45pm UTC](https://discourse.mcneel.com/t/document-user-text-is-read-in-o-n-and-freezes-the-ui-on-open/223440/8 "2026-10-09T22:45:28Z")

</div>

Hi @locivir,

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

> **[Document user text freezes the UI on open : RH-99461](https://mcneel.myjetbrains.com/youtrack/issue/RH-99461)**
>
> https://discourse.mcneel.com/t/document-user-text-is-read-in-o-n-and-freezes-the-ui-on-open/223440 Notes are on the Discouse thread.

– Dale
