Bug 53113

Summary: Xamarin.Forms.Map crash on UWP
Product: Forms Reporter: Tomislav Homan <tomislav.homan>
Component: SamplesAssignee: Jimmy [MSFT] <jimmy.garrido>
Severity: normal CC: cody.beyer, ethan.dennis, jimmy.garrido, nickcase, oleg.demchenko, sahin_ozdemir, sahou, tomislav.homan, v-amdha
Priority: ---    
Version: 2.3.3   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
Tags: crash, uwp, maps Is this bug a regression?: ---
Last known good build:
Attachments: Compressed modified sample
Attaching IDE logs

Description Tomislav Homan 2017-03-07 13:24:31 UTC
Created attachment 20181 [details]
Compressed modified sample

I managed to reproduce the crash that occurs on our application on one of the Xamarin samples. This is the sample: https://developer.xamarin.com/samples/xamarin-forms/CustomRenderers/Map/Polygon/
I had to do couple of simple modifications in order to reproduce it because I haven’t found the sample that deals with the current user location in the Xamarin.Forms section of the samples. 
1.	Add IsShowingUser="true" attribute to the customMap node in MapPage.xaml
2.	Add Location capability to the UWP package manifest
3.	Add a startup page with a button that calls Navigation.PushAsync(new MapPageCS()); on click 
4.	Set that startup page as startup page in App.cs - MainPage = new NavigationPage(new StartupPage());
Now you can start the app and click on the button and immediately back when the map is opened. If you click back before the app has picked up the user’s location it will crash. If you click button and back couple of times in a row it will usually do the trick. If you obtain the location without crashing, by actually waiting for it, then it’ll be fine afterwards, because it seems that it caches the location and it shows it immediately if you open the map afterwards. This isn’t usual button-spamming bug, it really does sometimes take some time to fetch the location and it crashes if you give up on it and click back. 
I’m using these versions:
Here is the stack trace:
   at Xamarin.Forms.Maps.UWP.MapRenderer.LoadUserPosition(Geocoordinate userCoordinate, Boolean center)
   at Xamarin.Forms.Maps.UWP.MapRenderer.<UpdateIsShowingUser>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.Forms.Maps.UWP.MapRenderer.<OnElementChanged>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
   at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()
I attached the modified sample

If you need any info please tell so…

Best regards,
Tomislav Homan
Comment 1 Jimmy [MSFT] 2017-03-07 15:59:43 UTC
Thank you for reporting this! Let me run the project you attached to try confirming this issue and I will update the report accordingly.
Comment 2 Ethan Dennis 2017-03-13 16:27:34 UTC
Fixed in https://github.com/xamarin/Xamarin.Forms/pull/811
Comment 3 Samantha Houts [MSFT] 2017-03-20 17:32:47 UTC
Should be fixed in 2.3.5-pre1. Thank you!
Comment 4 Sahin Ozdemir 2017-05-31 09:02:15 UTC
I am getting the same error when using the maprenderer for UWP. I have updated to pre1 and also tried pre3.
Comment 5 Nick Case 2017-06-13 15:01:50 UTC
I have also managed to re-create this bug in all:

#Current Stable
Comment 6 Samantha Houts [MSFT] 2017-06-13 15:53:07 UTC
Reopening per Comment 4 and Comment 5. Do you have a reproduction project you can attach that demonstrates the crash?

Thank you!
Comment 7 Nick Case 2017-06-14 08:38:17 UTC
Have just looked over my configurations again and it appears while Xamarin.Forms was updated to pre3 by Nuget, Xamarin.Forms.Maps was not.

Have just brought that in line with Xamarin.Forms and cannot reproduce, so my test was a false negative.
Comment 8 Aman Dharwal 2017-07-12 11:32:52 UTC
I tried it to reproduce using the sample given in bug, but it doesn't reproducible anymore, hence marking it as Verified

Screencast link : https://www.screencast.com/t/FG2QNzzXMu

Environment info :

Comment 9 Aman Dharwal 2017-07-12 11:35:39 UTC
Created attachment 23494 [details]
Attaching IDE logs

Diagnostics build logs :