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

Window glitches when dragging app between monitors with different scaling #11777

Closed
Felicity-R opened this issue Dec 1, 2022 · 12 comments · Fixed by #16637
Closed

Window glitches when dragging app between monitors with different scaling #11777

Felicity-R opened this issue Dec 1, 2022 · 12 comments · Fixed by #16637
Labels
area-controls-window Window fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 platform/windows 🪟 t/bug Something isn't working t/desktop The issue relates to desktop scenarios (MacOS/MacCatalyst/Windows/WinUI/WinAppSDK)
Milestone

Comments

@Felicity-R
Copy link

Description

Dragging a Maui app between different monitor causes visual glitches and eventually stops responding. See attached video to see what I mean: screen-capture.webm. In the video I'm just recording my 2nd monitor; the laptop screen is below it so that's where the app is when I drag it off screen below. In the end I need to ctrl+alt+delete to get to the task manager and force close it because everything stops responding.

Steps to Reproduce

  1. Have a dual-monitor setup
  2. Set custom scaling on monitor in the display settings. e.g. I have my laptop scaling set to 125% and a secondary monitor with scaling at 100%. (If I change the laptop to also be 100% scaling then the bug does not occur).
    image
  3. Create a new app from the .Net MAUI App template (using .Net7)
  4. Launch the app
  5. Drag the app from one monitor to the other. If it's still behaving normally, drag it back.

Expected results:
You can freely move the app around and it will work fine.

Actual results:
After moving from one monitor to the other a few times, it will break. Sometimes the app window flashes around wildly, sometimes just the edge of the window twitches - see video in description.

Link to public reproduction project repository

Can repro in the Maui template app

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows 10 19043.2251

Did you find any workaround?

Don't use different scaling

Relevant log output

No response

@Felicity-R Felicity-R added the t/bug Something isn't working label Dec 1, 2022
@drasticactions
Copy link
Contributor

If you try this in a WinUI application without MAUI, what happens?

@mattleibow mattleibow added this to the Backlog milestone Dec 1, 2022
@ghost
Copy link

ghost commented Dec 1, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@Felicity-R
Copy link
Author

Felicity-R commented Dec 1, 2022

Good question. I tried with a new app from the "Blank App, Packaged (WinUI 3 in Desktop)" template, changed it to .net7 to match the Maui project and was not able to reproduce the issue there. I also tried adding a ScrollViewer and some TextBoxes there and still no repro.
Then I pared down the Maui app, removing all the controls from the main page so it was just a blank page, and the Maui app still had the issue.

@DerPate2010
Copy link

I see the same behavior on my machine. One display is at 200% and a second one at 150%. I see different kinds of flickering effects and the content seems to toggle between both DPI settings (= sizes).

Based on the behavior my assumption is, that the MAUI window is doing some resizing strategy before the user releases the mouse cursor on the second screen

  1. It seems as if the window is being resized as a reaction to the message from Windows when moving to the second screen.
  2. As a result of the resizing the main part of the smaller window is now back on the first screen. =>
  3. Windows is sending a message to scale to this size.
  4. Maui rescales to the larger window and the main part of the window is on the second screen again =>
  5. goto 1

When I break the execution I always see stack trace like this:

image

@Eilon Eilon added the legacy-area-desktop Windows / WinUI / Project Reunion & Mac Catalyst / macOS specifics (Menus & other Controls)) label Dec 21, 2022
@jerry-synap
Copy link

jerry-synap commented Feb 17, 2023

I have the same issue with Maui Blazor App. One monitor is at 125% and the other is at 100%. When I drag the Maui app from the 125% monitor to the 100%, it gets stuck halfway, flickering as if re-rendering but the app itself is unresponsive and has to be killed off. On the other hand, if I drag from 100% to 125% the problem does not show up. As long as the app starts in a 100% scaling monitor it seems okay to be dragged afterward but not if it starts up in a 125% scaled monitor. You cannot drag back from 125% to 100%.

@drasticactions drasticactions added the s/verified Verified / Reproducible Issue ready for Engineering Triage label Feb 17, 2023
@LFXA
Copy link

LFXA commented Apr 4, 2023

I have the same issue with Maui Blazor App. any update?

@samhouts samhouts removed the s/verified Verified / Reproducible Issue ready for Engineering Triage label Apr 5, 2023
@drasticactions
Copy link
Contributor

#14597 (comment)

This mentions the possible issue. Calculating the Width, Height, X, and Y could be causing it to redraw and freak out.

@salarcode
Copy link
Contributor

salarcode commented Apr 17, 2023

Addition to my comment #14597 (comment)
If I add this line to the method, we can see that this FrameChanged method is in a hot path

if (_batchFrameUpdate > 0)
{
	Debug.WriteLine($"_batchFrameUpdate={_batchFrameUpdate}, frame={frame}");
}

Like this:
image

I will get this when I move MAUI window from a monitor with 150% scaling to another one with 100% scaling:

_batchFrameUpdate=1, frame={X=-279 Y=160 Width=797 Height=1211}
_batchFrameUpdate=2, frame={X=-279 Y=160 Width=797 Height=807}
_batchFrameUpdate=2, frame={X=-186 Y=106.66666412353516 Width=797.3333129882812 Height=1210.6666259765625}
_batchFrameUpdate=3, frame={X=-186 Y=160 Width=797.3333129882812 Height=1210.6666259765625}
_batchFrameUpdate=1, frame={X=-519 Y=151 Width=797 Height=1211}
_batchFrameUpdate=2, frame={X=-519 Y=151 Width=797 Height=807}
_batchFrameUpdate=2, frame={X=-519 Y=151 Width=797 Height=1211}
_batchFrameUpdate=1, frame={X=-519 Y=151 Width=531 Height=1211}
_batchFrameUpdate=1, frame={X=-519 Y=151 Width=531 Height=807}

It seems to me that updating bindable properties in such hot path is not a good idea.

.

@salarcode
Copy link
Contributor

X = frame.X;
Y = frame.Y;
Width = frame.Width;
Height = frame.Height;

These lines are causing performance regression imo

image

@jonathanpeppers pinging for help

@jonathanpeppers
Copy link
Member

jonathanpeppers commented Apr 20, 2023

The picture of a stack trace above shows this is called:

public static void UpdatePosition(this UI.Xaml.Window platformWindow, IWindow window)

Hoping this was profiled in Release mode, but can you share your profiler data here?

So, is this what is happening?

  1. User drags window
  2. Windows APIs -> tells MAUI the position changed
  3. MAUI OnPropertyChanged() -> calls Windows API to update position
  4. Repeat in a loop?

These lines are causing performance regression imo

Regression from what? .NET 6?

@salarcode
Copy link
Contributor

Unfortunately i didn't save that file, wasn't expecting it be needed. And yes it was in Release mode.

Here is another run I did in Release mode.
What I did is just run Maui.Controls.Sample and move the window between two monitors with different scaling as I've mentioned before.
At the end I managed to glitch the app and it was stuck and unresponsive like this :

Maui.Controls.Sample_Xl8BmnifAD.mp4

Here is the profile session for above :

Report20230421-0905.zip

Regression from what? .NET 6?

I think based on #4942 yes.

@rmarinho
Copy link
Member

rmarinho commented Aug 4, 2023

Sorry but we have to revert the PR that fixes this issue. We are working in improving the related fix to be merged on main.
Thanks.

@github-project-automation github-project-automation bot moved this from Todo to Done in MAUI SDK Ongoing Aug 11, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 10, 2023
@samhouts samhouts added the fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 label Sep 12, 2023
@Eilon Eilon added t/desktop The issue relates to desktop scenarios (MacOS/MacCatalyst/Windows/WinUI/WinAppSDK) and removed legacy-area-desktop Windows / WinUI / Project Reunion & Mac Catalyst / macOS specifics (Menus & other Controls)) labels May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-window Window fixed-in-8.0.0-rc.1.9171 Look for this fix in 8.0.0-rc.1.9171 platform/windows 🪟 t/bug Something isn't working t/desktop The issue relates to desktop scenarios (MacOS/MacCatalyst/Windows/WinUI/WinAppSDK)
Projects
None yet
Development

Successfully merging a pull request may close this issue.