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

SurfaceLoader fails in WinUI because of unsupported API usage #316

Open
4 of 24 tasks
Marv51 opened this issue Jan 12, 2024 · 1 comment
Open
4 of 24 tasks

SurfaceLoader fails in WinUI because of unsupported API usage #316

Marv51 opened this issue Jan 12, 2024 · 1 comment

Comments

@Marv51
Copy link

Marv51 commented Jan 12, 2024

Describe the bug

In the latest Toolkit from Jan 24 (8.0.240109), SurfaceLoader fails to create a brush, and it will always return null on WinUI 3.

This is because the private SurfaceLoader.LoadSurfaceBrushAsync method unconditionally calls DisplayInformation.GetForCurrentView().

var displayInformation = DisplayInformation.GetForCurrentView();
This is not supported on WinUI 3 and throws a COMException. This exception gets handled, but an empty/null brush will always be returned.

Steps to reproduce

// The Uri does not matter, it throws before loading anything.
_ = await SurfaceLoader.LoadImageAsync(new Uri("https://example.com"), CommunityToolkit.WinUI.Media.DpiMode.DisplayDpiWith96AsLowerBound);

// The exception is handled so it will return `null`.

Expected behavior

No exception is expected.

The old-7.1 winUI branch worked for me. On that branch this dpi issue was commented out:

https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/080bdb99e6810eb2157ad635f00e64a64acabb50/CommunityToolkit.WinUI.UI.Media/Helpers/SurfaceLoader.cs#L99

Screenshots

No response

Code Platform

  • UWP
  • WinAppSDK / WinUI 3
  • Web Assembly (WASM)
  • Android
  • iOS
  • MacOS
  • Linux / GTK

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 10 21H2 (Build 19044)
  • Windows 10 22H2 (Build 19045)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Windows 10, version 2104 (Build 20348)
  • Windows 11, version 22H2 (Build 22000)
  • Other (specify)

Other SDK version

No response

Visual Studio Version

2022

Visual Studio Build Number

No response

Device form factor

No response

Additional context

It might be tempting to think that this is the same issue as #233, however it is not. This is about 10 lines further into SurfaceLoader and this wasn't fixed by #299 in the latest update.

Help us help you

No, I'm unable to contribute a solution.

@Marv51
Copy link
Author

Marv51 commented Jun 24, 2024

Should I submit a PR with the old 7.x "fix" of commenting out the DPI references?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant