gridbugs icon indicating copy to clipboard operation
gridbugs copied to clipboard

Nested grid performance in Safari

Open syren opened this issue 3 years ago • 9 comments

I'm working on a project and have been trying to debug it for a couple days. I have a game with a drag and drop interface that uses several nested grids for the layout. The cards that are dragged are within a grid, and using GSAP's Draggable, they are cloned and dragged.

In Safari on iOS, there's a ~1s delay upon a card being picked up. I thought it was touch-related, but it was resolved when I removed the grid rules. I did some digging and found this example:

https://codepen.io/brendanmckenzie/pen/NWpKWez

There's a delay on desktop Safari, but its much more pronounced on iPad. If you remove the display: grid in the Codepen you'll see that clicking into the textarea is immediate, and both fields have a 1-2s delay when CSS grid is on. On desktop the issue is the speed on the nested textarea, but on iPad they are both equally slow.

My UI uses a lot of previously reported things that Safari takes issue with (intrinsic/extrinsic sizing, etc) but the above Codepen illustrates that it's just plain grid that has the performance issue.

Is this known? Is there anything I can do to debug this further? Any suggestions?

syren avatar Nov 17 '22 03:11 syren

I just spent a whole week to find why my nested webcomponents were lacking performance on iOS and that was because of the nested display: grid...

Magaav avatar Nov 05 '24 20:11 Magaav

Having the same issue, multiple nested grids are causing very slow performance on safari, making subgrid pretty much unusable.

theconsigliere avatar Dec 07 '24 18:12 theconsigliere

We started to migrate some of our webapp components to use subgrid and ran into this issue.

Chrome and Firefox work without problems whereas Safari shows a the spinning ball and makes the whole page unresponsive. The only option is to completely close out of the page.

The codepen in the original example has a lot of nesting, but we get the same issue with a subgrid at 3 levels

The issue has halted us being able to migrate our webapps to use grid and subgrid.

Punit-Rathod avatar Dec 16 '24 11:12 Punit-Rathod

@Punit-Rathod Only way I have managed to get this work without a total refactor was using a master grid class for each section / div and then nested subgrids within each section, runs on safari this way and doesn't cause an endless repaint on safari.

theconsigliere avatar Dec 16 '24 11:12 theconsigliere

I've include another codepen example: https://codepen.io/Punit-Rathod-the-selector/pen/JoPEbBw

Note the amount of nesting is minimal. The performance degrades as you add more rows either via adding divs or increasing grid-row: span XXX

@theconsigliere We can't add master grids to each section as all sections need to have aligned rows and columns for the layout without using magic numbers to force alignment.

Punit-Rathod avatar Dec 16 '24 14:12 Punit-Rathod

I just moved from grid into flexbox... I got I little breath for a while but it start degrades as well in the long run... https://stackoverflow.com/questions/75435931/safari-nested-flexbox-performance-issue

Magaav avatar Mar 17 '25 22:03 Magaav

why aint nobody fixing this?

Magaav avatar Oct 07 '25 14:10 Magaav

because this is an old repo, not related to any browser. I'd suggest raising a bug.

rachelandrew avatar Oct 07 '25 14:10 rachelandrew

You can find Safari webkit bugs opened in relation to this here: https://bugs.webkit.org/buglist.cgi?bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&component=Layout%20and%20Rendering&list_id=12735319&product=WebKit&query_format=advanced&short_desc=nested%20grid&short_desc_type=allwordssubstr

Punit-Rathod avatar Nov 14 '25 18:11 Punit-Rathod