I ran into an issue with Vuetify recently where the 1.0 betas were constantly utilising a CPU core when run in Safari. It turned out, I wasn’t alone and it had been reported as bug 2773.
First step was to create a simple reproduction case, which turned out to be a template with just:
So something to do with navigation drawers and whatever effects the app attribute causes. Looking at how the generated DOM changes with and without ‘app’ led me to discover the suspicious looking CSS:
max-height: calc(100% - 0px);
Sure enough, the problem went away if that was changed to a simple max-height: 100%; but the ‘- 0px’ part isn’t as silly as it seems. If you have a toolbar at the top of the page it adjusts to allow for the toolbar height becoming ‘max-height: calc(100% – 64px)’ which also causes high-CPU. But an element with ‘max-height: calc(100% – 0px)’ by itself doesn’t trigger the bug so there must be something else contributing to the problem…
More digging ensued, including deleting large chunks of Vuetify’s css to see when the problem went away which lead to the rule:
transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
That and the max-height was all the CSS required to reproduce the problem when Vuetify created the DOM, but not enough when applied to a static HTML page.
It turns out the third piece required to trigger the high CPU usage is that the element has to be created with document.createElement. If it’s included in the page HTML or even created with el.outerHTML = ‘…’ there’s no issue. So it turns out to be a Safari/WebKit bug which can be reproduced with:
const nav = document.createElement('aside');
nav.style.maxHeight = 'calc(100% - 0px)';
const originalEl = document.getElementById('app');
nav.style.transitionDuration = '1s';
You can try it out. With Safari 11.0.2 (and possibly other versions) you can see the Timelines tab in dev tools show the page constantly recalculating layout and Activity Monitor will show the process for that tab using around 100% CPU.
The work around for Vuetify was to ensure that transition-property which was defaulting to ‘all’ (because lots of things about navigation drawers animate) doesn’t include the ‘max-height’ property or anything else that uses ‘calc’. Hence pull request 2958.
The problem appears to have already been fixed in WebKit as I can’t reproduce it in the current Safari Technology Preview build.