profiler icon indicating copy to clipboard operation
profiler copied to clipboard

An error occurred in Firefox Profiler while analysing a profile

Open mayankleoboy opened this issue 1 year ago • 7 comments

I had profiled https://battle.modez.pro/ , and was looking at the profile. Suddenly got this error:

Uh oh, some unknown error happened in profiler.firefox.com.

Error: Expected an item to exist, and it was undefined..

Please report this issue to the developers, including the full error as displayed in the Developer Tools’ Web Console.

Error in console: 10:14:49.724 injected firefox content.js:142:11 10:14:49.858 Successfully compiled asm.js code (total compilation time 27ms) zee-worker.js 10:15:07.345 Error: Expected an item to exist, and it was undefined. h flow.js:182 render SampleTooltipContents.js:136 React 10 react-dom.production.min.js:188:119 React 11 10:15:07.345 An unhandled error was thrown in a React component. Error: Expected an item to exist, and it was undefined. h flow.js:182 render SampleTooltipContents.js:136 React 10

Gk@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:133:53375 div Kb@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:114:44368 div Hk@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:133:54068 @https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:117:15904 div Ax@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:281 @https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:117:15904 c@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:24380 div div li PS@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:70940 c@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:24380 ol KS@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:78856 li YS@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:81848 c@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:24380 ol KS@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:78856 div div div lB@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:94960 div oB@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:89197 c@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:24380 vB@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:113962 @https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:117:15904 c@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:24380 LB@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:123460 c@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:24380 div s@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:200:573772 div t@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:200:575421 div div tk@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:133:27292 YB@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:126842 c@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:24380 UI@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:158880 c@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:24380 jm@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:111:3131 c@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:24380 div QB@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:128910 c@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:24380 cg@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:111:19405 ug de@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:17306 ce@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:17219 g_@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:179088 c@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:24380 st@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:2:22644 cg@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:111:19405 dg v_@https://profiler.firefox.com/main.1cb3af3791ee766fff86.bundle.js:137:180180 ErrorBoundary.js:43:12 10:15:21.681 Unknown property ‘-moz-user-focus’. Declaration dropped. from-browser:1:604 10:15:21.684 Unknown property ‘-moz-user-focus’. Declaration dropped. from-browser:1:1497 10:15:21.684 Unknown property ‘-moz-user-focus’. Declaration dropped. from-browser:1:349 10:15:21.685 Unknown property ‘-moz-user-focus’. Declaration dropped.

┆Issue is synchronized with this Jira Task

mayankleoboy avatar Jan 05 '25 04:01 mayankleoboy

This happens at https://github.com/firefox-devtools/profiler/blob/acd55ea2968e87f20eebd07e3fcdef82e6ee85ca/src/components/shared/SampleTooltipContents.js#L132-L139 It would be good to check for the existence of the stackIndex in the if condition instead of using ensureExists.

julienw avatar Jan 06 '25 14:01 julienw

Hello, Could you please give a hint how to reproduce it locally? For example load a profile from file or from URL and which action in https://battle.modez.pro/ can cause it?

theoniko avatar Feb 04 '25 16:02 theoniko

Honestly I'm not sure when this case might happen. It's rare enough that we might want to have a warning for this case, so that if we see it in the wild at least we don't crash and somebody would be able to upload the profile still.

julienw avatar Feb 04 '25 17:02 julienw

No problem, I thought maybe @mayankleoboy had and could attach the profile file that caused the exception so as to have a way reproduce it.

I create a draft which probably avoid this exception https://github.com/firefox-devtools/profiler/pull/5353.

theoniko avatar Feb 06 '25 09:02 theoniko

@julienw btw I was trying to debug SampleTooltipContents.test.js locally with visual studio code based on launch.json in windows OS unsuccessfully. Do you have a hint why my breaking points like in testcase it('renders the CPU usage properly for the first part of the sample',..) was not hit? I would be grateful if you could give some feedback.

Debugger attached. yarn run v1.22.22 $ node bin/output-fixing-commands.js cross-env LC_ALL=C TZ=UTC NODE_ENV=test jest .\node_modules\jest\bin\jest --runInBand C:\Users\nikol\Desktop\mozilla\profiler\src\test\components\SampleTooltipContents.test.js Debugger attached. 💡 You might be able to fix the error by running yarn test -u Waiting for the debugger to disconnect... Done in 0.89s. Waiting for the debugger to disconnect...

theoniko avatar Feb 06 '25 09:02 theoniko

Actually I was looking at a profile and managed to reproduce it, and this is easier to reproduce after #5298. This is happening when the stack is filtered though a transform when we already have a tooltip hovered in the activity graph. Here's an example:

STR:

  • Load any profile, like: https://share.firefox.dev/4gu55uK
  • Below the activity graph, there are squares that are called "sample graph". They are here:
Image

Click any of those squares.

  • Do not move your mouse after clicking, and press the "d" key.

This will apply the "drop samples" transform and it will remove them from the view.

Expected behavior: it should not crash Current behavior: it crashes

So it's more likely because applying a transform removes the "stack" value of the sample. This is mostly due to the reason we get the filtered thread here. We should ideally do not render this popup when there is no stack.

You can test it locally by converting the profiler.firefox.com url to http://localhost:4242.

canova avatar Feb 06 '25 20:02 canova

@julienw btw I was trying to debug SampleTooltipContents.test.js locally with visual studio code based on launch.json in windows OS unsuccessfully. Do you have a hint why my breaking points like in testcase it('renders the CPU usage properly for the first part of the sample',..) was not hit? I would be grateful if you could give some feedback.

Debugger attached. yarn run v1.22.22 $ node bin/output-fixing-commands.js cross-env LC_ALL=C TZ=UTC NODE_ENV=test jest .\node_modules\jest\bin\jest --runInBand C:\Users\nikol\Desktop\mozilla\profiler\src\test\components\SampleTooltipContents.test.js Debugger attached. 💡 You might be able to fix the error by running yarn test -u Waiting for the debugger to disconnect... Done in 0.89s. Waiting for the debugger to disconnect...

usually I use the word "debugger;" explicitely in the code so that I'm sure it will break ;-)

julienw avatar Feb 07 '25 09:02 julienw