Skip to content

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

Merged
jfversluis merged 10 commits into
dotnet:mainfrom
devanathan-vaithiyanathan:fix-25502
Feb 13, 2025
Merged

jfversluis merged 10 commits into
dotnet:mainfrom
devanathan-vaithiyanathan:fix-25502

Conversation

@devanathan-vaithiyanathan

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

Copy link
Copy Markdown
Contributor

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


@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Dec 4, 2024
@dotnet-policy-service

Copy link
Copy Markdown
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

kubaflo commented Dec 4, 2024

Copy link
Copy Markdown
Contributor

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
Comment thread src/Core/src/Handlers/GraphicsView/GraphicsViewHandler.Windows.cs Outdated
@devanathan-vaithiyanathan

devanathan-vaithiyanathan commented Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

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

jfversluis commented Dec 12, 2024

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

This comment was marked as off-topic.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz

Copy link
Copy Markdown
Contributor

/rebase

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

Copy link
Copy Markdown
Member

Failing test unrelated

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