Repository navigation
fix: SG-45066: Load annotation font list without blocking first activation - #1444
Open
cedrik-fuoco-adsk wants to merge 1 commit into
Conversation
cedrik-fuoco-adsk
force-pushed
the
SG-45066-annotation-tools-first-activation-delay
branch
from
October 7, 2026 17:04
5907ea6 to
bd674ba
Compare
cedrik-fuoco-adsk
marked this pull request as ready for review
October 7, 2026 17:07
cedrik-fuoco-adsk
requested review from
bernie-laberge and
eloisebrosseau
as code owners
October 7, 2026 17:07
…ation The Text tool's font combo was filled in _TextOptionsPanel.__init__ by calling QFontDatabase.isSmoothlyScalable() on every installed family. Each call resolves all styles of the family, so building the dock froze RV the first time the beta annotate tool was opened: 650 to 870 ms measured on macOS with a warm font cache, and about 2 s reported. The cost grows with the number of installed fonts. The dock now builds without touching the font list. Once the secondary panel is shown, the list is filled in batches of about 1 ms from a QTimer, so the event loop keeps running between batches. The saved font family is selected when it is added, and a placeholder keeps the combo from auto-selecting the first font, so loading never emits font_family_changed or overwrites the saved setting. Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
cedrik-fuoco-adsk
force-pushed
the
SG-45066-annotation-tools-first-activation-delay
branch
from
October 7, 2026 17:23
bd674ba to
b66f7bf
Compare
| DEFAULT_FONT_FAMILY = "Helvetica" | ||
|
|
||
| # Time spent filling the font list per event loop pass. | ||
| FONT_BATCH_SECONDS = 0.001 |
Contributor
There was a problem hiding this comment.
I feel like the variable name should be descriptive enough to not need a comment above it here.
eloisebrosseau
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: SG-45066: Load annotation font list without blocking first activation
Linked issues
none
Summarize your change.
The beta annotate tool no longer freezes RV while it builds the font list for the Text tool. The dock opens right away, and the font combo then fills in time-boxed batches (about 1 ms each) on the GUI thread.
Describe the reason for the change.
_TextOptionsPanel.__init__filled the font combo by callingQFontDatabase.isSmoothlyScalable()on every installed family. Each call resolves every style of the family, so the first activation of the tool froze RV: 650 to 870 ms measured on macOS with a warm font cache, and about 2 seconds from what I can see on my Macbook.Describe what you have tested and on which operating system.
macOS (debug build), F10 sent through RV's event table from a startup script:
isSmoothlyScalable()call)Also checked in RV on macOS:
font_familysetting) is selected after loading and the setting is unchanged.Add a list of changes, and note any that might need special attention during the review.
_TextOptionsPanelno longer touchesQFontDatabasein__init__.start_loading_fonts()(runs once) queues thefamilies()names. A 0 msQTimerthen runs_load_font_batch(), which adds smoothly scalable families until about 1 ms have passed and then returns to the event loop.AnnotateSecondaryPanel.showEventschedulesstart_loading_fonts()with a single-shot timer, so the dock paints first. The text page itself can't trigger it, because it's a hidden stacked page unless the Text tool is active.setPlaceholderText("Aa"). Without it,QComboBoxauto-selects the first family added. Re-picking that item during the load wouldn't change the index, so no signal would fire and the user's pick would be lost. The closed combo already paints "Aa", so this changes nothing visible.set_font_family()always updates the "Aa" preview font, even before the family is in the list. If the saved family is no longer installed, Qt spends about 68 ms resolving aliases. Only users whose saved font was removed pay that.Why time-boxed batches instead of a worker thread: I prototyped a
QThreadthat builds the list and measured both in RV:QThreadThe thread doesn't stall the UI less, because PySide6 keeps the GIL while
isSmoothlyScalable()runs.A standalone test confirmed this:
During the slow calls the main thread's Python was blocked for up to 18.5 ms, more than the 5 ms GIL switch interval, while a
time.sleep()control blocked it for 0.1 ms. Both approaches are therefore bounded by one slow call.The thread finishes up to about 70 ms sooner, but it brings shutdown handling (a
QThreaddestroyed while running aborts) and depends onQFontDatabasethread safety on every platform's font back end. The batched version stalls less often (see the 99th percentile column), with deterministic behavior that's easier to test.