Chromium: excessive layout time with many math previews due to unused CSS anchor
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend, performance
Hướng nghiên cứu
Bắt đầu trong packages/core/src/editor/Block.css và kiểm tra khai báo anchor-name của .bn-preview-container; issue báo cáo rằng không có anchor consumer nào và việc xóa khai báo này sẽ loại bỏ chi phí layout của Chromium. Tái hiện fixture 500-inline-formula được cung cấp, so sánh kết quả Chromium Performance khi có và không có khai báo, đồng thời xác nhận rằng tất cả preview vẫn được render ở cả chế độ có thể chỉnh sửa và chỉ đọc.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 10.2k
- Fork
- 772
- Merge trung bình
- 6 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 26
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TypeCellOS/BlockNote
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
TypeCellOS/BlockNote#2949 · 1 bình luận ·
-
a11y
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
TypeCellOS/BlockNote#2855 ·
-
a11y
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
TypeCellOS/BlockNote#2829 · 1 bình luận ·
-
a11y
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
TypeCellOS/BlockNote#2824 ·
-
a11y
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
TypeCellOS/BlockNote#2811 ·
Tất cả issue của TypeCellOS/BlockNote
Issue tương tự
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Crush Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
ElementsProject/cln-application#167 · 1 bình luận · 1 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Quantco/pnpm-licenses#17 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100