jlfwong / speedscope

🔬 A fast, interactive web-based viewer for performance profiles.
https://www.speedscope.app
MIT License
5.59k stars 246 forks source link

Fix infinite recursion on resize #413

Open tstarling opened 1 year ago

tstarling commented 1 year ago

In Chromium 108.0.5359.124 I saw infinite recursion in maybeResize/resize/onBeforeFrame. So I added a recursion guard to maybeResize.

jlfwong commented 1 year ago

Thanks for the contributions! In the case of this one, I'm reluctant to merge this without understanding first why there's infinite recursion. I generally bias heavily towards fixing causes rather than symptoms, and this sounds like a symptom of a logic error to me (probably one I wrote).

tstarling commented 1 year ago

I can reproduce it by just going to https://www.speedscope.app/ and loading the example profile.

jlfwong commented 1 year ago

@tstarling Interesting! Can you say more about exactly what you're doing? When I load up https://www.speedscope.app/ and loading the example profile and try zooming around and resizing the window, I'm not able to create a crash

tstarling commented 1 year ago

No interaction, it fails to even show the profile. Actually, it's logging an exception when the page loads, before I even try to load the profile. Here's the console log after opening the page:

speedscope.tsx:5 speedscope v1.15.0
canvas-context.ts:34 WebGL initialized. renderer: ANGLE (NVIDIA Corporation, NVIDIA GeForce GTX 1650 with Max-Q Design/PCIe/SSE2, OpenGL 4.5.0), vendor: Google Inc. (NVIDIA Corporation), version: WebGL 1.0 (OpenGL ES 2.0 Chromium)
canvas-context.ts:57 Uncaught RangeError: Maximum call stack size exceeded
    at onBeforeFrame (canvas-context.ts:57:10)
    at graphics.ts:497:46
    at Set.forEach (<anonymous>)
    at a.resize (graphics.ts:497:32)
    at maybeResize (application.tsx:101:33)
    at onBeforeFrame (canvas-context.ts:63:7)
    at graphics.ts:497:46
    at Set.forEach (<anonymous>)
    at a.resize (graphics.ts:497:32)
    at maybeResize (application.tsx:101:33)
canvas-context.ts:57 Uncaught RangeError: Maximum call stack size exceeded
    at onBeforeFrame (canvas-context.ts:57:10)
    at graphics.ts:497:46
    at Set.forEach (<anonymous>)
    at a.resize (graphics.ts:497:32)
    at maybeResize (application.tsx:101:33)
    at onBeforeFrame (canvas-context.ts:63:7)
    at graphics.ts:497:46
    at Set.forEach (<anonymous>)
    at a.resize (graphics.ts:497:32)
    at maybeResize (application.tsx:101:33)
canvas-context.ts:57 Uncaught RangeError: Maximum call stack size exceeded
    at onBeforeFrame (canvas-context.ts:57:10)
    at graphics.ts:497:46
    at Set.forEach (<anonymous>)
    at a.resize (graphics.ts:497:32)
    at maybeResize (application.tsx:101:33)
    at onBeforeFrame (canvas-context.ts:63:7)
    at graphics.ts:497:46
    at Set.forEach (<anonymous>)
    at a.resize (graphics.ts:497:32)
    at maybeResize (application.tsx:101:33)
canvas-context.ts:57 Uncaught RangeError: Maximum call stack size exceeded
    at onBeforeFrame (canvas-context.ts:57:10)
    at graphics.ts:497:46
    at Set.forEach (<anonymous>)
    at a.resize (graphics.ts:497:32)
    at maybeResize (application.tsx:101:33)
    at onBeforeFrame (canvas-context.ts:63:7)
    at graphics.ts:497:46
    at Set.forEach (<anonymous>)
    at a.resize (graphics.ts:497:32)
    at maybeResize (application.tsx:101:33)