[6.x]: Entry edit page takes ~0.4s longer to first paint for every Matrix block
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
What happened?
Description
Follow-up to #20333. Since that PR, the server responds in about 0.25s even for Matrix entries, so the remaining time is in the browser. Opening an entry blocks the main thread in one long task before anything is drawn, and that task grows with each Matrix block: about 0.43s more per block. An entry with 7 blocks takes 4.6s to first paint.
Steps to reproduce
- Create an entry with a Matrix field holding 7 blocks (a mix of block types with plain text, Markdown and relation fields, in blocks view).
- Open it in the control panel (
/admin/entries/<section>/<id>) in Chrome at a desktop window size. - Record a Performance trace of the page load.
Expected behavior
Each block adds only the cost of rendering its fields, so first paint grows slowly with the number of blocks.
Actual behavior
Medians of 5 loads; the server response is 0.2–0.3s in all cases:
| Entry | Matrix blocks | First paint | Main thread blocked |
|---|---|---|---|
| Blog post | 0 | 1.61s | 1.41s |
| Page | 2 | 1.98s | 1.94s |
| Page | 5 | 3.08s | 3.13s |
| Home | 7 | 4.60s | 4.53s |
On the 7-block entry, the page load is one 4.75s task. 3.25s of it is 495 forced style or layout recalculations, each costing 8–16ms because each one recalculates the whole page.
Cause
Components read layout while the form is still rendering, and each block adds more of them (7-block entry, one trace):
- Menu and tooltip setup: ~2.0s. 41
craft-action-menuand 31craft-tooltipelements build their overlay controller on connect. That reads--c-layer-popoverwithgetComputedStyle(packages/craftcms-ui/src/components/popover/popover.ts:79, 73 forced recalculations, ~1.1s) and builds and measures the<dialog>wrapper (71 forced layouts, ~0.75s). - Textarea autosize: ~0.5s.
craft-textareasets its height fromscrollHeighton every update. Markdown fields add ~0.2s doing the same. - Button accessible name: ~0.47s.
craft-buttonrunscomputeAccessibleName()(button/button.ts:372) after first render, and again from the content MutationObserver (button.ts:116) on every content change during load.
Suggested fix
- Set up menu, popover and tooltip overlays on first hover, focus, key press or open instead of on connect. Caching the z-index read alone doesn't help: the forced layout just moves to the next read.
- Size textareas with CSS
field-sizing: content(min and max height fromrows/max-rows) instead of measuring them. - Run the accessible-name check, including the MutationObserver recheck, when the browser is idle, not during render.
Notes
The numbers are partly browser and machine dependent. I only measured in Chrome 155. How much a forced style or layout recalculation costs depends on the browser engine and the CPU, so Firefox and Safari (untested) may show different totals, and slower machines will be slower in proportion. The number of forced recalculations comes from the CP code and should be the same in every browser. field-sizing: content isn't supported in every browser yet, so textareas would need the current script as a fallback.
In some local tests with rough versions of all three, first paint went from 4.60s to 1.72s on the 7-block entry and from 1.61s to 1.00s on the entry without Matrix. Each block then added about 0.10s instead of 0.43s. Caveat: delaying tooltip setup also delays the tooltip that names icon-only buttons such as the header Search and Ask AI buttons, so they have no accessible name until first hovered. A real fix would need to name those buttons without setting up the tooltip.
Craft CMS version
6.x-dev 8b5bdb3
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
- Ngôn ngữ chính
- PHP
- Star
- 3.6k
- Fork
- 714
- Merge trung bình
- 13 giờ 9 phút
- Pull request đã merge (30 ngày)
- 378
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc 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 craftcms/cms
-
bug repo:cms
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
craftcms/cms#20205 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[6.x]: Element index View menu: sort direction buttons only update after the table has loadedĐang mởbug repo:cms
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
craftcms/cms#20203 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[5.x]: MCP returns `[]` for CKEditor field valuesCó thể đã có người làm @i-just đã nhận 2 ngày trước. Đang mởrepo:cms
craftcms/cms#20404 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[6.x]: Custom entry source with a single-section condition shows another source's entriesCó thể đã có người làm @brandonkelly đã nhận 2 ngày trước. Đang mởbug
craftcms/cms#20388 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[6.x]: settings icon not rending with admin changes disabledCó thể đã có người làm @brandonkelly đã nhận 3 ngày trước. Đang mởbug repo:cms
craftcms/cms#20338 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Include flows spanning the full report time windowCó thể đã có người làm @somethingwithproof đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Cacti/plugin_flowview#306 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:low type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
crazy-goat/workerman-bundle#1189 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Captured slideshow pass overwrites the route path, aborting compose with a rebind() TypeErrorĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Automattic/blocks-engine#5003 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
from-cloud mythic tracked
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
MythicalLTD/FeatherPanel#459 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày