firefox-developer-toolsfirefox-developer-edition

Why do my breakpoints flee from their intended position


I'm experiencing the behaviour of breakpoints moving to the end of the file in Firefox Developer Edition when trying to set them anywhere in the javascript.

enter image description here

Sometimes after restarting the PC or the next day it's working, but I'm unsure whether some code leads to this issue or whether this is a bug in Firefox Developer Edition.


Solution

  • When you set a breakpoint on a line that contains no executable code, the debugger tries to be helpful and slide the breakpoint to the next closest line it can find with executable code on it. This is not as easy as it seems, because its possible to set breakpoints on scripts that have already been garbage collected, so the debugger can't always tell whether a line contains no executable code, or whether the corresponding script has just been garbage collected.

    The problem is even more complicated when source maps are involved, because the debugger needs to figure out what lines in the original source correspond to the line in the generated source on which you set the breakpoint. The way we currently do this isn't always accurate, which can lead to problems like the one you're seeing.

    That said, there are other things that could explain why your breakpoints aren't working the way they should. For instance, we also need to map breakpoint locations to bytecode offsets, which isn't always done accurately either.

    We are actively refactoring the breakpoint code in the debugger at the moment in an attempt to resolve these issues, so I wouldn't be surprised if you hit upon a regression. The best thing to do would be to file a bug in bugzilla for the issue, ideally with steps to reproduce.

    Hope that helps!