unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
9.03k stars 733 forks source link

Xaml Image not working in Wasm project after update to .net #18823

Open premiaware opened 3 days ago

premiaware commented 3 days ago

Current behavior

I have update my single project solution to .net 9 and uno version 5.5.43, all working ok but the image control not show the image form url

 <Image
     Grid.Row="1"
     Grid.RowSpan="6"
     Grid.Column="0"
     Width="100"
     Height="80"
     HorizontalAlignment="Left"
     ImageFailed="Image_ImageFailed"
     Source="{x:Bind Thumbnail, Mode=OneWay}" />

        public BitmapImage Thumbnail
        {
            get {
                return  new BitmapImage(new System.Uri($"https://kinsta.com/it/wp-content/uploads/sites/2/2021/02/Cos_e_un_url.jpg")); 
                }
        }

this working in Desktop project but not in Wasm project

Expected behavior

No response

How to reproduce it (as minimally and precisely as possible)

No response

Workaround

No response

Works on UWP/WinUI

Yes

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia

NuGet package version(s)

No response

Affected platforms

WebAssembly

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

jeromelaban commented 3 days ago

Thanks for the report! Can you provide a repro sample for your issue?

premiaware commented 3 days ago

UnoApp1.zip

I have attached sample. Work with Desktop project Not work with wasm project.

jeromelaban commented 3 days ago

Thanks for the report.

This is happening because of this:

Failed to load resource: net::ERR_BLOCKED_BY_RESPONSE.NotSameOriginAfterDefaultedToSameOriginByCoep

It looks like the .NET Wasm host is started with COEP enabled, causing the image to not show up. It's likely to be a .NET update, but in the meantime, you can run your app using dotnet run in the command line, the image will appear.

premiaware commented 3 days ago

Ok, for the sample i can run "dotnet run" in my local machine, but for production my Wasm App work in Azure Web Storage, how can fix it?

jeromelaban commented 3 days ago

On the Azure Web Storage, the issue won't be there either. This is specific to the hosting when started from VS 2022.

jeromelaban commented 3 days ago

Here's the related .NET issue: https://github.com/dotnet/runtime/issues/109937