diff --git a/tinygrad/viz/index.html b/tinygrad/viz/index.html
index a2af54f57d..77d4e4292e 100644
--- a/tinygrad/viz/index.html
+++ b/tinygrad/viz/index.html
@@ -252,7 +252,7 @@
}
#device-list > div {
min-height: 32px;
- max-width: 132px;
+ width: 132px;
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
@@ -261,6 +261,9 @@
#device-list > div:hover {
background-color: rgba(20, 23, 35, 0.3);
}
+ #device-list {
+ height: fit-content;
+ }
.raw-text {
padding: 0 8px;
width: 100%;
diff --git a/tinygrad/viz/js/index.js b/tinygrad/viz/js/index.js
index 00eacafefd..4bb4a2bc41 100644
--- a/tinygrad/viz/js/index.js
+++ b/tinygrad/viz/js/index.js
@@ -380,9 +380,9 @@ async function renderProfiler() {
function resize() {
const profiler = document.querySelector(".profiler");
- // NOTE: use clientWidth to account for the scrollbar
- let [width, height] = [profiler.clientWidth, profiler.scrollHeight];
- width -= rect("#device-list").width+padding;
+ const sideRect = rect("#device-list");
+ const width = profiler.clientWidth-(sideRect.width+padding), height = Math.round(sideRect.height);
+ if (canvas.width === width*dpr && canvas.height === height*dpr) return;
canvas.width = width*dpr;
canvas.height = height*dpr;
canvas.style.height = `${height}px`;
@@ -395,8 +395,7 @@ async function renderProfiler() {
d3.select(canvas).call(canvasZoom);
document.addEventListener("contextmenu", e => e.ctrlKey && e.preventDefault());
- resize();
- window.addEventListener("resize", resize);
+ new ResizeObserver(([e]) => e.contentRect.width > 0 && resize()).observe(profiler.node());
function findRectAtPosition(x, y) {
const { top, left, width, height } = rect(canvas);