Native thread exiting without having called DetachCurrentThread

727 views
Skip to first unread message

bi...@harborlightsoftware.com

unread,
Jun 20, 2016, 2:44:41 PM6/20/16
to Nutiteq-dev
I am using SDK 3.3 with Xamarin Forms on Android.

Upon loading a page with the Nutiteq map view on it, the application checks to see if all required packages have been downloaded, and if not, it will sequentially download them.

If a user exits the page, I attempt to stop the download, but it appears that the thread that the downloads occur on is still running.

If I then attempt to cleanup and dispose the map view, or if Garbage Collection attempts to cleanup the resources, I get an error:

Native thread exiting without having called DetachCurrentThread (maybe it's going to use a pthread_key_create destructor?): Thread[29,tid=28238,Native,Thread*=0x7f73a33200,peer=0x12d5b2e0,"Thread-5580"]

At best, the app continues and the background download continues. More oftne, the app crashes.

Below is sample code (Xamarin C# Android) for my cleanup routine:

// Unsubscribe from event handlers and cleanup any resources
if ( m_packageManager.PackageManagerListener != null )
{
m_packageManager.PackageManagerListener.Dispose();
m_packageManager.PackageManagerListener = null;
}
m_packageManager.Stop( true );
m_packageManager.Dispose();
m_packageManager = null;

if ( m_baseVectorTileLayer != null )
{
m_mapView.Layers.Remove( m_baseVectorTileLayer );
m_baseVectorTileLayer.Dispose();
m_baseVectorTileLayer = null;
}
if ( m_myMapLayer != null )
{
m_mapView.Layers.Remove( m_myMapLayer );
myMapLayer.Dispose();
myMapLayer = null;
}
if ( m_vectorTileDecoder != null )
{
m_vectorTileDecoder.Dispose();
m_vectorTileDecoder = null;
}

m_mapView.Layers.Dispose();
m_mapView.Dispose();

What can I provide to you to help you debug this?

Thanks
bill spain

spainb...@gmail.com

unread,
Jun 24, 2016, 5:17:50 AM6/24/16
to Nutiteq-dev, bi...@harborlightsoftware.com
I've tried multiple approaches to getting around this problem. The cleanup code above was giving me problems and I've cleaned that up and played all sorts of other tricks, but there seems to be a problem here.

Sometimes if I call PackageManager.Stop(true), I can continue to see Nutiteq log statements indicating that downloads are continuing.

If seems as if with the thread that the downloads are running is still running, trying to clean things up, or navigate away from the page fail to free up the memory from the page, and sooner or later my app will run out of memory and crash.

I am not seeing this problem in our iOS app.

I've even tried keeping the map page in global memory so that I don't have to ever destroy it when I'm done with it, but that hasn't been practical in terms of memory usage as well.

Any comments?
Thanks
Bill Spain

Jaak Laineste

unread,
Jun 24, 2016, 5:22:10 AM6/24/16
to nutit...@googlegroups.com, spainb...@gmail.com, bi...@harborlightsoftware.com
Hello,

Thanks for the reports. In principle it is possible possible that Xamarin Forms does something unexpected in threading or memory management. It looks like we need a sample project to replicate and troubleshoot the issue before we can help here. Can you provide one?

Also check that you use the latest Xamarin build (component was lately updated to 3.3.0), we have done some Xamarin-specific memory management fixes there too.

Jaak
> --
> You received this message because you are subscribed to the Google Groups "Nutiteq-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nutiteq-dev...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages