Closed Bug 1717893 Opened 4 years ago Closed 4 years ago

Inspector empty when element is focused and page refresh

Categories

(DevTools :: Inspector, defect, P2)

defect

Tracking

(firefox92 fixed)

RESOLVED FIXED
92 Branch
Tracking Status
firefox92 --- fixed

People

(Reporter: danny.kulangiev, Assigned: jdescottes)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:90.0) Gecko/20100101 Firefox/90.0

Steps to reproduce:

  1. Open Firefox Developer Edition
  2. Right-click inspect an element (or use cmd+shift+c).
  3. Select an element.
  4. Refresh the page.

Actual results:

The dev tools inspector goes blank (need to close and reopen it again)

Expected results:

Either focus on the element that was selected before the page refresh or refresh the inspector.

Component: Untriaged → Inspector
Product: Firefox → DevTools
Version: other → unspecified
Flags: needinfo?(jdescottes)

Another thing to add:

I am running Firefox Dev Edition on a local web server.

Hi and thanks for filing.

I couldn't reproduce the issue for now, so we will need some more information.

I am running Firefox Dev Edition on a local web server.

Any chance you can share a test case? Either a public webpage, or a small project we could setup?

Also when this happens for you, could you open the Browser Console https://developer.mozilla.org/en-US/docs/Tools/Browser_Console and check if there is any relevant error?

Thanks!

Flags: needinfo?(jdescottes) → needinfo?(danny.kulangiev)

(In reply to Julian Descottes [:jdescottes] from comment #2)

Also when this happens for you, could you open the Browser Console https://developer.mozilla.org/en-US/docs/Tools/Browser_Console and check if there is any relevant error?

In the Browser Console I am getting the following error:

    write resource://devtools/shared/protocol/types.js:362
    write resource://devtools/shared/protocol/Request.js:109
    write resource://devtools/shared/protocol/Request.js:39
    name resource://devtools/shared/protocol/Front/FrontClassWithSpec.js:35
    querySelector resource://devtools/client/fronts/walker.js:145
    querySelectors resource://devtools/client/fronts/walker.js:410
    querySelectors resource://devtools/client/fronts/walker.js:437
inspector.js:364:15
    _handleRejectionIfNotDestroyed resource://devtools/client/inspector/inspector.js:364
    onRootNodeAvailable resource://devtools/client/inspector/inspector.js:1319

If that did not help, I will try to set up an environment where it can be reproduced.

Flags: needinfo?(danny.kulangiev)

(In reply to danny.kulangiev from comment #3)

(In reply to Julian Descottes [:jdescottes] from comment #2)

Also when this happens for you, could you open the Browser Console https://developer.mozilla.org/en-US/docs/Tools/Browser_Console and check if there is any relevant error?

In the Browser Console I am getting the following error:

    TypeError: can't access property "actorID", v is undefined
    write resource://devtools/shared/protocol/types.js:362
    write resource://devtools/shared/protocol/Request.js:109
    write resource://devtools/shared/protocol/Request.js:39
    name resource://devtools/shared/protocol/Front/FrontClassWithSpec.js:35
    querySelector resource://devtools/client/fronts/walker.js:145
    querySelectors resource://devtools/client/fronts/walker.js:410
    querySelectors resource://devtools/client/fronts/walker.js:437
inspector.js:364:15
    _handleRejectionIfNotDestroyed resource://devtools/client/inspector/inspector.js:364
    onRootNodeAvailable resource://devtools/client/inspector/inspector.js:1319

If that did not help, I will try to set up an environment where it can be reproduced.

whoops, formatting got messed up in the code block, I included the first line which was cut off.

Flags: needinfo?(jdescottes)

Thanks for the stack trace! According to this log, it seems that our logic to reselect the previously selected node fails.
This stack also indicates that the node we are trying to reselect seems to be in an iframe.

Basically when you select a node in DevTools, we store an array of selectors which should allow us to "reselect" the node after a refresh. We need an array of those selectors in case the selected node is nested in iframes:
[".selector.to.first.frame", ".selector.to.second.frame", ..., ".selector.to.last.frame", ".node.selector"]

In your case we have at least one frame selector (so I assume the inspected node was inside a frame?) but when we reload the document, we find the frame, but it doesn't have a document yet. The following code fails to find a node https://searchfox.org/mozilla-central/rev/c0fc8c4852e927b0ae75d893d35772b8c60ee06b/devtools/client/fronts/walker.js#423-437
And we don't check that we managed to retrieve a node there, which makes the next call fail. That should be easy to guard if that's really what happens.

I think I can try to build a test case to reproduce something similar, but in the meantime, it would be great if you could tell use more about the structure of the page you are inspecting, in particular if it uses iframes, and if they are somehow dynamically generated?

I'm curious to know if you are hitting the edge case I described or if for some reason we try to reselect iframes in a situation where there was no iframe.

Flags: needinfo?(jdescottes) → needinfo?(danny.kulangiev)

The page I am working on leverages web components so it might have something to do with accessing the shadow DOM. We are not using iframes anywhere, so it might help to just reproduce the issue using web components.

Some more info that I can share is that we are using Lightning Web Components on the page.

Flags: needinfo?(danny.kulangiev)

Fix an edge case which can lead to an empty markup view after reload.

(In reply to danny.kulangiev from comment #6)

The page I am working on leverages web components so it might have something to do with accessing the shadow DOM. We are not using iframes anywhere, so it might help to just reproduce the issue using web components.

Some more info that I can share is that we are using Lightning Web Components on the page.

Thanks for the feedback.

Indeed we handle iframes and custom elements similarly when it comes to reselecting nodes. And it is more likely that the code to initialize a given webcomponent has not been triggered yet when we attempt to reselect it. On top of that we also have some logic to wait for iframes to load before reselecting, whereas we don't do anything for custom elements.

I reproduce with the following STRs:

(and the current patch fixes those STRs, thankfully)

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P2
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1901ae10c819 [devtools] Avoid blank inspector if iframe selector matches non-iframe element r=bomsy
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 92 Branch

Awesome looks like it is fixed :)

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: