Elements are rendered in the wrong order in 0.10.6
See original GitHub issueDescribe the bug I have encountered a weird bug that, in the right conditions, causes elements to be drawn in the wrong order (so that, if there are overlapping controls, the ones that should be behind are instead drawn in front of the others), see screenshots.
To Reproduce Create a new Avalonia application with a Window with the following content:
<Viewbox>
<Canvas Width="140" Height="60">
<Path Fill="Red" Data="M 30, 15 L 22.5, 27.99038105676658 L 7.5000000000000036, 27.99038105676658 L 0, 15.000000000000002 L 7.499999999999993, 2.0096189432334235 L 22.5, 2.0096189432334217Z" />
<Path Fill="Green" Data="M 45, 15 L 37.5, 27.99038105676658 L 22.500000000000004, 27.99038105676658 L 15, 15.000000000000002 L 22.499999999999993, 2.0096189432334235 L 37.5, 2.0096189432334217Z" />
<Path Fill="Blue" Data="M 37.5, 15 L 30, 27.99038105676658 L 15.000000000000004, 27.99038105676658 L 7.5, 15.000000000000002 L 14.999999999999993, 2.0096189432334235 L 30, 2.0096189432334217Z" />
<Path Fill="Red" Data="M 75, 15 L 67.5, 27.99038105676658 L 52.5, 27.99038105676658 L 45, 15.000000000000002 L 52.49999999999999, 2.0096189432334235 L 67.5, 2.0096189432334217Z" />
<Path Fill="Green" Data="M 90, 15 L 82.5, 27.99038105676658 L 67.5, 27.99038105676658 L 60, 15.000000000000002 L 67.5, 2.0096189432334235 L 82.5, 2.0096189432334217Z" />
<Path Fill="Blue" Data="M 82.5, 15 L 75, 27.99038105676658 L 60, 27.99038105676658 L 52.5, 15.000000000000002 L 59.99999999999999, 2.0096189432334235 L 75, 2.0096189432334217Z" />
<Path Fill="Red" Data="M 120, 15 L 112.5, 27.99038105676658 L 97.5, 27.99038105676658 L 90, 15.000000000000002 L 97.5, 2.0096189432334235 L 112.5, 2.0096189432334217Z" />
<Path Fill="Green" Data="M 135, 15 L 127.5, 27.99038105676658 L 112.5, 27.99038105676658 L 105, 15.000000000000002 L 112.5, 2.0096189432334235 L 127.5, 2.0096189432334217Z" />
<Path Fill="Blue" Data="M 127.5, 15 L 120, 27.99038105676658 L 105, 27.99038105676658 L 97.5, 15.000000000000002 L 105, 2.0096189432334235 L 120, 2.0096189432334217Z" />
<Path Fill="Red" Data="M 30, 45 L 22.5, 57.99038105676658 L 7.5000000000000036, 57.99038105676658 L 0, 45 L 7.499999999999993, 32.00961894323342 L 22.5, 32.00961894323342Z" />
<Path Fill="Green" Data="M 45, 45 L 37.5, 57.99038105676658 L 22.500000000000004, 57.99038105676658 L 15, 45 L 22.499999999999993, 32.00961894323342 L 37.5, 32.00961894323342Z" />
<Path Fill="Blue" Data="M 37.5, 45 L 30, 57.99038105676658 L 15.000000000000004, 57.99038105676658 L 7.5, 45 L 14.999999999999993, 32.00961894323342 L 30, 32.00961894323342Z" />
<Path Fill="Red" Data="M 75, 45 L 67.5, 57.99038105676658 L 52.5, 57.99038105676658 L 45, 45 L 52.49999999999999, 32.00961894323342 L 67.5, 32.00961894323342Z" />
<Path Fill="Green" Data="M 90, 45 L 82.5, 57.99038105676658 L 67.5, 57.99038105676658 L 60, 45 L 67.5, 32.00961894323342 L 82.5, 32.00961894323342Z" />
<Path Fill="Blue" Data="M 82.5, 45 L 75, 57.99038105676658 L 60, 57.99038105676658 L 52.5, 45 L 59.99999999999999, 32.00961894323342 L 75, 32.00961894323342Z" />
<Path Fill="Red" Data="M 120, 45 L 112.5, 57.99038105676658 L 97.5, 57.99038105676658 L 90, 45 L 97.5, 32.00961894323342 L 112.5, 32.00961894323342Z" />
<Path Fill="Green" Data="M 135, 45 L 127.5, 57.99038105676658 L 112.5, 57.99038105676658 L 105, 45 L 112.5, 32.00961894323342 L 127.5, 32.00961894323342Z" />
<Path Fill="Blue" Data="M 127.5, 45 L 120, 57.99038105676658 L 105, 57.99038105676658 L 97.5, 45 L 105, 32.00961894323342 L 120, 32.00961894323342Z" />
</Canvas>
</Viewbox>
Expected behavior Each path represents a hexagon; in all “triplets”, the hexagons are partially overlapping, and the blue hexagon should be over the green hexagon, which is over the red hexagon. The preview correctly shows this, however, when the application is executed, the order for some of the triplets is wrong.
Screenshots
Result when running the program:
Result in the preview (correct behaviour):
Desktop (please complete the following information):
- OS: Tested on Windows, Ubuntu 20.10 and macOS (the bug happens in all three)
- Version: Bug occurs with version 0.10.6; works fine with 0.10.3-0.10.5
Additional context There seems to be some dependency on the number of controls: removing any two paths from the example above recovers the correct behaviour.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
This problem is caused by an unstable sort in the deferred renderer actually. We need to change to an another implementation since
Array.Sort
is problematic in this case.No it is not. This is definitely a bug inside the DeferredRenderer that needs to be fixed. Thanks for helping.