Page MenuHomePhabricator

Visual diff doesn't highlight changes inside a container
Closed, ResolvedPublic8 Estimated Story Points

Description

Example: https://de.wikipedia.org/w/index.php?diff=174338623&oldid=174328623&diffmode=visual&visualdiff=1

image.png (2×3 px, 654 KB)

Though only a few changes were made, the visual diff just shows the complete old version as deleted, and the complete new version as inserted.
I assume this is because the whole page is inside a <div> container, so this shouldn't happen very often, but it still would be nice to have the visual diff display the actual changes inside the container in such a case.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Deskana renamed this task from Visual diff behaves poorly for changes inside a container to Historical visual diff behaves poorly for changes inside a container.Feb 26 2018, 11:41 AM
Deskana moved this task from To Triage to TR6: Visual diffs on the VisualEditor board.
Deskana set the point value for this task to 8.

In this particular case, the problem is caused by the diff timing out, at which point it just gives up and says everything in the old version was removed and everything in the new version was inserted... Once T180842 is fixed, we will at least show a message to explain that this has happened.

You're right that the containers are causing the problem here - without the containers, the diff doesn't time out. The reason is that there is a speed-up that is applied to top level elements in the document, where we use a fast check to see if any of them are exactly the same. If all of those lists/templates were top-level, then we'd quickly match up the ones that are the same using the fast check; however, in this case the <div> is the only top-level element, and once the fast check finds that the old <div> isn't exactly the same as the new <div>, it then applies the slow differ to everything inside.

The reason everything inside is slow to diff is because of all the lists - the slow part of the differ is particularly slow for lists. Once we special-case lists (see T187632) I would expect that this wouldn't time out any more...

@Tchanders Given the complexity, maybe we should put this back into the backlog? Displaying the timeout at least makes it more obvious what's happened, which might be good enough for now.

The reason I put it here is because the work I'm doing on lists diffs happens to solve this too, but happy to move it if that makes more sense...

Esanders moved this task from In progress to Code review on the VisualEditor (Current work) board.
Esanders moved this task from Code review to Incoming on the VisualEditor (Current work) board.
Esanders edited projects, added VisualEditor; removed VisualEditor (Current work).
Esanders moved this task from To Triage to TR6: Visual diffs on the VisualEditor board.

Change 750777 had a related patch set uploaded (by Bartosz Dziewoński; author: Esanders):

[VisualEditor/VisualEditor@master] Diff some nodes as if they are documents, e.g. <div>s

https://gerrit.wikimedia.org/r/750777

Change 750777 merged by jenkins-bot:

[VisualEditor/VisualEditor@master] Diff some nodes as if they are documents, e.g. <div>s

https://gerrit.wikimedia.org/r/750777

The patch significantly improves this, although it also reveals new issues – apparently the background on the container hides all of the diff context (this is similar to T292491). But if you overlook that, the changes are highlighted perfectly.

image.png (2×1 px, 110 KB)

(screenshot is from my local testing wiki, so the linked articles/templates are missing)

matmarex renamed this task from Historical visual diff behaves poorly for changes inside a container to Historical visual diff doesn't highlight changes inside a container.Jan 10 2022, 11:26 PM
matmarex removed a project: Patch-For-Review.
matmarex updated the task description. (Show Details)

Change 752764 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (2db326345)

https://gerrit.wikimedia.org/r/752764

Change 752764 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (2db326345)

https://gerrit.wikimedia.org/r/752764

Change 753179 had a related patch set uploaded (by Esanders; author: Esanders):

[VisualEditor/VisualEditor@master] DiffElement: Change order of z-index fixes

https://gerrit.wikimedia.org/r/753179

Change 753198 had a related patch set uploaded (by Esanders; author: Esanders):

[VisualEditor/VisualEditor@master] DiffElement: Collapse context to spacers in isDiffedAsDocument nodes

https://gerrit.wikimedia.org/r/753198

The above patches fix the z-index issue, and then handle context collapsing in document wrappers (the 3 vertical dots). The diff looks like this now:

image.png (1×1 px, 241 KB)

Change 753179 merged by jenkins-bot:

[VisualEditor/VisualEditor@master] DiffElement: Change order of z-index fixes

https://gerrit.wikimedia.org/r/753179

Change 753198 merged by jenkins-bot:

[VisualEditor/VisualEditor@master] DiffElement: Collapse context to spacers in isDiffedAsDocument nodes

https://gerrit.wikimedia.org/r/753198

matmarex edited projects, added Editing QA; removed Patch-For-Review.

Looks good enough to me to close this task :D

Change 754004 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (57e82187b)

https://gerrit.wikimedia.org/r/754004

Change 754004 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Update VE core submodule to master (57e82187b)

https://gerrit.wikimedia.org/r/754004

The above patches fix the z-index issue, and then handle context collapsing in document wrappers (the 3 vertical dots). The diff looks like this now:

image.png (1×1 px, 241 KB)

On a closer look, the diff in the second list is incorrect – the inserted "Template:J" is shown at the end, but it should be shown immediately after the removed list item. I wonder if that's because there's another "Template:J" there? Or maybe this is related to T198529? Anyway, I think we can ignore this for now, and treat it as a separate issue.

Esanders renamed this task from Historical visual diff doesn't highlight changes inside a container to Visual diff doesn't highlight changes inside a container.Jan 16 2022, 12:01 AM

Wrapped the page content in a <div> container and made changes to the list. This behaves as expected:

Screenshot 2022-01-19 at 19.18.36.png (1×3 px, 269 KB)
.

ppelberg claimed this task.