Closed Bug 1265823 Opened 8 years ago Closed 5 years ago

Add a "view sub-range" view to large JS files?

Categories

(DevTools :: Debugger, enhancement)

enhancement
Not set
normal

Tracking

(firefox48 affected)

RESOLVED DUPLICATE of bug 1291419
Tracking Status
firefox48 --- affected

People

(Reporter: jujjyl, Unassigned)

References

(Blocks 1 open bug)

Details

In bug 1158098, we are working towards a way to scale the debugger capability to view large asm.js files.

Nick Shin from Epic mentions that he often would like to click on the "URL:line:column" heading at the far right side of an error or a warning message in page console, to jump to the corresponding file:line in the source script. In the current form, if the JS file is very large, clicking on the URL link  hangs the browser when the debugger takes a long time to open the file.

His suggestion is to make these URL:line:column links jump to the debugger, but when opened this way, have the debugger view window only show up a relatively small amount of JS code before and after the line:column location in question, for context. More of the JS code would dynamically be populated to show up when one scrolls towards the end of the view.

Additionally there could be a toggle icon button to switch between "Show context around error only"/"Show whole JS file", if one wanted to switch to view all code in the file. When opening the file in a "normal" way where there is no associated JS file:line error context where the navigation occurred from, the view could show the whole file and this toggle context icon button would be disabled or hidden.

This would let the user see the code related to the error without the fear of the browser hanging. The idea for this option came from Visual Studio disassembly view, which operates in the same way, since it has no hope of populating all the machine code in the program address space into the edit box either. See http://www.cprogramming.com/tutorial/Images/IDE_DebugWindows_Disassembly.JPG for an illustration. (from old VS version, but the idea is the same, the vertical scrollbar is placed in the middle position when one opens up, and scrolling it far up or down would dynamically reveal more machine code)
The Debugger API specifies a "substring" and "lineToPosition" methods for Debugger.Source instances to help make this sort of windowing possible. They're not yet implemented because we haven't needed them; perhaps now's the time.

https://hg.mozilla.org/mozilla-central/file/06678484909c/js/src/doc/Debugger/Debugger.Source.md#l251

You'd also need appropriate extensions to the protocol.

Note that this only works at all because our devtools clear Debugger's 'allowUnobservedAsmJS' flag, which causes SpiderMonkey to not optimize Asm.js, and to keep the source around. In true asm.js execution, I'm pretty sure we don't retain the source code at all.

https://hg.mozilla.org/mozilla-central/file/06678484909c/js/src/doc/Debugger/Debugger.md#l28
Product: Firefox → DevTools
Blocks: dbg-wasm
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.