Debugger doesn't see sources that are cleaned up by GC
Categories
(DevTools :: Debugger, enhancement, P3)
Tracking
(Not tracked)
People
(Reporter: davidwalsh, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(4 files, 3 obsolete files)
45.41 KB,
image/png
|
Details | |
17.26 KB,
patch
|
Details | Diff | Splinter Review | |
8.78 KB,
patch
|
Details | Diff | Splinter Review | |
4.75 KB,
patch
|
Details | Diff | Splinter Review |
Reporter | ||
Comment 1•7 years ago
|
||
Reporter | ||
Comment 2•7 years ago
|
||
Comment 3•7 years ago
|
||
Updated•7 years ago
|
Comment 4•7 years ago
|
||
Comment 5•7 years ago
|
||
Updated•7 years ago
|
Comment 6•7 years ago
|
||
Updated•7 years ago
|
Updated•7 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Comment 9•6 years ago
|
||
This patch implements the idea in comment 4. If the debugger attaches and we detect that sources have been GC'ed, a message is shown at the bottom of the sources pane. Reloading or navigating with the debugger open will clear the message.
This works but I think we can do better in terms of detecting whether meaningful script sources have been collected. This will fire if any sources have been collected by the process, including those from pages prior to the user navigating (including the initial contents of a new tab). Showing the message at inappropriate times will be unnecessarily confusing for users.
Comment 10•6 years ago
|
||
Comment 11•6 years ago
|
||
The strategy in this patch works pretty well from the testing I've done, i.e. reporting that there is a missing source at the expected times. This shows the 'Reload to see missing sources' message in the sources pane if at the time the debugger asked for the sources, there is a source meeting the following criteria:
- The source was created for the main thread's runtime since the last page navigation (including going back/forward, reloading, and visiting a new URI).
- The source matches a filter looking for content scripts.
- The source is no longer reachable from any scripts in the main thread's runtime.
Doing things this way avoids needing to keep track of URLs or other information associated with unreachable sources that would need careful management.
This is trying to keep things as simple as possible until there is some feedback about how it could be improved. Note that this can incorrectly report both the presence and absence of missing sources:
-
If a source has been collected that the debugger doesn't care about, like an eval'ed source with no source map info, we will incorrectly report the presence of missing sources.
-
If a page uses a content source from before navigating, if that source is collected then we can incorrectly report the absence of missing sources. I think this can happen when going back/forward (not sure about otherwise), but it seems difficult to trigger in any case.
Comment 12•6 years ago
|
||
Add a Debugger method to determine whether sources that might be relevant to the debugger are unreachable, according to the description in comment 11.
Comment 13•6 years ago
|
||
This patch uses the API added in part 1 to notify the JS engine's debugger when a page navigates (goes back/forward, reloads, or visits a new URI).
Comment 14•6 years ago
|
||
Devtools server/client changes to determine whether there might be missing sources in the main thread's runtime and show a message in the sources pane.
Comment 15•6 years ago
|
||
Comment 16•6 years ago
|
||
(I couldn't set superreview flag to anything, so just cleared the name)
Comment 17•6 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #15)
Comment on attachment 9048707 [details] [diff] [review]
Part 2 - Notify JS when navigating.Do we need to care about bfcached pages?
Somewhere around
https://searchfox.org/mozilla-central/rev/
3e0f1d95fcf8832413457e3bec802113bdd1f8e8/docshell/base/nsDocShell.cpp#7238Do we need to deal with navigations in iframes somehow differently?
And...OnNavigate is static. So if a background tab navigates, we still
notify. Is that all expected?
This is expected, but you're right that the approach has a lot of holes and will only work well in certain circumstances, e.g. visiting a page in a new/existing tab and then opening the debugger. I think we can do better by keeping track of this information at the realm level, which both syncs up better with the debugger's state (debuggees are per-realm) and should avoid needing to know about navigations (since the realms which the debugger will find change when we navigate).
Updated•6 years ago
|
Comment 18•6 years ago
|
||
Comment 19•6 years ago
|
||
Comment 20•6 years ago
|
||
Updated realm-based patch, for posterity.
Comment 21•6 years ago
|
||
:bhacket, looks great. As a comparison, Chrome has something similar in their Security panel.
A follow up I need to explore is opening GCd sources (from the Console for example) in Debugger, that then are non-debuggable as the server isn't aware of them. Is there a bug about those, or am I misunderstanding the case?
Comment 22•6 years ago
|
||
(In reply to :Harald Kirschner :digitarald from comment #21)
:bhacket, looks great. As a comparison, Chrome has something similar in their Security panel.
A follow up I need to explore is opening GCd sources (from the Console for example) in Debugger, that then are non-debuggable as the server isn't aware of them. Is there a bug about those, or am I misunderstanding the case?
Bug 1347018 has STR for this case, where a console link may go to either the debugger or view-source, depending on whether the underlying source has been GC'ed.
Updated•6 years ago
|
Comment 23•5 years ago
|
||
This should be addressed with https://bugzilla.mozilla.org/show_bug.cgi?id=1572596
Description
•