I am rendering around 4,000 values into a stacked bar chart to Safari on iOS. Displaying a hover, on only Safari iOS, takes 5-10 seconds, during which the browser freezes. (About once in every 10 reloads the browser doesn’t do this.)
I have dragmode=’pan’, so the user can scroll when zoomed.
When I tap the chart to display the hover, the browser freezes for around 5 seconds while it invalidates the styles and re-renders. Then the hover is then displayed correctly. This does not happen on Safari desktop, nor any other browser, desktop or Android.
The code that triggers the style invalidation is the below call to onStart(e) in src/components/dragelement/index.js, line 29798 in plotly-3.0.1.js or 29903 in plotly-3.1.0.js:
var require_dragelement = __commonJS({
"src/components/dragelement/index.js"(exports, module) {
"use strict";
...
var clampFn = options.clampFn || _clampFn;
function onStart(e) { // <= this line triggers the style invalidation, according to the Safari timeline recorder
gd._dragged = false;
gd._dragging = true;
var offset = pointerOffset(e);
startX = offset[0];
startY = offset[1];
initialTarget = e.target;
initialEvent = e;
rightClick = e.buttons === 2 || e.ctrlKey;
if (typeof e.clientX === "undefined" && typeof e.clientY === "undefined") {
e.clientX = startX;
e.clientY = startY;
}
newMouseDownTime = (/* @__PURE__ */ new Date()).getTime();
...
Dragging works fine, except if there is a hover displayed, in which case the chart first takes 5-10 seconds to clear the hover.
I tried changing to a combined X hover but that does the same. Also tried removing all hovers.
It seems the browser is recalculating layout and re-rendering the chart before adding the hover.
If I set hovermode: falsethe big freeze doesn’t happen. (There is still a second or so pause, because it is allowing for a drag, but this is fine.)
Happy to implement my own hover on chart click if that’s easiest. My HTML layout isn’t very dynamic, all plain HTML and JS flex. I create the DOM elements but this has long completed by the time I render charts let alone hovers.
Huge thanks for any ideas, what is the heavy lift on rendering the hover? Tearing hair out a little and I haven’t much left!