VladislavAntonyuk/MauiSamples

[Android]System.Threading.Tasks.TaskCanceledException: A task was canceled in MauiMaps Sample

HobDev opened this issue · 3 comments

{System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.Maui.Controls.StreamImageSource.Microsoft.Maui.IStreamImageSource.GetStreamAsync(CancellationToken userToken) in D:\a_work\1\s\src\Controls\src\Core\StreamImageSource.cs:line 48
at Microsoft.Maui.Controls.Compatibility.Platform.Android.ImageLoaderSourceHandler.LoadImageAsync(ImageSource imagesource, Context context, CancellationToken cancelationToken) in D:\a_work\1\s\src\Compatibility\Core\src\Android\Renderers\ImageLoaderSourceHandler.cs:line 19

at CustomizedMap.Platforms.Android.CustomMapHandler.AddPins(IEnumerable`1 mapPins) in {folder path here}\Platforms\Android\CustomMapHandler.cs:line 97}

The repro project is here:
https://github.com/HobDev/CustomPinSample

@VladislavAntonyuk I am also confused about the pin icons. Can I use png as custom pin image. I used the icon from your project just for testing purpose.

You can use any image

The problem is that the method MapPins is synchronous: https://github.com/VladislavAntonyuk/MauiSamples/blob/main/MauiMaps/Platforms/Android/CustomMapHandler.cs#L37

However I am not able to reproduce the issue, I suggest you find a synchronous implementation for this method: https://github.com/VladislavAntonyuk/MauiSamples/blob/main/MauiMaps/Platforms/Android/CustomMapHandler.cs#L72