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

[iOS] Fix Gray Line Appears on the Right Side of GraphicsView with Decimal WidthRequest #26368

Merged
merged 10 commits into from
Feb 13, 2025

Conversation

devanathan-vaithiyanathan
Copy link
Contributor

@devanathan-vaithiyanathan devanathan-vaithiyanathan commented Dec 4, 2024

Issue Details

GraphicsView has its Width or Height set to a decimal value (e.g., 0.25 or 0.75) and a background is applied, an unwanted gray line appears on the view on the iOS platform.

RootCause

Background color rendering inconsistency in GraphicsView occurs due to incorrect boundary value. causing visible lines at view edges when using decimal width and height dimensions.

Description of Changes:

When providing a graphics view size with decimal values like XX.25, iOS converts the decimal part to a value like XX.3333331, which causes a gray line to appear due to rounding inconsistencies.
In the graphics view, the background color is currently applied directly to the View element. However, it is unnecessary to apply the background color to the entire View element. Instead, the background color should be applied only to the drawable area.
To address this issue, we stopped mapping the background color to the View element and instead mapped it to the graphics view. Additionally, whenever the background color changes, we invalidate the drawable to redraw the drawable area with the updated color.

Issues Fixed

Fixes #25502

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Output Screenshot

Before After


Sorry, something went wrong.

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Dec 4, 2024
Copy link
Contributor

Hey there @devanathan-vaithiyanathan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@kubaflo
Copy link
Contributor

kubaflo commented Dec 4, 2024

The strange thing about this bug is that it is only applicable for the graphics view with decimal values XX.25 It happens because iOS converts the decimal part to something line XX.3333331. I wonder if it is worth wrapping the GraphicsView inside a wrapper view only for this case. Moreover, if you use a transparent background instead of a white color then the problem disappears. And the line is invisible with any color different than white. Maybe there's a better fix for this🤔

@mattleibow what do you think?

@sheiksyedm sheiksyedm added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Dec 6, 2024
@jfversluis jfversluis added the area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing label Dec 9, 2024
@devanathan-vaithiyanathan
Copy link
Contributor Author

devanathan-vaithiyanathan commented Dec 11, 2024

The strange thing about this bug is that it is only applicable for the graphics view with decimal values XX.25 It happens because iOS converts the decimal part to something line XX.3333331. I wonder if it is worth wrapping the GraphicsView inside a wrapper view only for this case. Moreover, if you use a transparent background instead of a white color then the problem disappears. And the line is invisible with any color different than white. Maybe there's a better fix for this🤔

@mattleibow what do you think?

@kubaflo When providing a graphics view size with decimal values like XX.25, iOS converts the decimal part to a value like XX.3333331, which causes a gray line to appear due to rounding inconsistencies.
In the graphics view, the background color is currently applied directly to the View element. However, it is unnecessary to apply the background color to the entire View element. Instead, the background color should be applied only to the drawable area.
To address this issue, we stopped mapping the background color to the View element and instead mapped it to the graphics view. Additionally, whenever the background color changes, we invalidate the drawable to redraw the drawable area with the updated color.

The Unwanted - Line is not limited to a white background but occurs with any background color applied, except for transparent.

@devanathan-vaithiyanathan devanathan-vaithiyanathan marked this pull request as ready for review December 11, 2024 18:05
@jfversluis
Copy link
Member

jfversluis commented Dec 12, 2024

/azp run

This comment was marked as off-topic.

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/rebase

@jfversluis jfversluis added this to the .NET 9 SR5 milestone Feb 13, 2025
@jfversluis
Copy link
Member

Failing test unrelated

@jfversluis jfversluis merged commit e76b0ee into dotnet:main Feb 13, 2025
102 of 104 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gray Line Appears on the Right Side of GraphicsView with Decimal WidthRequest on iOS Platform
7 participants