Skip to content

perf(theme): eliminate continuous QueryaHighlightController recreation during AnimatedQueryaTheme transitions #1358

Closed

Description

@ZhuchkaTriplesix

Summary

During theme transitions (switching between light/dark mode or selecting a new theme), AnimatedQueryaTheme (in lib/core/theme/animated_querya_theme.dart) interpolates QueryaTheme.lerp(a, b, t) across frames over themeDuration (200–300 ms).
Inside QueryaCodeEditor.build() (lib/core/editor/querya_code_editor.dart, lines 148–175):
_ensureHighlightController(context.queryaTheme) checks:

if (_highlightController != null &&
    _highlightEditorTheme == editor &&
    _highlightLanguage == widget.language &&
    _highlightTokenColorsHash == tokenHash) {
  return;
}

Because editor colors are lerped on every frame (60 to 144 times/sec), _highlightEditorTheme == editor evaluates to false on every single frame of the animation.
Consequently:

  1. _disposeHighlight() is called.
  2. SyntaxHighlightService.createPair is called with newly lerped hex colors, missing the LRU cache and evicting entries from the 12-slot _pairCache.
  3. A brand new QueryaHighlightController is instantiated, and listeners are re-wired.
  4. For every open SQL tab, the controller is destroyed and recreated 18 to 36 times during a single 300 ms transition.

Proposed Solution

  1. Update editor wrapper and token colors in-place on the existing QueryaHighlightController without disposing and recreating the controller.
  2. Only recreate the controller when the target theme definition, language, or grammar actually changes, ignoring intermediate lerp frames.
  3. Prevent cache pollution in SyntaxHighlightService._pairCache by avoiding cache lookups for transient lerped themes.

Acceptance Criteria

  • Switching themes does not dispose and recreate QueryaHighlightController on every intermediate animation frame.
  • Theme transitions with multiple open SQL editor tabs run smoothly at 60/120 Hz without frame drops.

Activity

  1. added
    themeTheming, colors, VS Code themes
    editorCode/SQL editor
    performanceTheme parser epic label: performance
    P2Medium priority / Parity & Refactoring
    on Oct 10, 2026
  2. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Done in #1402 (merged into dev).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority / Parity & RefactoringeditorCode/SQL editorperformanceTheme parser epic label: performancethemeTheming, colors, VS Code themes

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions