Bug 178554 - Web Inspector: Layer mutations should be purely based on layerId, not based on nodeId
Summary: Web Inspector: Layer mutations should be purely based on layerId, not based o...
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: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 174176
  Show dependency treegraph
 
Reported: 2017-10-19 17:13 PDT by Ross Kirsling
Modified: 2017-11-15 13:00 PST (History)
4 users (show)

See Also:


Attachments
[Image] Problem (274.21 KB, image/png)
2017-10-19 17:13 PDT, Ross Kirsling
no flags Details
Patch (7.71 KB, patch)
2017-10-19 17:17 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff
Patch (8.19 KB, patch)
2017-10-23 10:48 PDT, Ross Kirsling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Kirsling 2017-10-19 17:13:36 PDT
Created attachment 324318 [details]
[Image] Problem

The current implementation of LayerTreeManager#layerTreeMutations tries to cleverly detect when a compositing layer for a given DOM node has been destroyed and recreated (resulting a new layerId but the same nodeId).

This is nonsense for two reasons:
1. Even if you call this layer "preserved", the old layer object and new layer object share NO data, so there's no way for a consumer to act on this supposed preservation.
2. Crucially, a single nodeId can correspond to multiple layerIds at once, such as when a pseudo-element of a DOM node gives rise to a layer of its own.

Turns out that this causes problems even in the legacy Layers sidebar -- simply visit https://devinrousso.com/ for easy repro.
(See attached image, where the layer count is incorrect and some popover content is missing.)

This method should be rewritten to only check layerIds, not nodeIds.
Comment 1 Ross Kirsling 2017-10-19 17:17:16 PDT
Created attachment 324320 [details]
Patch
Comment 2 Devin Rousso 2017-10-20 22:10:29 PDT
Comment on attachment 324320 [details]
Patch

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

> Source/WebInspectorUI/ChangeLog:9
> +        * UserInterface/Controllers/LayerTreeManager.js:
> +        (WI.LayerTreeManager.prototype.layerTreeMutations):

This could use an explanation as to why this is needed or what the problem originally was.

> Source/WebInspectorUI/UserInterface/Controllers/LayerTreeManager.js:-59
> -            return layer.isGeneratedContent ? layer.pseudoElementId : layer.nodeId;

Does this patch still work with pseudo-elements?  Adding a test for this would be awesome =D

> Source/WebInspectorUI/UserInterface/Controllers/LayerTreeManager.js:-73
> -            if (layer.isReflection)

Is the concept of `isReflection` no longer valid/useful?
Comment 3 Ross Kirsling 2017-10-21 16:19:35 PDT
(In reply to Devin Rousso from comment #2)
> > +        * UserInterface/Controllers/LayerTreeManager.js:
> > +        (WI.LayerTreeManager.prototype.layerTreeMutations):
> 
> This could use an explanation as to why this is needed or what the problem
> originally was.

Can do.

> > Source/WebInspectorUI/UserInterface/Controllers/LayerTreeManager.js:-59
> > -            return layer.isGeneratedContent ? layer.pseudoElementId : layer.nodeId;
> 
> Does this patch still work with pseudo-elements?  Adding a test for this
> would be awesome =D
> 
> > Source/WebInspectorUI/UserInterface/Controllers/LayerTreeManager.js:-73
> > -            if (layer.isReflection)
> 
> Is the concept of `isReflection` no longer valid/useful?

Sorry if this wasn't all clear above: It was incorrect to be looking for special cases involving nodeIds at all (as these need not be unique in the layer list). A preserved layer should be nothing more or less than a recycled layerId (the thing that *is* unique). Pseudo-elements were actually the very thing being mishandled on your website, as a result of this special-casing. :) Reflections should follow suit.
Comment 4 Ross Kirsling 2017-10-23 10:48:06 PDT
Created attachment 324564 [details]
Patch
Comment 5 Ross Kirsling 2017-10-23 10:48:40 PDT
Comment on attachment 324564 [details]
Patch

Made ChangeLog and test more informative.
Comment 6 Devin Rousso 2017-10-24 13:07:01 PDT
Comment on attachment 324564 [details]
Patch

r=me
Comment 7 WebKit Commit Bot 2017-10-24 13:11:38 PDT
Comment on attachment 324564 [details]
Patch

Clearing flags on attachment: 324564

Committed r223914: <https://trac.webkit.org/changeset/223914>
Comment 8 WebKit Commit Bot 2017-10-24 13:11:40 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2017-11-15 13:00:59 PST
<rdar://problem/35568610>