Closed Bug 1552186 Opened 7 years ago Closed 7 years ago

Remove nsIRemoteTab::windowGlobalParents getter

Categories

(Core :: DOM: Content Processes, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla69
Tracking Status
firefox69 --- fixed

People

(Reporter: mconley, Assigned: rhunt)

References

Details

Attachments

(1 file, 1 obsolete file)

Bug 1549753 introduced a new handy getter, windowGlobalParents, on nsIRemoteTab.

Right now, it returns all WindowGlobalParents for all subtrees.

This was originally in support of my work in bug 1533949 - however, upon testing, there's a slight alteration that we need in order for bug 1533949 to finish.

Specifically, I'm hoping windowGlobalParents can returns only the WindowGlobalParent's from the roots of process-contiguous subtrees.

Hopefully this will help illustrate what I mean by process-contiguous trees:

Suppose that a document has the following frame structure:

                  a
               /     \
              b        c
            /   \    /  \
           b    d   c    c
               /          \
              d            d

where each letter represents the process that each frame runs in, then we consider
process-contiguous trees of frames to be ones where all frames are directly connected
and running in the same process. Process-contiguous subtrees are denoted in the following
graph with shared numbers.

                  a1
               /     \
              b2        c3
            /    \    /   \
           b2    d4  c3   c3
                /          \
              d4            d5

Specifically, note that the d5 leaf node, while belonging to the same process as the
d4 nodes are not directly connected, so it's not process-contiguous.

To further illustrate, I've marked the roots of the process contiguous subtrees with a *:

                  a1*
               /     \
              b2*      c3*
            /    \    /   \
           b2    d4* c3   c3
                /          \
              d4            d5*

Thanks for the diagrams, those really helped!

Taking another attempt here, I think we can do this with two pieces.

  1. <xul:browser>.frameloader.browsingContext.currentWindowGlobalParent (already exists)
    a. This should give you 'a' in that diagram
  2. WindowGlobalParent.getNearestRemoteDescendants() (doesn't exist yet)
    a. This would give you the closest '' descendants of a given WindowGlobalParent
    b. e.g. For a1
    , you would get [b2*, c3*]. For b2*, you would get [d4*]. For c3*, you would get [d5*].
    b. With this you could traverse the contiguous browser tree roots by starting at currentWindowGlobalParent

This commit adds getNearestRemoteDescendants as a way to get the contiguous
browser subtree roots that are descendant from a given WindowGlobalParent.

This method wasn't correct for what mconley needed and is no longer needed.

Depends on D31505

Now that bug 1554280 has landed, is it possible to implement this method entirely in JS now?

Roughly something like:

function getNearestRemoteDescendants(frameLoader) {
  let result = [];
  function visitBC(bc) {
    if (!bc) {
      return;
    }
    let wgp = child.currentWindowGlobal;
    if (wgp && wgp.isProcessRoot) {
      result.push(wgp);
    }
    for (let child of bc.getChildren()) {
      visitBC(child);
    }
  }
  visitBC(frameLoader.browsingContext);
  return result;
}

I'm not sure if something additional is needed to filter out BFCache'd WGP's, or if only checking currentWindowGlobal's is enough.

Flags: needinfo?(nika)
Flags: needinfo?(mconley)

(In reply to Ryan Hunt [:rhunt] from comment #5)

Now that bug 1554280 has landed, is it possible to implement this method entirely in JS now?

Yeah, it should be doable. Your method is missing a few return calls, (e.g. we shouldn't look at the children of a BC which is also a process root), and has some minor typos (like child instead of bc), but should be correct.

Flags: needinfo?(nika)

Cool, yeah, I can use something like that implementation in JS now for the PermitUnload case, so I guess we can close this out as essentially fixed by bug 1554280. Thanks!

Status: NEW → RESOLVED
Closed: 7 years ago
Flags: needinfo?(mconley)
Resolution: --- → DUPLICATE
Attachment #9065487 - Attachment is obsolete: true

I'm going to reuse this bug to remove the getter that was originally added to solve this problem.

Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Summary: nsIRemoteTab.windowGlobalParents should return the roots of process-contiguous subtrees → Remove nsIRemoteTab::windowGlobalParents getter
Pushed by rhunt@eqrion.net: https://hg.mozilla.org/integration/autoland/rev/b2620ccb1d84 Remove `windowGlobalParents` getter from nsIRemoteTab. r=nika
Status: REOPENED → RESOLVED
Closed: 7 years ago → 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla69
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: