Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird 1 pixel layout bug when a control is loaded. Repro and video included. #12676

Closed
dbriard opened this issue Aug 26, 2023 · 5 comments · Fixed by #12765
Closed

Weird 1 pixel layout bug when a control is loaded. Repro and video included. #12676

dbriard opened this issue Aug 26, 2023 · 5 comments · Fixed by #12765
Labels

Comments

@dbriard
Copy link
Contributor

dbriard commented Aug 26, 2023

Describe the bug
There is a layout issue when a control is loaded and before it is touched. It is 1 pixel too long in width. After its state change, the control with is reduce by 1 pixel.
This is related to ContentDialog foreground change.

To Reproduce

  1. Create a new Avalonia Application.
  2. Add a button (for example)
  3. Run the app
  4. MouseOver the Button
  5. The width of the button change, it is reduced by 1 pixel ??!!!

To better see the result, put the button inside a LayoutTransformControl with x8 scaling, and set padding to 0
When you run the app, there is 2 pixels between text and border on left side, and 1 pixel on right side.
When you mouseover (in fact, when the state of the foreground change), the left side become 1 px.

If you create a custom theme for the button, with BrushA for Foreground, BrushA again for MouseOver, and BrushB for Pressed.
The 1-pixel shift only happen when the button is pressed, that allow to measure with the inspector, and we can see that the DesiredSize of the text is reduced by 1 pixel after the foreground state change.

Expected behavior
The layout must be good when the control is loaded, and should not change after.

Screenshots

1pixel_bug.mp4

Repro sample
OnePixelBug.zip

Desktop (please complete the following information):

  • OS: Windows 11 (with OS scaling 100%)
  • Version: tested with v11.0.2, v11.0.4 and latest nighly

Additional context
Add any other context about the problem here.

@dbriard dbriard added the bug label Aug 26, 2023
@dbriard dbriard changed the title Weird 1 pixel layout bug when a control is loaded. Repro included. Weird 1 pixel layout bug when a control is loaded. Repro and video included. Aug 26, 2023
@timunie
Copy link
Contributor

timunie commented Aug 28, 2023

👀

can reproduce on my machine. Great and easy sample 👍

@dbriard
Copy link
Contributor Author

dbriard commented Aug 28, 2023

👀

can reproduce on my machine. Great and easy sample 👍

Thanks for looking, I have no idea why that happen, but I hope it can be fixed :)

@timunie
Copy link
Contributor

timunie commented Aug 28, 2023

place your sample into samples > Sandbox and add breakpoints into the layout pass if you want to investigate it on your own further.

@Gillibald
Copy link
Contributor

Could be related to rounding differences. First layout snaps the control to the left. Second to the right. Just some theory.

@MrJul
Copy link
Member

MrJul commented Sep 2, 2023

I had a look at this: please see #12765 for details about the problem and a potential fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants