KEMBAR78
[iOS] Fixed Invalid Color warning by SubhikshaSf4851 · Pull Request #30876 · dotnet/maui · GitHub
Skip to content

Conversation

SubhikshaSf4851
Copy link
Contributor

@SubhikshaSf4851 SubhikshaSf4851 commented Jul 28, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Root Cause :

Invalid color warning happens when there's a mismatch between the type of pattern and the color space used.

Description of Change

Created the pattern color space with null , which tells Core Graphics it's a colored pattern to avoid the mismatch.

Tested the behavior in the following platforms:

  • Windows
  • Android
  • iOS
  • Mac

Reference

Here is the apple's documentation for Creating patterns https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_patterns/dq_patterns.html

Issues Fixed

Fixes #22891

Screenshot

Before Issue Fix After Issue Fix
Screenshot 2025-07-28 at 5 50 36 PM Screenshot 2025-07-28 at 5 51 57 PM

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Jul 28, 2025
@SubhikshaSf4851 SubhikshaSf4851 changed the title [iOS] Fixed warning Invalid Color [iOS] Fixed Invalid Color warning Jul 28, 2025
_context.SaveState();
var baseColorspace = _getColorspace?.Invoke();
var colorspace = CGColorSpace.CreatePattern(baseColorspace);
var colorspace = CGColorSpace.CreatePattern(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_getColorspace?.Invoke(); This callback is now unused. Is needed elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, _getColorspace?.Invoke() is still needed. It is being used for pattern creation, also used when creating gradients and initializing the drawing context in other parts of the code.

@SubhikshaSf4851 SubhikshaSf4851 marked this pull request as ready for review July 30, 2025 08:09
@Copilot Copilot AI review requested due to automatic review settings July 30, 2025 08:09
@SubhikshaSf4851 SubhikshaSf4851 requested a review from a team as a code owner July 30, 2025 08:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an "Invalid Color warning" in iOS by correcting the color space configuration for pattern colors in the graphics rendering pipeline. The issue was caused by a mismatch between the pattern type and color space used when filling rectangles with patterns.

  • Simplified pattern color space creation by passing null to CGColorSpace.CreatePattern()
  • Removed dependency on base color space retrieval for pattern creation
Comments suppressed due to low confidence (1)

src/Graphics/src/Graphics/Platforms/MaciOS/PlatformCanvas.cs:721

  • This change fixes an iOS-specific graphics warning but lacks corresponding test coverage. Please ensure there are relevant test cases in TestCases.HostApp and TestCases.Shared.Tests that validate pattern filling behavior works correctly without generating warnings.
			var colorspace = CGColorSpace.CreatePattern(null);

@jfversluis jfversluis added this to the .NET 9 SR11 milestone Aug 7, 2025
@jfversluis jfversluis added the area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing label Aug 7, 2025
@jfversluis jfversluis changed the base branch from main to inflight/current August 11, 2025 07:55
@jfversluis jfversluis merged commit c54e49b into dotnet:inflight/current Aug 11, 2025
3 checks passed
github-actions bot pushed a commit that referenced this pull request Aug 11, 2025
github-actions bot pushed a commit that referenced this pull request Aug 15, 2025
github-actions bot pushed a commit that referenced this pull request Aug 15, 2025
github-actions bot pushed a commit that referenced this pull request Aug 19, 2025
github-actions bot pushed a commit that referenced this pull request Aug 22, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 2025
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.

.NET MAUI: There is an "Invalid color" error on iOS when drawing a pattern using the GraphicsView

3 participants