Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolkit Basemap Gallery doesn't display the Thumbnails properly #530

Open
LuisRguezEsriSpain opened this issue Oct 24, 2023 · 12 comments
Open

Comments

@LuisRguezEsriSpain
Copy link

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.

@dotMorten
Copy link
Member

dotMorten commented Oct 26, 2023

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

@LuisRguezEsriSpain
Copy link
Author

I share a small sample.

PoCDrones.zip

@dotMorten
Copy link
Member

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

@LuisRguezEsriSpain
Copy link
Author

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"

@dotMorten
Copy link
Member

It looks like it is hitting this fallback:

return ImageSource.FromResource("Esri.ArcGISRuntime.Toolkit.Maui.Assets.BasemapLight.png", typeof(BasemapGallery).Assembly); ;

That data should be coming from here:

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?

@LuisRguezEsriSpain
Copy link
Author

LuisRguezEsriSpain commented Nov 7, 2023

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

@dotMorten
Copy link
Member

dotMorten commented Nov 8, 2023

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?

@LuisRguezEsriSpain
Copy link
Author

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

@dotMorten
Copy link
Member

.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)

@LuisRguezEsriSpain
Copy link
Author

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

@dotMorten
Copy link
Member

@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.

@LuisRguezEsriSpain
Copy link
Author

LuisRguezEsriSpain commented Jan 8, 2024

@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)
            {
            }
        }

@pMaske pMaske modified the milestone: 200.5 May 29, 2024
@dotMorten dotMorten linked a pull request Aug 1, 2024 that will close this issue
@dotMorten dotMorten removed a link to a pull request Aug 1, 2024
@dotMorten dotMorten removed this from the 200.5 milestone Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants