-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] GraphicsView scaling after canvas.ResetState - fix #31183
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
|
Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
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 Android-specific issue where GraphicsView would draw at half the expected size after calling canvas.ResetState(). The fix involves preserving the initial display scale factor in ScalingCanvas and restoring it properly during state reset operations.
- Modifies
ScalingCanvasto store and restore initial scale values instead of resetting to 1.0 - Updates
PlatformGraphicsViewon Android to pass the display density scale toScalingCanvas - Adds UI tests to verify the fix works correctly
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
ScalingCanvas.cs |
Adds initial scale tracking and new constructor; modifies ResetState/RestoreState to preserve initial scale |
PlatformGraphicsView.cs |
Updates ScalingCanvas instantiation to pass display density scale |
Issue31182.cs (test) |
Adds NUnit test to verify GraphicsView draws at correct size after ResetState |
Issue31182.cs (hostapp) |
Adds test UI page demonstrating the ResetState scaling issue |
| _blurrableCanvas = _canvas as IBlurrableCanvas; | ||
| } | ||
|
|
||
| internal ScalingCanvas(ICanvas wrapped, float scale) |
Copilot
AI
Aug 15, 2025
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.
Adding a new constructor to a public class like ScalingCanvas represents a potential breaking change to the public API. Since this is marked as 'internal', it may be acceptable, but please ensure this change is reviewed for API compatibility if ScalingCanvas is part of the public surface area.
Copilot uses AI. Check for mistakes.
| { | ||
| _canvas = wrapped; | ||
| _blurrableCanvas = _canvas as IBlurrableCanvas; | ||
| _initialScaleX = scale; |
Copilot
AI
Aug 15, 2025
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.
[nitpick] The new constructor assumes uniform scaling by setting both X and Y scales to the same value. Consider adding an overload that accepts separate X and Y scale values for more flexibility, or document this limitation.
Copilot uses AI. Check for mistakes.
Addresses issue dotnet#31182 where GraphicsView would draw at half size after calling canvas.ResetState() on Android. ScalingCanvas now preserves the initial scale and restores it after ResetState and RestoreState. Added related test cases to verify correct drawing behavior.
|
/azp run |
|
@softlion would you be able to test this out and let us know? :) |
|
Azure Pipelines successfully started running 3 pipeline(s). |
02e46cb to
784722d
Compare
Addresses issue #31182 where GraphicsView would draw at half size after calling canvas.ResetState() on Android. ScalingCanvas now preserves the initial scale and restores it after ResetState and RestoreState. Added related test cases to verify correct drawing behavior.
Addresses issue #31182 where GraphicsView would draw at half size after calling canvas.ResetState() on Android. ScalingCanvas now preserves the initial scale and restores it after ResetState and RestoreState. Added related test cases to verify correct drawing behavior.
Addresses issue #31182 where GraphicsView would draw at half size after calling canvas.ResetState() on Android. ScalingCanvas now preserves the initial scale and restores it after ResetState and RestoreState. Added related test cases to verify correct drawing behavior.
REVERTED THIS PR
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!
Description of Change
Addresses issue #31182 where GraphicsView would draw at half size after calling canvas.ResetState() on Android. ScalingCanvas now preserves the initial scale and restores it after ResetState and RestoreState. Added related test cases to verify correct drawing behavior.
Issues Fixed
Fixes #31182