Bug 145085

Summary: Web Inspector: Tab Restoration may call shown on initial ContentView twice
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: graouts, inspector-bugzilla-changes, jonowells, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   

Description Joseph Pecoraro 2015-05-15 17:39:32 PDT
* SUMMARY
Tab Restoration may call shown on initial ContentView twice.

* STEPS TO REPRODUCE
1. Inspect <http://bogojoker.com/shell/>
2. In Debugger Tab select the "easySlider.min.js" resource => creates a SourceCodeTextEditor
3. Switch to the Elements Tab
4. Close Inspector => saves state of tabs
5. Open Inspector
6. Select Debugger Tab to trigger tab restoration
  => Unexpectedly the TextResourceContentView for "easySlider.min.js" gets "shown" called twice.

* TRACES
- Note that BackForwardEntry._restoreFromCookie seems to be the culprit.
  - it restores some ContentView and calls shown()
  - it then proceeds to call shown() again on what it just showed.

    Views/SourceCodeTextEditor.js:100:20: CONSOLE LOG SourceCodeTextEditor.shown http://bogojoker.com/shell/js/easySlider.min.js
    Views/SourceCodeTextEditor.js:101:22: CONSOLE TRACE
    0: shown(Views/SourceCodeTextEditor.js:101:22)
    1: shown(Views/TextResourceContentView.js:104:31)
    2: prepareToShow(Models/BackForwardEntry.js:61:35)
    3: _showEntry(Views/ContentViewContainer.js:472:28)
    4: showBackForwardEntryForIndex(Views/ContentViewContainer.js:212:28)
    5: showContentView(Views/ContentViewContainer.js:188:42)
    6: _showContentViewForIdentifier(Views/ResourceClusterContentView.js:236:57)
    7: restoreFromCookie(Views/ResourceClusterContentView.js:147:61)
    8: _restoreFromCookie(Models/BackForwardEntry.js:78:43)
    9: prepareToShow(Models/BackForwardEntry.js:57:32)
    10: _showEntry(Views/ContentViewContainer.js:472:28)
    11: showBackForwardEntryForIndex(Views/ContentViewContainer.js:212:28)
    12: showContentView(Views/ContentViewContainer.js:188:42)
    13: showContentViewForRepresentedObject(Views/ContentBrowser.js:168:58)
    14: showDefaultContentViewForTreeElement(Views/NavigationSidebarPanel.js:196:64)
    15: _checkElementsForPendingViewStateCookie(Views/NavigationSidebarPanel.js:701:54)
    16: _checkOutlinesForPendingViewStateCookie(Views/NavigationSidebarPanel.js:656:60)
    17: finalAttemptToRestoreViewStateFromCookie(Views/NavigationSidebarPanel.js:242:57)
    18: finalAttemptToRestoreViewStateFromCookie([native code])

    Views/SourceCodeTextEditor.js:100:20: CONSOLE LOG SourceCodeTextEditor.shown http://bogojoker.com/shell/js/easySlider.min.js
    Views/SourceCodeTextEditor.js:101:22: CONSOLE TRACE
    0: shown(Views/SourceCodeTextEditor.js:101:22)
    1: shown(Views/TextResourceContentView.js:104:31)
    2: prepareToShow(Models/BackForwardEntry.js:61:35)
    3: _showEntry(Views/ContentViewContainer.js:472:28)
    4: shown(Views/ContentViewContainer.js:425:24)
    5: shown(Views/ClusterContentView.js:75:41)
    6: shown(Views/ResourceClusterContentView.js:125:61)
    7: prepareToShow(Models/BackForwardEntry.js:61:35)
    8: _showEntry(Views/ContentViewContainer.js:472:28)
    9: showBackForwardEntryForIndex(Views/ContentViewContainer.js:212:28)
    10: showContentView(Views/ContentViewContainer.js:188:42)
    11: showContentViewForRepresentedObject(Views/ContentBrowser.js:168:58)
    12: showDefaultContentViewForTreeElement(Views/NavigationSidebarPanel.js:196:64)
    13: _checkElementsForPendingViewStateCookie(Views/NavigationSidebarPanel.js:701:54)
    14: _checkOutlinesForPendingViewStateCookie(Views/NavigationSidebarPanel.js:656:60)
    15: finalAttemptToRestoreViewStateFromCookie(Views/NavigationSidebarPanel.js:242:57)
    16: finalAttemptToRestoreViewStateFromCookie([native code])
Comment 1 Radar WebKit Bug Importer 2015-05-15 17:39:44 PDT
<rdar://problem/20985259>
Comment 2 Joseph Pecoraro 2015-05-15 17:42:06 PDT
Sounds like a duplicate of 135000 but that was closed as WONTFIX.

It would be great to simplify the BackForward logic a bit. It is so complex, I can't follow it. We should really clarify when an entry gets added that wouldn't want "shown" called on it. Otherwise, we can just check "if (!cv.visible) cv.shown()" and not rely on passing booleans around.
Comment 3 Joseph Pecoraro 2015-05-15 17:42:21 PDT
Bug 135000