Bug 194242 - Web Inspector: REGRESSION: Resources: WI.TreeOutline assertions when refreshing the page
Summary: Web Inspector: REGRESSION: Resources: WI.TreeOutline assertions when refreshi...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Matt Baker
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-02-04 15:15 PST by Devin Rousso
Modified: 2019-02-04 17:08 PST (History)
6 users (show)

See Also:


Attachments
Patch (1.84 KB, patch)
2019-02-04 16:26 PST, Matt Baker
no flags Details | Formatted Diff | Diff
Patch for landing (1.84 KB, patch)
2019-02-04 16:41 PST, Matt Baker
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.