-
Notifications
You must be signed in to change notification settings - Fork 1.9k
ImageLoaderSourceHandler: Could not retrieve image or image data was invalid: Uri #7751
Comments
@developer9969 we recently fixed an issue with this that should be in the release you mentioned I tested that sample on an Samsung S9 (API 28) and API 25 Simulator and in both cases it worked for me Can you make sure the device has internet connectivity? Can you try updating to the latest 4.3 pre? or try the latest nightly builds? https://github.com/xamarin/Xamarin.Forms/wiki/Nightly-Builds |
@PureWeen thanks for your prompt reply. just tried now on emulator.Will try on device as soon as get home, but at work I tried on s9 and sony and did not work. Does work in iOS emulator and device. Tried latest xamarin and prerelease 4.3 and nothing.. I get the following ,below is just a section. Thread started: #4 |
same problem here |
@ddo88 @developer9969 I realize this one is as simple as downloaded that sample :-) But can you zip up your projects anyway and attach just so I can verify |
@ddo88 @developer9969 can you also
|
@PureWeen Hi good news! I have done a factory reset on the simulator device and works with the latest stable. I cannot try the device as I need to be connected to the machine at work. Now I will have the issue of how to build using the android 28.0.0.3 on those azure pipelines all those agents are outdated and crashes the build. grrr. |
Nightly build not working for me either |
same issue here using xamarin.forms 4.2.0.778463, but with the latest version of xamarin forms 4.2.0.815419 and android support 28.0.0.3, it's working fine |
@PureWeen Hello, Shane! |
For anyone else running into this issue can you try any of the following
|
I'm having this issue as well. I upgraded from XF4.1 to 4.2 latest and got "System.ArgumentException: An element with the same key already exists in NameScope Parameter name: name" on various forms. Downgrading to XF4.1 solved that issue, but I couldn't get rid of the image problem. |
With 4.1.0.673156 I get this with VS2019, 16.3.1: 10-04 20:53:28.492 D/skia (12559): --- SkAndroidCodec::NewFromStream returned null Of course the url was not ****, but a valid url which has access to a jpeg image. With 4.1.778454 I get the stream closed exception. With 4.2.848062 I also get no picture. When I do a direct HttpClient.Get in that same Xamarin Page, the picture will be downloaded properly. It just doesn't work via XAML markup. I'm stuck because of the other NameScope issue as well. |
I see that the Android GetStreamAsync in https://github.com/xamarin/Xamarin.Forms/blob/151bdb5ebfd0cfbcad0aa10d6327ff79e534fda5/Xamarin.Forms.Platform.Android/Forms.cs is newing up an HttpClient for every image: public async Task<Stream> GetStreamAsync(Uri uri, CancellationToken cancellationToken)
{
using (var client = new HttpClient())
{
HttpResponseMessage response = await client.GetAsync(uri, cancellationToken).ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
{
Internals.Log.Warning("HTTP Request", $"Could not retrieve {uri}, status code {response.StatusCode}");
return null;
}
// the HttpResponseMessage needs to be disposed of after the calling code is done with the stream
// otherwise the stream may get disposed before the caller can use it
return new StreamWrapper(await response.Content.ReadAsStreamAsync().ConfigureAwait(false), response);
}
} As far as I know disposing HttpClient results in unreliable behavior. See also https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests. |
I did uninstall the app, uninstalled the runtime as well. No luck. |
Workaround that @REDECODE suggested to use Visual Studio 2017 worked for me. Hours and hours wasted on this and it is not feasible for me to upgrade to Xamarin Forms 4 to get this bug fix as I am on Xamarin Forms 3.6.0.639721. Would be nice for this to get fixed in Xamarin Forms 3.6 and VS 2019. |
Why?
Are you on the latest version of VS 2019? I was thinking they fixed this in the latest release of Mono |
Why? Because I have a bunch of dependencies on NuGet packages that have not been upgraded to support Forms 4 and the client isn't going to pay me to rip out Forms 3, replace it with Forms 4, and find alternates to those packages that work with 4. Plus there is no reason that this shouldn't work in Forms 3. Not Forms 3 it old and unsupported. I am on 16.3.7 and it looks like .10 is out. I'll try updating. Thanks. |
What packages? We don't really use semantic versioning. The 3 to 4 doesn't really mean that it's breaking and all related packages have to also be on 4. For the most part any packages you have compiled for 3 should work for 4. If just updating to the latest XF 4 totally breaks your application then I would be curious as to why because it might be something we need to fix. Ideally your upgrade from v3 to v4 should be seamless |
The bug is presented only for some image URLs:
[Error]: https://via.placeholder.com/200.png?text=hello_world
The error text is:
The demo XFIMAG.zip |
Did this open? This photo is not a problem Both are https https://forums.xamarin.com/discussion/comment/411510#Comment_411510 |
I am in trouble to load images. I think is firewall or other thing in the remote server. it is blocking the connection... |
Goto Android Project, then click on properties, https://forums.xamarin.com/discussion/164771/cleartext-http-traffic-not-permitted |
thank you very very very much !! simple solution... work for me!! |
Thanks, this fixes it for HTTPS sites, however HTTPS still seems problematic, and there appears to be no way to ignore an invalid certificate. |
Description
Image does not load
It was allegedly fixed in
#5172 7248
but latest comment there
Steps to Reproduce
Download project from
https://docs.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/workingwithimages/
update to latest xamarin forms
Launch android and you will get in output
ImageLoaderSourceHandler: Could not retrieve image or image data was invalid: Uri: https://aka.ms/campus.jpg
Expected Behavior
Load the image
Actual Behavior
Does not show image
Basic Information
Screenshots
Reproduction Link
The text was updated successfully, but these errors were encountered: