maui icon indicating copy to clipboard operation
maui copied to clipboard

[Mac Catalyst] DeviceDisplay.MainDisplayInfo is not refreshed

Open mikeparker104 opened this issue 9 months ago • 1 comments

Description

The information (DisplayInfo) returned by DeviceDisplay.MainDisplayInfo does not get refreshed on macOS after changing display options (in Settings > Displays) like resolution, scaling, rotation, etc., or when switching the display that is designated as the Main display. Potentially related to https://github.com/dotnet/maui/issues/22634.

For comparison, on Windows the expected DisplayInfo is returned reflecting changes to system display configuration. Expectation is that the macOS version behaves consistently with the Windows version.

Steps to Reproduce

Create a file -> new .NET MAUI app. In MainPage.xaml.cs, paste the ReadDeviceDisplay method from the Main display info documentation modifying to output to the console instead of the DisplayDetailsLabel used in that example. Then, update the templated Button click event handler to call the ReadDeviceDisplay function.

void ReadDeviceDisplay()
{
    System.Text.StringBuilder sb = new System.Text.StringBuilder();

    sb.AppendLine($"Pixel width: {DeviceDisplay.Current.MainDisplayInfo.Width} / Pixel Height: {DeviceDisplay.Current.MainDisplayInfo.Height}");
    sb.AppendLine($"Density: {DeviceDisplay.Current.MainDisplayInfo.Density}");
    sb.AppendLine($"Orientation: {DeviceDisplay.Current.MainDisplayInfo.Orientation}");
    sb.AppendLine($"Rotation: {DeviceDisplay.Current.MainDisplayInfo.Rotation}");
    sb.AppendLine($"Refresh Rate: {DeviceDisplay.Current.MainDisplayInfo.RefreshRate}");

    System.Diagnostics.Debug.WriteLine(sb.ToString());
}

Using screen resolution as the example of a change to display information expected to be reflected in the DisplayInfo.

  1. Run the .NET MAUI app on macOS
  2. Click the templated Button to output the Main display info
  3. Open the Settings app and change the screen resolution for the designated Main display
  4. Click the templated Button to output the Main display info

EXPECTED

The (DisplayInfo) output the second time around is different to the first. In this case, showing different height and width values.

ACTUAL

The (DisplayInfo) outputs remain the same.

Link to public reproduction project repository

No response

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

Mac Catalyst 13.1

Did you find any workaround?

No response

Relevant log output

No response

mikeparker104 avatar May 24 '24 13:05 mikeparker104