arcgis-maps-sdk-dotnet-toolkit icon indicating copy to clipboard operation
arcgis-maps-sdk-dotnet-toolkit copied to clipboard

Toolkit Basemap Gallery doesn't display the Thumbnails properly

Open LuisRguezEsriSpain opened this issue 1 year ago • 12 comments

I am developing an application with MAUI.

  • Product: ArcGIS Maps SDK for .NET
  • Version: 200.2
  • Project template: ArcGIS Maps SDK .NET MAUI App (Esri)
  • Framework: .NET 7.0
  • Toolkit Basemap Gallery widget

When I run de app by using "Samsung Galaxy Tab A SM-T510" and "Samsung Galaxy Tab A SM-T580", Toolkit Basemap Gallery widget doesn't display the Thumbnails properly.

BasemapGalleryThumbnails

After creating a Esri Case, Esri recommend me submit a new Issue.

LuisRguezEsriSpain avatar Oct 24 '23 14:10 LuisRguezEsriSpain

@LuisRguezEsriSpain Would you be able to share a small sample that reproduces the issue?

dotMorten avatar Oct 26 '23 03:10 dotMorten

I share a small sample.

PoCDrones.zip

LuisRguezEsriSpain avatar Oct 26 '23 20:10 LuisRguezEsriSpain

Thank you. Were you only seeing this on Android, or only on certain Android devices? I see the basemaps both on Windows and on my Android: image

dotMorten avatar Nov 03 '23 18:11 dotMorten

Hi Morten,

I only see Thumbnails on certain Android devices.

Por example:

  • I see Thumbnails on mobiles Miui 10 and Samsung Galaxy A52s
  • I don't see Thumbnails on tablets "Samsung Galaxy Tab A SM-T510" and "Samsung Galaxy Tab A SM-T580"

LuisRguezEsriSpain avatar Nov 05 '23 09:11 LuisRguezEsriSpain

It looks like it is hitting this fallback:

https://github.com/Esri/arcgis-maps-sdk-dotnet-toolkit/blob/8e5bc024f51beea413b3f11541ed662854e38323/src/Toolkit/Toolkit.Maui/BasemapGallery/ByteArrayToImageSourceConverter.cs#L34

That data should be coming from here: https://github.com/Esri/arcgis-maps-sdk-dotnet-toolkit/blob/8e5bc024f51beea413b3f11541ed662854e38323/src/Toolkit/Toolkit/UI/Controls/BasemapGallery/BasemapGalleryItem.cs#L100

Since I can't reproduce, would you be able to debug what is happening on your specific Android devices and see why the thumbnails fail to load?

dotMorten avatar Nov 06 '23 22:11 dotMorten

Hi Morten,

This is the debug's result.

at RuntimeCoreNet.GeneratedWrappers.CoreImage.GetEncodedBuffer() at Esri.ArcGISRuntime.UI.RuntimeImage.GetEncodedBufferAsync(CancellationToken cancellationToken) at PoCDrones.BasemapGallery.BasemapGalleryItem.LoadImage() in C:\LuisRodriguez\Proyectos\ENAIRE\200_2\Incidencia\PoCDrones\PoCDrones\BasemapGallery\BasemapGalleryItem.cs:line 107

BasemapGalleryThumbnailsDebug1

BasemapGalleryThumbnailsDebug2

this.Thumbnail.Source.AbsoluteUri: "https://www.arcgis.com/sharing/rest/content/items/983b312ebd9b4d15a02e00f50acdb1c1/info/thumbnail/thumbnail1607564423352.jpeg"

BasemapGalleryThumbnailsDebug3

LuisRguezEsriSpain avatar Nov 07 '23 11:11 LuisRguezEsriSpain

Thank you for the detailed screenshots. InvalidProgramException sounds like something went wrong in .NET or the compilation: https://learn.microsoft.com/en-us/dotnet/api/system.invalidprogramexception?view=net-7.0 Is your .NET up to date? Any chance you could also try with the latest .NET 8?

dotMorten avatar Nov 08 '23 00:11 dotMorten

Hi Morten,

I don't see how to create a ArcGIS Maps SDK .NET MAUI project using .NET.

DotNet8_1

I also don't see a way to change an existing project's .NET Framework.

DotNet8_2

LuisRguezEsriSpain avatar Nov 10 '23 08:11 LuisRguezEsriSpain

.NET 8 shipped as final yesterday. If you update your visual studio to latest, you should now see it in your dropdown (before this you needed the preview release)

dotMorten avatar Nov 15 '23 19:11 dotMorten

Hi Morten,

I've installed the latest versión of visual studio.

LatestVSVersion

I've also installed ArcGIS_Maps_SDK_DotNet_Templates_200_3_0.vsix.

In project propertiens I cannot choose either "Target Android Framework" or "Minimum Target Android Framework".

TargetAndoird FW

In addition to this issue I have others issues:

  • When I change content of appicon.svg and appiconfg.svg I get this error when the project is built.

ManifestError

  • In Android app I cannot see svg icons as souce if ImageButton
  • In Android app I cannot change IsEnabled property of "Frame" Maui controls by code

LuisRguezEsriSpain avatar Jan 08 '24 21:01 LuisRguezEsriSpain

@LuisRguezEsriSpain are you able to build a normal .NET MAUI app targeting .NET 8? Most of the settings you refer too are easiest set in the .csproj file directly.

dotMorten avatar Jan 08 '24 22:01 dotMorten

@dotMorten I've done this workaround in BasemapGalleryItem class and work properly:

        private async Task LoadImage()
        {
            IsLoadingThumbnail = true;
            try
            {
                await (Thumbnail?.LoadAsync() ?? Task.CompletedTask);

                if (Thumbnail?.LoadStatus == LoadStatus.Loaded)
                {
                    var stream = await Thumbnail.GetEncodedBufferAsync();
                    var buffer = new byte[stream.Length];
                    await stream.ReadAsync(buffer, 0, (int)stream.Length);
                    ThumbnailData = buffer;
#if WINDOWS_XAML
                    ThumbnailBitmap = await Thumbnail.ToImageSourceAsync();
#endif
                }
                _hasLoaded = true;
            }
            catch (Exception ex)
            {
                await LoadImageAux();
            }
            finally
            {
                IsLoadingThumbnail = false;
            }
        }

        private async Task LoadImageAux()
        {
            try
            {
                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, Thumbnail.Source);
                HttpClient client = new HttpClient(new HttpClientHandler());
                var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
                var content = response.EnsureSuccessStatusCode();
                var streamRes = await content.Content.ReadAsStreamAsync();
                byte[] buffer = new byte[16 * 1024];
                using (MemoryStream ms = new MemoryStream())
                {
                    int read;
                    while ((read = await streamRes.ReadAsync(buffer, 0, buffer.Length)) > 0)
                    {
                        ms.Write(buffer, 0, read);
                    }
                    ThumbnailData = ms.ToArray();
                }
            }
            catch (Exception ex2)
            {
            }
        }

LuisRguezEsriSpain avatar Jan 08 '24 23:01 LuisRguezEsriSpain