From b34f3153f38025a5aeecd63e4694cb021f1c6d46 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Salgado Date: Sun, 14 Sep 2025 03:43:31 +0100 Subject: [PATCH] Prevent overflow in the profiler flamegraph hover boxes --- Lib/profiling/sampling/flamegraph.css | 24 ++++++++++++++++++++++++ Lib/profiling/sampling/flamegraph.js | 16 +++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Lib/profiling/sampling/flamegraph.css b/Lib/profiling/sampling/flamegraph.css index 9d470653170ccc..87387f20f5f958 100644 --- a/Lib/profiling/sampling/flamegraph.css +++ b/Lib/profiling/sampling/flamegraph.css @@ -403,3 +403,27 @@ body { margin: 0; padding: 12px 0; } + +/* Tooltip overflow fixes */ +.python-tooltip { + max-width: 500px !important; + word-wrap: break-word !important; + overflow-wrap: break-word !important; + box-sizing: border-box !important; +} + +/* Responsive tooltip adjustments */ +@media (max-width: 768px) { + .python-tooltip { + max-width: calc(100vw - 40px) !important; + max-height: calc(100vh - 80px) !important; + overflow-y: auto !important; + } +} + +@media (max-width: 480px) { + .python-tooltip { + max-width: calc(100vw - 20px) !important; + font-size: 12px !important; + } +} diff --git a/Lib/profiling/sampling/flamegraph.js b/Lib/profiling/sampling/flamegraph.js index 27dff3b6854895..2334706edd0dc1 100644 --- a/Lib/profiling/sampling/flamegraph.js +++ b/Lib/profiling/sampling/flamegraph.js @@ -42,6 +42,8 @@ function createPythonTooltip(data) { .style("font-weight", "400") .style("line-height", "1.5") .style("max-width", "500px") + .style("word-wrap", "break-word") + .style("overflow-wrap", "break-word") .style("font-family", "'Source Sans Pro', sans-serif") .style("opacity", 0); } @@ -61,7 +63,7 @@ function createPythonTooltip(data) { `
${line + }; white-space: pre-wrap; word-break: break-all; overflow-wrap: break-word; line-height: 1.4; padding: 2px 0;">${line .replace(/&/g, "&") .replace(//g, ">")}
`, @@ -77,7 +79,7 @@ function createPythonTooltip(data) {
+ overflow-y: auto; overflow-x: hidden;"> ${sourceLines}
`; @@ -92,7 +94,7 @@ function createPythonTooltip(data) {
+ overflow-y: auto; overflow-x: hidden; font-family: monospace; font-size: 11px; word-break: break-all; overflow-wrap: break-word;"> ${JSON.stringify(source, null, 2)}
`; @@ -101,13 +103,13 @@ function createPythonTooltip(data) { const tooltipHTML = `
- ${d.data.funcname || d.data.name} + margin-bottom: 8px; line-height: 1.3; word-break: break-word; overflow-wrap: break-word;"> + ${funcname}
- ${d.data.filename || ""}${d.data.lineno ? ":" + d.data.lineno : ""} + padding: 4px 8px; border-radius: 4px; word-break: break-all; overflow-wrap: break-word;"> + ${filename}${d.data.lineno ? ":" + d.data.lineno : ""}