-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Fixed Invalid Color warning #30876
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
Conversation
| _context.SaveState(); | ||
| var baseColorspace = _getColorspace?.Invoke(); | ||
| var colorspace = CGColorSpace.CreatePattern(baseColorspace); | ||
| var colorspace = CGColorSpace.CreatePattern(null); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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);
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