Problem/Motivation
Not sure if this is a bug or something local. If others can verify it on mac in safari, we can rule it out. But I just installed a fresh Drupal 11 (11.3.6) and whenever clicking on a "display builder" link or button, the browser completely freezes. Nothing happens, even developer tools don't work anymore. In Chrome everything works perfectly.
Running this on ddev, Php 8.2, macbook pro M2 32Gb Tahoe 26.5, Safari 26.5.
When I enable xdebug, with a breakpoint in index.php, the htmx calls aren't even coming in.
Steps to reproduce
Install D11 (normal install with articles, pages)
Install display builder module and enable it.
Enable display builder in the view modes of for example page content type.
Goto the display builder of that view mode.
Browser locks up.
Proposed resolution
-
Remaining tasks
Figure out what is going on inside safari (difficult, because no network dev tools are working)
User interface changes
-
API changes
-
Data model changes
-
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | safari-layers-hang-layer-css-flatten-ramps.patch | 41.64 KB | kriboogh |
| #12 | safari-layers-freeze-keyboard-sl-show.patch | 2.61 KB | kriboogh |
Issue fork display_builder-3607394
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 1.0.x
compare
- 3607394-slow-page-load
changes, plain diff MR !307
Comments
Comment #2
pdureau commentedThanks you @kriboogh
Here is a related conversation with https://www.drupal.org/u/dasginganinja :
Comment #3
pdureau commentedLooking at @kriboogh browser when he was testing Drisplay Builder on Safari, I got the impression the display builder page was loading right, but was not replaced in the browser window. It seems there are some check in between the page load and the page rendering, and Safari is struggling with one of them.
We removed our Javascript files from the module codebase, the same. Maybe it is is something in the HTML markup itself.
Comment #4
pdureau commentedComment #5
pdureau commentedWhat is happening if we remove everything from
components/display_builder/display_builder.twig? If the slowness goes away, it would be interesting to add the parts one by one until we found the one which is causing slowness.Someone with Safari can do the test?
Comment #6
kriboogh commentedBeen trying all day to debug it, but even xdebug gets stuck :/ What I managed to figure out is that if you disable the 'view_main', in ProfileViewBuilder, the page at least loads again.
Comment #7
kriboogh commentedBit deeper, it's the 'layers' island. If you leave that out, page loads normal.
Comment #8
pdureau commentedThank you so much
Comment #9
just_like_good_vibesHello,
please check the keyboard shortcut, which may to be the reason of the problem.
Comment #10
pdureau commentedThanks Mikael.
Indeed, removing
LayersPanel::keyboardShortcuts()"fixes" the problem.For information,
IslandInterface::keyboardShortcuts()is called byProfileViewbuilder::buildDynamicTabs()which is generating those data attributes:then,
keyboard.jsis listeningkeydownevent and move the focus to the corresponding element:Where is Safari struggling? it is on load, so the
keydownJavascript hasn't been executed yet.Is it
aria-keyshortcuts="y"?Comment #11
kriboogh commentedI had Claude AI have a go at this. After applying it's suggested solution, now the page loads again although still slow. Before it wouldn't load at all. So there might be something else still involved.
Here's the complete Claude AI Diagnosis:
The freeze is not the keydown handler — it is the sl-show handler in assets/js/keyboard.js:41-52. It has three defects that together produce a synchronous re-entry loop on Safari at initial page load, especially when the Layers island is present (which adds more Shoelace tooltip surface inside the same builder container).
<sl-card> / <sl-details>-based db-layer elements. When the Layers panel opens, all of those Shoelace components can emit sl-show as they mount. Each one bubbles to builder, the handler runs, mutates a tooltip, that mutation cascades — loop.Proof / cross-check
Possible Fix
Tighten the sl-show handler so it only reacts to the help tooltip firing its own sl-show, and does not mutate DOM inside other tooltips. Two safe minimal changes:
The idempotence check means the second and subsequent bubbled sl-show events do not mutate the DOM, so Shoelace does not react and the loop cannot sustain.
if (!event.isTrusted && event.target === lastTarget) return;Combining #1 and #2 is the robust fix. #2 alone is enough to stop the current Safari freeze without changing behavior for other browsers.
Verification steps
Comment #12
kriboogh commentedSo with this patch I got the stall halved. Initially it stalls for about 1m30 seconds. There are 2 waves. From the moment you instruct Safari to load the page, 40s laps where the page is blank, then the page is drawn, but frozen. After another 40s the page is interactive. and after 1m30 the safari considers the page fully loaded.
When applying the attached patch AND also you need to load the shoelace library as a full js locally (not in chunks, not from CDN) the page is completly loaded after 40s. (still a long time, but some progress).
The patch is what is explained above by Claude AI.
Comment #13
kriboogh commentedFinally found the real reason. The culprit was layers.css. It has to many nested & rules which safari can't handle. When expanding them, one rule got over 115k characters. Attached is a (AI generated) patch of layers.css that solves the problem. Please verify on your behalf if this thing still does the intended behaviour.
Safari 26 CSS-engine regression workaround. The 10-deep & & & & & & & & & & nesting is technically valid CSS, but crashes Safari 26. The workaround (flat descendant selectors) is functionally identical. Worth reporting to WebKit separately (bug in Safari), but the display_builder patch is a pragmatic fix while WebKit ships a fix.
I tested this on a fresh install, and applying both patches loads the page now instantly.
Comment #14
kriboogh commentedPS: I intentionally did not create a MR yet, as there are two issues actually solved here (2 patches) and maybe we need to pull them apart or not. I'll leave that upto you to decide Piere.
Comment #15
pdureau commentedThanks a lot, that's impressive. Let's do a single MR with the 2 fixes
Comment #17
pdureau commentedDon't forget to assign the ticket to you :)
Once the MR is rebased and the stylelint has been run. You can unassign it and switch to "Needs review" status
Comment #18
kriboogh commentedComment #19
kriboogh commentedMR ran, no more issues. Pls review.
Comment #20
pdureau commentedComment #21
mogtofu33 commentedComment #22
mogtofu33 commentedComment #23
mogtofu33 commentedLayers.css tree removed and keyboard rewamped in #3576683: [meta] UX refresh.
Need a review with 1.0.x-dev.
Comment #24
pdureau commented;Checked with Kris, we can close this. Thanks everybody.