Closed Bug 1814608 Opened 2 years ago Closed 2 years ago

Inline script may easily have empy breakable lines

Categories

(DevTools :: Debugger, task)

task

Tracking

(firefox112 fixed)

RESOLVED FIXED
112 Branch
Tracking Status
firefox112 --- fixed

People

(Reporter: ochameau, Assigned: ochameau)

References

Details

Attachments

(2 files)

STR:

Notice the empty breakable lines on the second inline script.
Note that it seems to be working more frequently when you set a breakpoint.
This seems to come from this workaround which isn't working on this test page:
https://searchfox.org/mozilla-central/rev/11cf68787bd00edfa7ac6a0ecd07794698cdebdc/devtools/client/debugger/src/actions/sources/newSources.js#323-329

There is many issues here...

  • breakable lines reducer is confusing. It is only about source actor IDs, but this isn't extra clear when reading the reducer module.
  • breakable lines actions setBreakableLines is called from random places, whereas it sounds like it should be called after text content is retrieved?
  • for some reason SourceActor.getBreakableLines doesn't work if you call it early. It may depend on calling getSourceContent first??
  • source actor still clone its internal maps, which is an unecesarry significant perf issue.
Depends on: 1814609

Breakable lines could easily be missed when reloading.
The very original issue is that SourceActor.getBreakableLines can't be called too early during the page load.
The SourceActor may not have received enough content of the HTML page and the HTML string may not
include the inline script sources itself.
This lead to wrong _startLineColumnDisplacement being set to zero and breakable lines
of the inline script are starting from the very first line of the HTML page, instead of where the <script> starts.

Then... the frontend somewhat worksaround that very implicitely and not correctly.
The key is to force fetching the breakable lines after the source text content is fetched.

Covering this isn't trivial as this is a race condition.
But I expanded the coverage in feature tests and tweaked browser_dbg-inline-script-offset.js
which could fail intermittently and no longer fail with this patch and the next one applied.

Assignee: nobody → poirot.alex
Status: NEW → ASSIGNED
  • Remove the usage of PROMISE action, which isn't used
  • Remove the memoizedAction as the reducer is already memoizing the breakableLines

All of this is only useful if we call setBreakableLines concurrently while
this is already in process of being loading.
This may still be theoriticaly possible between newSources and select actions.
But we should rather better coordinate when we pull breakable lines rather than
introduce such complexity. i.e. reduce the number of callsites requiring to load them.

Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/abc019424cec [devtools] Simplify source actor breakable line computation. r=devtools-reviewers,nchevobbe https://hg.mozilla.org/integration/autoland/rev/2e41f4a14afd [devtools] Fix breakable lines of inline script. r=bomsy,devtools-reviewers
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3403f3c933da [devtools] Simplify source actor breakable line computation. r=devtools-reviewers,nchevobbe https://hg.mozilla.org/integration/autoland/rev/cef8502055c5 [devtools] Fix breakable lines of inline script. r=bomsy,devtools-reviewers
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
Flags: needinfo?(poirot.alex)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: