Bad zSorting when zIndex is the same

Hi, I have been investigating why some Elements randomly pop in front of other in our app. This has revealed a bug in the lightning’s zSorting algorithm, it does not sort Elements with the same zIndex by updateTreeOrder.

The issue is on sortZIndexedChildren of ElementCore, on lines 2062 “// Merge-sort arrays;” it assumes both arrays are sorted, however same zIndex items may not be (since _updateTreeOrder change does not trigger _zIndexResort = true the a array may have unsorted items)

The logic that ensured this was removed on version 1.0.4: performance(updateTreeOrder): refactor, make simpler and (in most cas… · rdkcentral/Lightning@38285e0 · GitHub

Any ideas on how to fix it?

Can you file this as an issue on the Lightning github - Thanks! @michiel FYI

1 Like

Hi, I have posted the plaayground example of the issue as requested:

Playground example

  1. To see the bug press left.
  2. Can see the issue with _updateTreeOrder not begin sorted by pressing right (after pressing left).
  3. Can fix the zSort algorithm by pressing down.

Is it clear? Can you understand the bug?

All the PRs were merged I assume this was fixed… I think the bug just needs to be closed…

I am not sure what you mean. Can you not reproduce the bug with the Playground example?

You’re probably referring to this PR fix: order same zIndex elements by updateTreeOrder by jorge-graca-sky · Pull Request #441 · rdkcentral/Lightning · GitHub

That one hasn’t been merged yet and unfortunately didn’t make our latest January release because we needed a bit more time to validate the changes (and any impact they may have).

I believe for the upcoming April release we should be able to work through this PR and get it included in the release.

Tagging @uguraslan for awareness - let’s make sure we pick this PR up.