Skip to content

fix: cache NVIDIA WOFF2 font descriptors to prevent app hangs - #9

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/cache-nvidia-font-descriptors
Open

fix: cache NVIDIA WOFF2 font descriptors to prevent app hangs#9
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/cache-nvidia-font-descriptors

Conversation

@sentry

@sentry sentry Bot commented Jul 27, 2026

Copy link
Copy Markdown

This PR addresses an app hanging issue (OPENNOW-MAC-20) caused by repeated, synchronous WOFF2 font decoding on the main thread.

Problem:
SwiftUI view body re-evaluations, frequently triggered by rapid GraphQL polling, would repeatedly call OpenNOWNVIDIAFont.loadDescriptor(named:). This function, in turn, called CTFontManagerCreateFontDescriptorsFromURL on .woff2 font files without any caching. WOFF2 decoding involves expensive, synchronous brotli decompression and TTF conversion, blocking the main thread for extended periods and leading to app hangs.

Solution:
Implemented a static, thread-safe cache (descriptorCache) within OpenNOWNVIDIAFont to store CTFontDescriptor results. The loadDescriptor function now:

  1. Acquires a lock to ensure thread safety.
  2. Checks the cache first; if the descriptor (or a nil result for a non-existent font) is found, it's returned immediately.
  3. If not in cache, proceeds with the expensive CTFontManagerCreateFontDescriptorsFromURL call.
  4. Stores the result (whether a valid descriptor or nil) in the cache before releasing the lock and returning.

This ensures that each font is decoded and converted only once during the app's lifetime, significantly reducing main thread blocking and eliminating the app hang.

Fixes OPENNOW-MAC-20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants