UWP applications exits when map control is garbage collected

0

I created a mapping application that places custom tiles on a Bing Map control to display a heatmap. The application worked without issue with build 16299. With build 17663, I get the following error:

Exception thrown at 0x00007FFB1496DF33 (ntdll.dll) in xxxxx.exe: 0xC0000005: Access violation writing location 0x0000000000000024.

This error occurs only after I leave the page that contains the MapControl. The error may occur immediately after I change to a different page or after I traverse many pages. I also noticed that a garbage collection two also occurs at the time the error is thrown.

My stack trace is exactly the same as the stack trace in the following post:

[https://social.msdn.microsoft.com/Forums/vstudio/en-US/1c0d361f-9470-4c38-b856-0ae502427b56/visibility-of-maptilesource?forum=bingmapswindows8][1]

Being new to UWP, I'm not exactly sure how the dev solved the issue in the above link. I would guess from the stack trace that the the MapControl is having issues when being garbage collected. I have attempted to remove all tiles and delete all objects from the map control on leaving the page but it didn't resolve the issue.

I'm not sure how I debug this issue as the map control and the tile set appear to work fine while on the map page, it's only when GC occurs do I get the fatal error.

I saw on a post in the Microsoft Dev forum that suggested making the map control static. It just seems odd that the build work correctly for 16299 but with build 17663 it breaks. Any suggestions on courses of actions would be greatly appreciated.

My Stack trace:

ntdll.dll!RtlpWaitOnCriticalSection()
ntdll.dll!RtlpEnterCriticalSectionContended()
ntdll.dll!RtlEnterCriticalSection()
BingMaps.dll!Pal::CppEvent<class MapControl::MapMode &>::detach(class Pal::EventId *)
BingMaps.dll!Microsoft::WRL::Details::RuntimeClassImpl<struct Microsoft::WRL::RuntimeClassFlags<1>,1,1,0,struct IMapControlAdapter,struct IMapControlAdapterInternal,struct IOverviewMapControlAdapter,struct IMapOverlayModelBingServices>::Release(void) 
JpMapControl.dll!JpMapControlHybridAdapter::~JpMapControlHybridAdapter(void)
JpMapControl.dll!JpMapControlHybridAdapter::`vector deleting destructor'(unsigned int)
JpMapControl.dll!Microsoft::WRL::Details::RuntimeClassImpl<struct 
Microsoft::WRL::RuntimeClassFlags<1>,1,1,0,struct IMapControlAdapter,struct IMapControlHybridAdapter,struct IMapControlHybridAdapterPrivate,struct IMapKeyValidator,class Microsoft::WRL::FtmBase>::Release(void)
Windows.UI.Xaml.dll!DirectUI::TrackerTargetReference::Clear(unsigned char bEnsureTrackerTarget, unsigned char bForceLoopback) Line 697
[Inline Frame] Windows.UI.Xaml.dll!DirectUI::TrackerPtr<IUnknown,1,0>::Clear() Line 267
[Inline Frame] Windows.UI.Xaml.dll!ctl::WeakReferenceSourceNoThreadId::RemovePtrValue(DirectUI::TrackerPtr<IUnknown,1,0> &) Line 233
[Inline Frame] Windows.UI.Xaml.dll!ctl::WeakReferenceSourceNoThreadId::DeleteTrackerHandle(TrackerHandle__ *) Line 1087
Windows.UI.Xaml.dll!ctl::interface_forwarder<ITrackerOwner,DirectUI::DependencyObject>::DeleteTrackerHandle(TrackerHandle__ * handle=0x00000241365f6920) Line 98
Windows.UI.Xaml.Maps.dll!Private::TrackerPtr<struct Windows::Foundation::Collections::IObservableVector<class Windows::UI::Xaml::DependencyObject *> >::~TrackerPtr<struct Windows::Foundation::Collections::IObservableVector<class Windows::UI::Xaml::DependencyObject *> >(void)
Windows.UI.Xaml.Maps.dll!Windows::UI::Xaml::Controls::Maps::MapControl::~MapControl(void)
Windows.UI.Xaml.Maps.dll!Windows::UI::Xaml::Controls::Maps::MapControl::`vector deleting destructor'(unsigned int)
Windows.UI.Xaml.Maps.dll!Private::ReferenceTrackerRuntimeClass<struct 
Windows::UI::Xaml::Controls::Maps::IMapControl,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl2,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl3,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl4,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl5,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl6,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl7,class Microsoft::WRL::ComposableBase<struct 
Windows::UI::Xaml::Controls::IControlFactory>,class Microsoft::WRL::Details::Nil>::DeleteThis(void)
Windows.UI.Xaml.Maps.dll!Private::ReferenceTrackerRuntimeClass<struct 
Windows::UI::Xaml::Controls::Maps::IMapControl,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl2,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl3,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl4,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl5,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl6,struct 
Windows::UI::Xaml::Controls::Maps::IMapControl7,class Microsoft::WRL::ComposableBase<struct 
Windows::UI::Xaml::Controls::IControlFactory>,class Microsoft::WRL::Details::Nil>::Release(void)
[Inline Frame] Windows.UI.Xaml.dll!ctl::release_interface(DirectUI::DependencyObject * &) Line 135
Windows.UI.Xaml.dll!DirectUI::DependencyObject::ReleaseForPeerReferenceHelper() Line 2634
Windows.UI.Xaml.dll!DirectUI::DependencyObject::ClearPeerReferences() Line 748
Windows.UI.Xaml.dll!DirectUI::DependencyObject::Deinitialize() Line 719
Windows.UI.Xaml.dll!DirectUI::UIAffinityReleaseQueue::DoCleanup(unsigned char bSync='\0', unsigned char * completed=0x000000724907eab0) Line 191
Windows.UI.Xaml.dll!DirectUI::UIAffinityReleaseQueue::BuildTree(unsigned char * returnValue=0x000000724907eb50) Line 44
Windows.UI.Xaml.dll!DirectUI::BuildTreeService::BuildTrees(bool * pWorkLeft=0x000000724907eb88) Line 111
Windows.UI.Xaml.dll!AgCoreCallbacks::FrameworkCallbacks_PhasedWorkDistributor_PerformWork(unsigned int * pWorkleft=0x000000724907ebe4) Line 560
[Inline Frame] Windows.UI.Xaml.dll!CFxCallbacks::FrameworkCallbacks_PhasedWorkDistributor_PerformWork(unsigned int *) Line 1131
Windows.UI.Xaml.dll!CCoreServices::NWDrawTree(HWWalk * pHWWalk=0x0000024124ebcf50, CWindowRenderTarget * pRenderTarget=0x0000024124ee2ad0, VisualTree * pVisualTree, unsigned int forceRedraw=0x00000000, XRECT_WH * prcDirtyRect=0x000000724907edc0) Line 6982  C++
Windows.UI.Xaml.dll!CCoreServices::NWDrawMainTree(CWindowRenderTarget * pIRenderTarget=0x0000024124ee2ad0, bool fForceRedraw, XRECT_WH * prcDirtyRect=0x000000724907edc0) Line 6723
Windows.UI.Xaml.dll!CWindowRenderTarget::Draw(CCoreServices * fForceRedraw=0x00000000, unsigned int prcDirtyRect={...}, XRECT_WH *) Line 137
Windows.UI.Xaml.dll!CXcpBrowserHost::OnTick() Line 538
Windows.UI.Xaml.dll!CXcpDispatcher::Tick() Line 1446
Windows.UI.Xaml.dll!CXcpDispatcher::OnReentrancyProtectedWindowMessage(HWND__ * msg=0x00000402, unsigned int lParam=0x0000000000000000, unsigned __int64) Line 1046
[Inline Frame] Windows.UI.Xaml.dll!CXcpDispatcher::ProcessMessage(HWND__ *) Line 887 
Windows.UI.Xaml.dll!CXcpDispatcher::WindowProc(HWND__ * hwnd=0x0000000000080a2e, unsigned int msg=0x00000402, unsigned __int64 wParam=0x0000000000000000, __int64 lParam=0x0000000000000000) Line 836
Windows.UI.Xaml.dll!CDeferredInvoke::DispatchQueuedMessage(bool * dispatchedWork=0x000000724907ef38, bool * hasMoreWork) Line 299
[Inline Frame] Windows.UI.Xaml.dll!CXcpDispatcher::MessageTimerCallback() Line 1531
Windows.UI.Xaml.dll!CXcpDispatcher::MessageTimerCallbackStatic(void * myUserData=0x0000024124ec0ae0) Line 1523
CoreMessaging.dll!Microsoft__CoreUI__Dispatch__TimeoutHandler$CallbackThunk(class System::Delegate *)
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::TimeoutManager::Callback_OnDispatch()
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::EventLoop::Callback_RunCoreLoop(struct Microsoft::CoreUI::Dispatch::RunMode,bool,bool &)
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter::OnUserDispatch(bool,struct Microsoft::CoreUI::Dispatch::UserAdapter__UserPriority,struct System::IntPtr &)
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter_DoWork(struct Microsoft::CoreUI::Dispatch::UserData *,struct Microsoft::CoreUI::Dispatch::UserAdapter__UserPriority,bool)
CoreMessaging.dll!Microsoft::CoreUI::Dispatch::UserAdapter_WindowProc()
user32.dll!UserCallWinProcCheckWow()
user32.dll!DispatchMessageWorker()
Windows.UI.dll!Windows::UI::Core::CDispatcher::ProcessMessage(bool bDrainQueue, bool * pbWindowMessagesProcessed=0x000000724907f610, bool * pbInvokeItemProcessed=0x000000724907f611) Line 327
Windows.UI.dll!Windows::UI::Core::CDispatcher::WaitAndProcessMessagesInternal(bool bRunAlwaysOnce, void * hEventWait=0x0000000000000000) Line 1953   
Windows.UI.dll!Windows::UI::Core::CDispatcher::ProcessEvents(Windows::UI::Core::CoreProcessEventsOption options=CoreProcessEventsOption_ProcessUntilQuit) Line 599

Windows.UI.Xaml.dll!CJupiterWindow::RunCoreWindowMessageLoop() Line 1246
[Inline Frame] Windows.UI.Xaml.dll!CJupiterControl::RunMessageLoop() Line 1024
Windows.UI.Xaml.dll!DirectUI::DXamlCore::RunMessageLoop() Line 2446
twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationView::Run()
twinapi.appcore.dll!<lambda>(void)()
SHCore.dll!_WrapperThreadProc()
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()
c#
uwp
bing-maps
asked on Stack Overflow Jul 14, 2020 by Jason Pratt

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0