Chromium: excessive layout time with many math previews due to unused CSS anchor
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 84/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react, typescript
- 領域
- frontend, performance
調査の方向性
packages/core/src/editor/Block.css から始めて、.bn-preview-container の anchor-name 宣言を調べます。この issue では、anchor の consumer が存在せず、宣言を削除すると Chromium のレイアウトコストがなくなると報告されています。提供された 500-inline-formula fixture を再現し、宣言の有無で Chromium Performance の結果を比較し、編集可能モードと読み取り専用モードの両方で、すべてのプレビューが引き続きレンダリングされることを確認します。
索引モデルが issue の本文から書いたものです。
説明
What’s broken?
Rendering 500 official inline math previews in Chromium spends about 17.6 seconds in layout, including with editable={false}. Every .bn-preview-container receives anchor-name: --bn-source-popup-anchor in packages/core/src/editor/Block.css, although the current popup positioning does not consume this anchor.
Removing that declaration reduces layout to about 0.43 seconds with the same content and DOM.
What did you expect to happen?
Closed source previews should not incur CSS-anchor layout overhead when popup positioning does not use anchors.
Steps to reproduce
- In a React app with
@blocknote/core,@blocknote/react,@blocknote/mantine, and@blocknote/math-block, render this component:
import { BlockNoteSchema, defaultBlockSpecs, defaultInlineContentSpecs } from "@blocknote/core";
import { useCreateBlockNote } from "@blocknote/react";
import { BlockNoteView } from "@blocknote/mantine";
import { createReactInlineMathSpec } from "@blocknote/math-block";
import "@blocknote/mantine/style.css";
const schema = BlockNoteSchema.create({
blockSpecs: defaultBlockSpecs,
inlineContentSpecs: {
...defaultInlineContentSpecs,
math: createReactInlineMathSpec(),
},
});
const initialContent = Array.from({ length: 25 }, (_, row) => ({
type: "paragraph",
content: Array.from({ length: 20 }, (_, col) => [
{ type: "text", text: " text ", styles: {} },
{ type: "math", content: `x_{${row * 20 + col}}^2 + y^2 = z^2` },
]).flat(),
}));
export default function App() {
const editor = useCreateBlockNote({ schema, initialContent });
return <BlockNoteView editor={editor} editable={false}
formattingToolbar={false} sideMenu={false} slashMenu={false} />;
}
- Serve a production build and record page load in Chromium's Performance panel.
- Add
.bn-preview-container { anchor-name: none !important; }as a diagnostic override and reload. Layout time drops substantially; all 500 formulas remain rendered. - Repeat with
editable={true}; the same issue occurs.
BlockNote version
Reproduced on 0.54.0 and current source at 835fabf86ef26c9932075ab47f3d03cf900f276b.
Environment
Chromium 151.0.7922.137, Linux, AMD Ryzen 7 5800X. Production React/Vite fixture, 1280×900 viewport, no CPU throttling.
Additional context
Current-source production builds, three runs per cell; median cumulative CDP LayoutDuration through editor/font readiness:
| 500 inline formulas | Original | Declaration removed |
|---|---|---|
| Editable | 17.610 s | 0.437 s |
| Read-only | 17.684 s | 0.427 s |
Median readiness improves from 18.51 to 1.28 seconds in editable mode. The same trigger also reproduces with official block math. No position-anchor, anchor(), or anchor-size() consumer exists in the inspected source; popups currently use absolute positioning.
Contribution
- I'd be interested in contributing a fix for this issue
- 主要言語
- TypeScript
- スター
- 10.2k
- フォーク
- 772
- 平均マージ
- 3日 11時間
- マージ済み PR(30日)
- 17
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TypeCellOS/BlockNote のほかの issue
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
TypeCellOS/BlockNote#3073 ·
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
TypeCellOS/BlockNote#3072 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
TypeCellOS/BlockNote#2949 · コメント 1 件 ·
-
a11y
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
TypeCellOS/BlockNote#2855 ·
-
a11y
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
TypeCellOS/BlockNote#2829 · コメント 1 件 ·
TypeCellOS/BlockNote の issue をすべて見る
似ている issue
-
Type/Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenNSW/nsw-srilanka#497 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
0xMiden/bridge-portal#132 ·
-
react-doctor severity:warning tech-debt
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
digidem/comapeo-cloud-app#403 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100