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.98k stars 1.71k forks source link

[iOS, MAC] Image not loading from stream or URI binding source #15871

Open karthikraja-arumugam opened 1 year ago

karthikraja-arumugam commented 1 year ago

Description

In image control, if we bind stream or URI image source, it does not load into the view upon initial loading. However, if any layout changes occur, the image loads correctly.

Steps to Reproduce

iOS

  1. Run the attached sample in iOS.
  2. Note that the image is not displayed in the view
  3. Change mobile or simulator orientation, now the image will be visible.

MAC

  1. Set the proper local image in ViewModel.

    Screenshot 2023-06-27 at 1 16 01 PM
  2. Run the sample on Mac and repeat the steps, you will get the same result as iOS.

ImageBindingSample.zip

Link to public reproduction project repository

https://github.com/KarthikRajaAKR/Samples/tree/main/ImageBindingSample

Version with bug

7.0.49

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

MacOS Ventura v13.0.1, iOS 14

Did you find any workaround?

No

Relevant log output

No response

ghost commented 1 year ago

Hi @karthikraja-arumugam. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

karthikraja-arumugam commented 1 year ago

I've checked in the latest version too, still facing the same issue.

jfversluis commented 1 year ago

@karthikraja-arumugam could you specify what you mean with "latest version"?

ghost commented 1 year ago

Hi @karthikraja-arumugam. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

karthikraja-arumugam commented 1 year ago

@jfversluis, I'm facing this issue with version 7.0.86. Please check the video.

https://github.com/dotnet/maui/assets/92788387/bda086b4-0a12-4412-8421-099e21562f75

ghost commented 1 year ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

nurNedimOkatan commented 1 year ago

I have also came across same problem.

<Image Source="{Binding SVImageSource}"/>
SVImageSource = ImageSource.FromStream(() => response);

As @karthikraja-arumugam showed, image is not visible initially but when screen orientation changes, image shows up.

nurNedimOkatan commented 1 year ago

@jfversluis Is there any suggested workaround on this one?

crwsolutions commented 9 months ago

I have this same behavior, but I think in my case it is caused by the fact that the Source url is answered with a 301 Moved. However I do not know how I can make this image control follow the redirect on iOs like it is doing on android. Help is welcome.

crwsolutions commented 7 months ago

I think in my case it is caused by the fact that the Source url is answered with a 301 Moved.

I solved my problem. I think it was not entirely the same as described. The redirect was from an ip adres to a domain both without ssl. This was solved by adding

<key>NSAppTransportSecurity</key> etc... in the iOs plist. More on this can be found here.

Uridel commented 2 days ago

I am facing the same issue for my project. Has someone managed to find a workaround?

RobK410 commented 9 hours ago

I am getting this error simply by binding a Uri to the Source of an Image in a CollectionView. NSAppTransportSecurity does not help, as this Url is https:// but also, hosted on a valid AWS CDN that returns the image in any browser on/off the device. Works on Android, so it is IOS platform specific issue.

Microsoft.Maui.Controls.UriImageSource: Warning: Error getting stream for https://d39bv8qyr14eas.cloudfront.net/b7106340-29f1-4476-b545-9ed29ce42582/ea48232b-68de-4677-a810-4fbf83ae670a.png

System.TimeoutException: The request timed out.
 ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at System.Net.Http.NSUrlSessionHandler.NSUrlSessionDataTaskStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSUrlSessionHandler.cs:line 1377
   --- End of inner exception stack trace ---
   at System.Net.Http.NSUrlSessionHandler.NSUrlSessionDataTaskStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSUrlSessionHandler.cs:line 1381
   at System.IO.Stream.<CopyToAsync>g__Core|27_0(Stream source, Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
   at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at Microsoft.Maui.Controls.StreamWrapper.GetStreamAsync(Uri uri, CancellationToken cancellationToken, HttpClient client)
   at Microsoft.Maui.Controls.UriImageSource.DownloadStreamAsync(Uri uri, CancellationToken cancellationToken)
[19:16:24 WRN] Error getting stream for "https://d39bv8qyr14eas.cloudfront.net/b7106340-29f1-4476-b545-9ed29ce42582/ea48232b-68de-4677-a810-4fbf83ae670a.png"
System.TimeoutException: The request timed out.
 ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at System.Net.Http.NSUrlSessionHandler.NSUrlSessionDataTaskStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSUrlSessionHandler.cs:line 1377
   --- End of inner exception stack trace ---
   at System.Net.Http.NSUrlSessionHandler.NSUrlSessionDataTaskStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSUrlSessionHandler.cs:line 1381
   at System.IO.Stream.<CopyToAsync>g__Core|27_0(Stream source, Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
   at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at Microsoft.Maui.Controls.StreamWrapper.GetStreamAsync(Uri uri, CancellationToken cancellationToken, HttpClient client)
   at Microsoft.Maui.Controls.UriImageSource.DownloadStreamAsync(Uri uri, CancellationToken cancellationToken)