dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.97k stars 1.71k forks source link

ImageSource does not work with Uri's that have an & in the URI #10746

Open bradyguyc opened 1 year ago

bradyguyc commented 1 year ago

Description

Converting an existing Xamarin project to .NET MAUI. I have a collectionview that has an image in the collection that is binding to images that have the following format.

public string ImageUrlBad2 { get; set; } = "http://books.google.com/books/content?id=ArLbO9YdVMMC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api";

Note the & in the Uri. This works just fine in Xamarin.

Images look like the following screen shot in Xamarin.

image

In .NET MAUI there is black (nothing) where the image should be.


Visual Studio 2022 Developer PowerShell v17.4.0-pre.3.0 Copyright (c) 2022 Microsoft Corporation


PS C:\d\MauiAppImageTest> dotnet workload list

Welcome to .NET 7.0!

SDK Version: 7.0.100-rc.2.22477.23

Telemetry

The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry


Installed an ASP.NET Core HTTPS development certificate. To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). Learn about HTTPS: https://aka.ms/dotnet-https

Write your first app: https://aka.ms/dotnet-hello-world Find out what's new: https://aka.ms/dotnet-whats-new Explore documentation: https://aka.ms/dotnet-docs Report issues and find source on GitHub: https://github.com/dotnet/core Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli

Installed Workload Id Manifest Version Installation Source

maui-windows 7.0.0-rc.1.6683/7.0.100-rc.1 VS 17.4.33006.217 maui-maccatalyst 7.0.0-rc.1.6683/7.0.100-rc.1 VS 17.4.33006.217 maccatalyst 15.4.1029-rc.1/7.0.100-rc.1 VS 17.4.33006.217 maui-ios 7.0.0-rc.1.6683/7.0.100-rc.1 VS 17.4.33006.217 ios 15.4.1029-rc.1/7.0.100-rc.1 VS 17.4.33006.217 maui-android 7.0.0-rc.1.6683/7.0.100-rc.1 VS 17.4.33006.217 android 33.0.0-rc.1.151/7.0.100-rc.1 VS 17.4.33006.217

Use dotnet workload search to find add

Steps to Reproduce

Open attached project. run the project. You can see that no image is displayed where the XMAL has an image with source that contains &. Click on the button at the bottom to try dynamically load the resource same result.

Link to public reproduction project repository

https://github.com/bradyguyc/MauiAppImageTest

Version with bug

7.0 Release Candidate 2

Last version that worked well

7.0 Release Candidate 1

Affected platforms

Android

Affected platform versions

Andriod 12.1 API 32

Did you find any workaround?

no

Relevant log output

[Glide] Load failed for http://books.google.com/books/content?id=ArLbO9YdVMMC&printsec=frontcover&img=1&zoom=5&edge=curl&source=gbs_api with size [915x978]
[Glide] class com.bumptech.glide.load.engine.GlideException: Failed to load resource
[Glide] There was 1 root cause:
[Glide] com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1)
[Glide]  call GlideException#logRootCauses(String) for more detail
[Glide]   Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE
[Glide] There was 1 root cause:
[Glide] com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1)
[Glide]  call GlideException#logRootCauses(String) for more detail
[Glide]     Cause (1 of 1): class com.bumptech.glide.load.HttpException: Failed to connect or obtain data, status code: -1
[Glide]   Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{StringUri->Object->Drawable}, LOCAL
[Glide]     Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{StringUri->Drawable->Drawable}
[Glide]     Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{StringUri->Bitmap->BitmapDrawable}
[Glide] Root cause (1 of 1)
[Glide] com.bumptech.glide.load.HttpException: Failed to connect or obtain data, status code: -1
[Glide]     at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:98)
[Glide]     at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:58)
[Glide]     at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:95)
[Glide]     at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:88)
[Glide]     at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311)
[Glide]     at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280)
[Glide]     at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235)
[Glide]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
[Glide]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
[Glide]     at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:413)
[Glide]     at java.lang.Thread.run(Thread.java:920)
[Glide]     at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultPriorityThreadFactory$1.run(GlideExecutor.java:372)
[Glide] Caused by: java.io.IOException: Cleartext HTTP traffic to books.google.com not permitted
[Glide]     at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:127)
[Glide]     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:462)
[Glide]     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
[Glide]     at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:93)
[Glide]     ... 11 more
[Glide] Load failed for crc6488302ad6e9e4df1a.ImageLoaderCallback@7398419 with size [915x978]
ghost commented 1 year ago

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.

