Unnecessary allocations in UIElementAutomationPeer of Matrix/Transform
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
_Note that I will submit a PR in the coming days for this issue, so its more of an FYI._
### Description
`CalculateVisibleBoundingRect` attempts to perform an intersection out of matrix transformation from the AP owner to the parent, using matrix inversion. In most simple cases, there will either be identity matrix or just a standard matrix transform.
In the case displayed, `TrySimpleTransformToAncestor` returns a `Matrix`, which then inside `InternalTransformToAncestor` creates a `MatrixTransform`, which is forced to box this `Matrix`, just to immediately invoke `Inverse` property (inherited via `Transform` abstraction), which is then inverted and once again, a `MatrixTransform` is created and `Matrix` must be boxed.
All this can be special-cased with a few lines avoided and done on stack instead, which in this case would save around 800 MB, which is most of what this app has allocated.
### Showcase

### Repro
Note: This repro is specifically crafted to highlight an issue like this.
https://github.com/h3xds1nz/UIAPerformancePitfalls
Contributor guide
Assessment
This issue has not been assessed yet.