Chromium: excessive layout time with many math previews due to unused CSS anchor
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 84/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- react, typescript
- Domínio
- frontend, performance
Direção de pesquisa
Comece em packages/core/src/editor/Block.css e inspecione a declaração anchor-name de .bn-preview-container; a issue relata que não existe nenhum consumer do anchor e que removê-la elimina o custo de layout do Chromium. Reproduza o fixture 500-inline-formula fornecido, compare os resultados do Chromium Performance com e sem a declaração e confirme que todas as previews continuam sendo renderizadas tanto no modo editável quanto no modo somente leitura.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- TypeScript
- Estrelas
- 10.2k
- Forks
- 772
- Merge médio
- 3d 11h
- PRs com merge (30d)
- 17
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TypeCellOS/BlockNote
-
Off-By-One `RangeError` Crash and Text Duplication in `StyleManager.editLink` and `deleteLink` Abertaneeds-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
TypeCellOS/BlockNote#3073 ·
-
needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
TypeCellOS/BlockNote#3072 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
TypeCellOS/BlockNote#2949 · 1 comentário ·
-
a11y
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
TypeCellOS/BlockNote#2855 ·
-
a11y
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
TypeCellOS/BlockNote#2829 · 1 comentário ·
Todas as issues de TypeCellOS/BlockNote
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
[Bug]: Matrix progress drafts fail with "Matrix runtime not initialized" during tool activity Abertabug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
calcite-components needs triage refactor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Esri/calcite-design-system#15203 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100
danielmiessler/LifeOS#2218 ·