Skip to content

[Bug] UI Freezes on "show full code block" due to synchronous diff recalculation on main thread #1216

@bdelosrios

Description

@bdelosrios

Description:
When expanding a code block in the Gemini Code Assist chat panel by clicking "show full code block," the extension panel completely freezes, and a single CPU core spikes. The rest of the VS Code window remains responsive, but the chat panel becomes unusable until the process is killed or the chat is cleared.

This issue persists regardless of VS Code hardware acceleration settings, color themes, or disabling other Markdown extensions.

Steps to Reproduce:

  1. Open a relatively large text/code file in the active VS Code editor tab.
  2. Open the Gemini Code Assist panel and prompt it to generate a code block.
  3. Click the "show full code block" button in the response.
  4. The Gemini chat panel freezes completely.

Environment:

  • OS: Ubuntu 24.04
  • Hardware: Razer Blade 15 mid-2019
  • Editor: VS Code (Latest)
  • Extension: Gemini Code Assist (Latest - also tested on downgraded versions)

Diagnostic Data (Root Cause Analysis):
I ran a VS Code Extension Host CPU profile during the freeze. The .cpuprofile (attached) shows the freeze is NOT caused by Markdown parsing. Instead, the main thread is being locked up by a synchronous diff calculation running against the active editor document.

The profile shows a tight, unbroken loop hogging the CPU time, tracing back through the following extension functions:

  • codeBlockCollapsedStateChangedAction
  • recalculateRanges
  • setFilesFromDiffSuggestions
  • getChangedLinesCounts
  • Heavy execution inside a diffing algorithm (frequent calls to extractCommon and removeEmpty).

Expected Behavior:
The code block should expand smoothly without attempting to synchronously run an expensive diff operation on the main thread, or the diff recalculation should be offloaded to a web worker/background process so it doesn't block the UI.

Attachments:

CPU-20260308T011114.024Z.cpuprofile.txt

(text made with gemini 3.1 pro)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions