Skip to content
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

ScrollViewer / Scroller doesn't re-rasterize the content after a zoom #541

Closed
micahl opened this issue Apr 9, 2019 · 15 comments · Fixed by #669 or #882
Closed

ScrollViewer / Scroller doesn't re-rasterize the content after a zoom #541

micahl opened this issue Apr 9, 2019 · 15 comments · Fixed by #669 or #882
Assignees
Labels
Milestone

Comments

@micahl
Copy link
Contributor

micahl commented Apr 9, 2019

Describe the bug

ScrollViewer/Scroller doesn't re-rasterize the content after a zoom

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Use the Microsoft.UI.Xaml.Controls.ScrollViewer control to display some zoomable content that contains text (e.g. TextBlocks)
  2. Set ZoomMode="Enabled"
  3. Zoom in/out
  4. The text isn't re-rendered after the zoom and remains fuzzy

Expected behavior

The content may appear fuzzy while a zoom is in progress, but it should re-rasterize when the zoom completes.

Version Info

NuGet package version:

2.1.190319001-prerelease

Windows 10 version Saw the problem?
October 2018 Update (17763) Yes
Device form factor Saw the problem?
Desktop Yes

Additional context

@adrientetar
Copy link

@jevansaks, is this bug on the team's radar? So far I've been changing the DpiScale of my scrolled control according to the ZoomFactor of the Scroller but it seems DpiScale doesn't work well with values greater than 10 for instance... what would be the right thing to do here, resize the scrolled control?

@jevansaks
Copy link
Member

I believe @RBrid is working his way through these issues, so I'll let him comment.

@micahl
Copy link
Contributor Author

micahl commented May 1, 2019

@adrientetar, what do you see happening at scale factors larger than 10? And, the DpiScale you're referring to is the property on the Win2D CanvasControl, right?

@adrientetar
Copy link

@micahl Yes, I use CanvasVirtualControl. There's a value out of range traceback with value greater than 10 dot something iirc, here I got 12 by scrolling in with the touchpad (does not repro consistently I think).

image

For now I clamp to 10 but I'm wondering what the right thing to do is here.

@micahl
Copy link
Contributor Author

micahl commented May 2, 2019

Hmm... we looked into this issue a little while back to understand why the Scroller wasn't re-rasterizing content after a zoom. IIRC, the way we're hooking up the content's Scale property to the output of the InteractionTracker.Scale causes it to be treated as a long-running animation that runs independent and we'd need to stop/start it again during Idle to trigger the re-rasterization.

I haven't played enough with CanvasVirtualControl to know its behavior, but perhaps once this bug is fixed then it will render correctly without needing to set a DpiScale?

@shawnhar are there limitations with zooming and CanvasVirtualControl? The InteractionTracker-based Scroller in WinUI doesn't have the min/max zoom factor limits that the old ScrollViewer control has. Will that be problematic with CanvasVirtualControl?

@shawnhar
Copy link
Member

shawnhar commented May 2, 2019

CanvasVirtualControl doesn't have any specific limits of its own beyond the underlying DComp virtual surface image source max size (which is what it wraps). Certainly nothing as small as a 10x limit.

It's important to keep control of rasterization DPI + zoom factors, though, as bad combinations of these can easily exceed DComp limits on how many tiles can be visible at one time. If you're re-rasterizing in the middle of a zoom without adjusting these ratios, it's surprising how fast changes in zoom amount can end up requesting Win2D to rasterize gigabytes worth of image data (which is never going to work).

@micahl
Copy link
Contributor Author

micahl commented May 2, 2019

@adrientetar, try reducing the height/width being set on the CanvasVirtualControl. Sounds like you may also want to wait to invalidate the canvas until the scroller state hits idle. Take a look at the StateChanged event.

@micahl
Copy link
Contributor Author

micahl commented May 8, 2019

After further investigation we found that the change to enable the correct behavior on RS4 (1803) and earlier releases isn't a change in the scroller control, but rather would require a change in the framework's rendering logic. We've fixed it for RS5+. Until we finish decoupling the framework from the OS (detailed announced in the //build 2019 talk on the State of the Union: The Windows Presentation Platform talk), we'll have this limitation on releases prior to RS5.

@RBrid RBrid added this to the WinUI 2.2 milestone May 9, 2019
@msft-github-bot
Copy link
Collaborator

🎉This issue was addressed in #669, which has now been successfully released as Microsoft.UI.Xaml v2.2.190611001.:tada:

Handy links:

@adrientetar
Copy link

@micahl So I just tried this in the new prerelease. Now the Scroller does rasterize on its own, but I see white flashes at regular intervals when I zoom in/out, which I didn't have before.

@jevansaks
Copy link
Member

@adrientetar thanks for bringing this up. I'll reopen and let Regis investigate. What OS version are you running on? 1809 or 1903?

@jevansaks jevansaks reopened this Jun 11, 2019
@adrientetar
Copy link

@jevansaks, 1903. Here's a video of what I'm seeing, my only change was removing the call to Invalidate() the canvas on ViewChanged.

RBrid added a commit that referenced this issue Jun 24, 2019
…882)

* Fixing Scroller.Content flicker during rasterization for Issue#541.

* A few more renames.
@msft-github-bot
Copy link
Collaborator

🎉This issue was addressed in #882, which has now been successfully released as Microsoft.UI.Xaml v2.2.190702001-prerelease.:tada:

Handy links:

@adrientetar
Copy link

Okay I just tried 2.2.190702001-prerelease, it's better than before (no flashes now) but with the zoom inertia it can take a couple seconds after I stop zooming with my touchpad before it redraws... I'll probably disable inertia altogether but perhaps there's room for improvement there? I can provide a video if it helps.

@RBrid
Copy link
Contributor

RBrid commented Jul 2, 2019

Hello @adrientetar, le Parisien. Thanks for checking my changes & for your feedback. At the moment, I can't think of a way around this because whether in inertia or driven by input, the Scroller can't re-rasterize in the middle of the ongoing manipulation without a major visual glitch. I will keep this unfortunate experience in mind in case a better approach surfaces.

Merci.
-Régis, un Strasbourgeois.

@jevansaks jevansaks added the team-Controls Issue for the Controls team label Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment