Virtual Table Scrolling Performance lag Issue with WebSocket real-time data updates

未關閉
#1,204 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
28/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
react, typescript

研究方向

從重現虛擬表格開始,檢查第 244-247 行附近的 BodyGrid.tsx,據報告 itemProps.style 會觸發儲存格重新渲染。在測試複雜儲存格和透過 WebSocket 進行的列更新時,使用 React Profiler 和瀏覽器效能工具;完成的標準是識別並解決捲動延遲,同時不導致虛擬捲動行為回歸。

由索引模型根據 Issue 內容生成。

描述

Reproduction link

https://ant.design/components/table#table-demo-virtual-list

Steps to reproduce
  1. Create a virtual table using rc-table's genVirtualTable
  2. Implement with complex cell nodes
  3. Load initial data with WebSocket real-time updates for certain rows
  4. Scroll the table vertically
What is expected?

Smooth vertical scrolling performance with virtual list implementation.

What is actually happening?

Implementation Details

import { genVirtualTable } from 'rc-table';

const RcVirtualTable = genVirtualTable(
  (prev, next) => {
    const { _renderTimes: prevRenderTimes } = prev;
    const { _renderTimes: nextRenderTimes } = next;
    return prevRenderTimes !== nextRenderTimes;
  }
);

export default RcVirtualTable;

// Table
const Table = (props, ref) => {
  const renderTimesRef = React.useRef<number>(0);
  renderTimesRef.current  = 1;
  const virtualProps = { ref, _renderTimes: renderTimesRef.current };

  return <RcVirtualTable {...props} {...virtualProps} />;
};

export default React.forwardRef(Table);

Actual Behavior

  1. Noticeable lag during vertical scrolling
  2. Using React Profiler with highlight feature shows:
  • All rows re-render on each scroll with color yellow
  • All cells re-render on each scroll with color yellow
    This issue exists in both antd and rc-virtual-list demos

Investigation Findings

  1. Root cause of cell re-renders:
  1. Additional observations:
  • Commenting out the style prop prevents cell re-renders but scrolling lag persists
  • Frame rate remains stable during scrolling
  • Suggests possible CSS updates, reflow, or repaint issues

Potential Contributing Factors

  • Complex cell node structure
  • Subsequent WebSocket updates for specific rows
Environment Info
antd 5.21.6
React 18.2.0
System macOS 14.6.1
Browser Chrome 130.0.6723.92

  1. Issue persists across React 16 and React 18
  2. Frame rate stability during lag suggests DOM operations (reflow/repaint) may be the bottleneck rather than React rendering
  3. Current implementation follows antd usage patterns with rc-table's genVirtualTable
主要語言
TypeScript
星號
1.4k
分支
623
PR 合併指標
30 天內沒有已合併 PR

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

react-component/table 的其他 Issue

查看 react-component/table 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。