Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

sharedThreadPool reference in platform specific implementations #12712

Closed
LukasPaczos opened this issue Aug 22, 2018 · 8 comments · Fixed by #12810
Closed

sharedThreadPool reference in platform specific implementations #12712

LukasPaczos opened this issue Aug 22, 2018 · 8 comments · Fixed by #12810
Assignees
Labels
Android Mapbox Maps SDK for Android crash release blocker Blocks the next final release

Comments

@LukasPaczos
Copy link
Contributor

LukasPaczos commented Aug 22, 2018

DraggableMarkerActivity crashes on master during startup with this exception:

java.lang.Error: mutex lock failed: Device or resource busy
    at com.mapbox.mapboxsdk.style.sources.GeoJsonSource.nativeSetFeatureCollection(Native Method)
    at com.mapbox.mapboxsdk.style.sources.GeoJsonSource.setGeoJson(GeoJsonSource.java:220)
    at com.mapbox.mapboxsdk.style.sources.GeoJsonSource.<init>(GeoJsonSource.java:124)
    at com.mapbox.mapboxsdk.testapp.activity.style.DraggableMarkerActivity.<init>(DraggableMarkerActivity.kt:49)
    at java.lang.Class.newInstance(Native Method)
    at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:69)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1215)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2831)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)

/cc @tobrun

@LukasPaczos LukasPaczos added Android Mapbox Maps SDK for Android crash labels Aug 22, 2018
@LukasPaczos
Copy link
Contributor Author

Initial debugging shows that creating sources before the map is initialized is broken and results in the above crash or freeze. This regression was introduced with the async GeoJsonSource features conversion in #12580.

@LukasPaczos
Copy link
Contributor Author

I'm seeing mutex lock failed: Device or resource busy when trying to lock mutex after invoking the actor but only when the map is not created. There seems to be no issues scheduling the actor after the map is initialized.

@jfirebaugh
Copy link
Contributor

jfirebaugh commented Aug 27, 2018

The GeoJSONSource constructors call std::make_unique<Actor<FeatureConverter>>(*sharedThreadPool()), dereferencing the std::shared_ptr<ThreadPool> that sharedThreadPool() returns. But as soon as this line is complete, the shared_ptr is destroyed, and it's the last outstanding reference, so the ThreadPool is destroyed and the actor is left with a dangling reference.

cc @kkaefer

@jfirebaugh
Copy link
Contributor

CustomGeometrySource has the same issue.

@kkaefer
Copy link
Member

kkaefer commented Aug 27, 2018

They shouldn't reference sharedThreadPool to begin with. It's a platform-specific implementation and will e.g. not be available in the node bindings.

@LukasPaczos LukasPaczos changed the title DraggableMarkerActivity crash sharedThreadPool reference in platform specific implementations Sep 4, 2018
@LukasPaczos
Copy link
Contributor Author

What are the next steps here? Should we keep the reference to the pointer instead of dereferencing it? Is a separate thread pool implementation required as of now?

Ideally, the fix would need to land before the 6.5.0 release.

@jfirebaugh
Copy link
Contributor

They shouldn't reference sharedThreadPool to begin with. It's a platform-specific implementation and will e.g. not be available in the node bindings.

This is the Android-specific GeoJSONSource class, so we're okay on that front at least.

@kkaefer
Copy link
Member

kkaefer commented Sep 4, 2018

🤦‍♂️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android crash release blocker Blocks the next final release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants