Bug 194242

Summary: Web Inspector: REGRESSION: Resources: WI.TreeOutline assertions when refreshing the page
Product: WebKit Reporter: Devin Rousso <hi>
Component: Web InspectorAssignee: Matt Baker <mattbaker>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, hi, inspector-bugzilla-changes, joepeck, mattbaker, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Devin Rousso 2019-02-04 15:15:17 PST
# Steps to reproduce:
1. inspect <https://apple.com>
2. select the <https://apple.com> frame tree element in the Resources tab
3. refresh the page
 => many assertions fire
     - Assertion Failed: Unable to get index for tree element.
     - Assertion Failed: Index must be a non-negative integer.
Comment 1 Radar WebKit Bug Importer 2019-02-04 15:15:57 PST
<rdar://problem/47802027>
Comment 2 Devin Rousso 2019-02-04 15:17:31 PST
It looks like `WI.TreeOutline`'s `_cachedNumberOfDescendents` is a negative value.
Comment 3 Matt Baker 2019-02-04 16:26:26 PST
Did some digging. When the frame navigates, FrameTreeElement calls TreeElement.prototype.removeChildren, which the immediate base class, FolderizedTreeElement overrides:

removeChildren()
{
    super.removeChildren();

    this._clearNewChildQueue();

    for (var folder of this._folderTypeMap.values())
        folder.removeChildren();

    this._folderExpandedSettingMap.clear();
    this._folderTypeMap.clear();

    this._groupedIntoFolders = false;
}

Calling `removeChildren` for each FolderTreeElement leads to the assertions when trying to calculate the indexes of TreeElements which are no longer attached the tree.

I think the fix is to simply remove this step. I don't think it is necessary. We clear the map below, and I don't believe we hold on to any references to the FolderTreeElements after this function returns.
Comment 4 Matt Baker 2019-02-04 16:26:47 PST
Created attachment 361124 [details]
Patch
Comment 5 Joseph Pecoraro 2019-02-04 16:37:28 PST
Comment on attachment 361124 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=361124&action=review

> Source/WebInspectorUI/ChangeLog:12
> +        Calling `removeChildren` for deteached TreeElements is unnecessary.

Typo: deteached => detached
Comment 6 Matt Baker 2019-02-04 16:41:20 PST
Created attachment 361126 [details]
Patch for landing
Comment 7 WebKit Commit Bot 2019-02-04 17:08:46 PST
Comment on attachment 361126 [details]
Patch for landing

Clearing flags on attachment: 361126

Committed r240950: <https://trac.webkit.org/changeset/240950>
Comment 8 WebKit Commit Bot 2019-02-04 17:08:47 PST
All reviewed patches have been landed.  Closing bug.