Bug 53113 - Xamarin.Forms.Map crash on UWP
Summary: Xamarin.Forms.Map crash on UWP
Alias: None
Product: Forms
Classification: Xamarin
Component: Samples ()
Version: 2.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
Depends on:
Reported: 2017-03-07 13:24 UTC by Tomislav Homan
Modified: 2017-07-12 11:35 UTC (History)
9 users (show)

Tags: crash, uwp, maps
Is this bug a regression?: ---
Last known good build:

Compressed modified sample (517.18 KB, application/x-zip-compressed)
2017-03-07 13:24 UTC, Tomislav Homan
Attaching IDE logs (3.04 KB, application/x-zip-compressed)
2017-07-12 11:35 UTC, Aman Dharwal

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

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 :