[iOS] Fixed Invalid Color warning#30876
Merged
jfversluis merged 1 commit intodotnet:inflight/currentfrom Aug 11, 2025
Merged
Conversation
jsuarezruiz
suggested changes
Jul 29, 2025
| _context.SaveState(); | ||
| var baseColorspace = _getColorspace?.Invoke(); | ||
| var colorspace = CGColorSpace.CreatePattern(baseColorspace); | ||
| var colorspace = CGColorSpace.CreatePattern(null); |
Contributor
There was a problem hiding this comment.
_getColorspace?.Invoke(); This callback is now unused. Is needed elsewhere?
Contributor
Author
There was a problem hiding this comment.
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.
Contributor
There was a problem hiding this comment.
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
approved these changes
Aug 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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