GalaxiaGuy commented 1 year ago

This may not line up well with the idea that it works in Xamarin, or in Maui 7.0 RC1, but the following seems important:

Caused by: java.io.IOException: Cleartext HTTP traffic to books.google.com not permitted

See: https://nphau.medium.com/android-8-cleartext-http-traffic-not-permitted-73c1c9e3b803

Phantom-KNA commented 1 year ago

The same error, just now created project in MAUI. Caused by: java.io.IOException: Cleartext HTTP traffic to image.tmdb.org not permitted Any suggestion, i proved every config in this topic:https://nphau.medium.com/android-8-cleartext-http-traffic-not-permitted-73c1c9e3b803

Phantom-KNA commented 1 year ago

Well nothing, clean and rebuid the project right now out this error: [NetworkSecurityConfig] No Network Security Config specified, using platform default [Glide] Load failed for https://image.tmdb.org/t/p/w500/rcICfiL9fvwRjoWHxW8QeroLYrJ.jpg with size [1080x2328] [Glide] class com.bumptech.glide.load.engine.GlideException: Failed to load resource [Glide] There was 1 root cause: [Glide] com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1) [Glide] call GlideException#logRootCauses(String) for more detail [Glide] Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE [Glide] There was 1 root cause: [Glide] com.bumptech.glide.load.HttpException(Failed to connect or obtain data, status code: -1) [Glide] call GlideException#logRootCauses(String) for more detail [Glide] Cause (1 of 1): class com.bumptech.glide.load.HttpException: Failed to connect or obtain data, status code: -1 [Glide] Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{StringUri->Object->Drawable}, LOCAL [Glide] Cause (1 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{StringUri->Drawable->Drawable} [Glide] Cause (2 of 2): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{StringUri->Bitmap->Drawable} [Glide] Root cause (1 of 1) [Glide] com.bumptech.glide.load.HttpException: Failed to connect or obtain data, status code: -1 [Glide] at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:98) [Glide] at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:58) [Glide] at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:70) [Glide] at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:63) [Glide] at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:311) [Glide] at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:280) [Glide] at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:235) [Glide] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) [Glide] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) [Glide] at java.lang.Thread.run(Thread.java:761) [Glide] at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:393) [Glide] Caused by: java.net.ConnectException: Connection refused [Glide] at java.net.PlainSocketImpl.socketConnect(Native Method) [Glide] at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:334) [Glide] at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:196) [Glide] at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) [Glide] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356) [Glide] at java.net.Socket.connect(Socket.java:605) [Glide] at com.android.okhttp.internal.Platform.connectSocket(Platform.java:113) [Glide] at com.android.okhttp.Connection.connectSocket(Connection.java:196) [Glide] at com.android.okhttp.Connection.connect(Connection.java:172) [Glide] at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367) [Glide] at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130) [Glide] at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329) [Glide] at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246) [Glide] at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457) [Glide] at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126) [Glide] at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89) [Glide] at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java) [Glide] at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:93) [Glide] ... 10 more

Now is: [Glide] Caused by: java.net.ConnectException: Connection refused

Phantom-KNA commented 1 year ago

Well in this case i be used VPN, the problem fix.

Zhanglirong-Winnie commented 1 year ago

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on android platform with sample project. MauiAppImageTest-master.zip Screenshot 2023-07-13 174944

bradyguyc commented 1 year ago

thanks for providing the rebo and confirming the issue!