-
Notifications
You must be signed in to change notification settings - Fork 1.3k
MGLComputedShapeSource/CustomGeometrySource.java shouldn't create thread pools #11895
Comments
@ChrisLoer Instead of exposing CustomGeometrySource from the SDK, an alternative would be to implement it as a plugin. The plugin would run a simple http server and use run time styling api to add a new source with http://localhost:<port_number> tile template urls. |
Capturing from conversation with @LukasPaczos regarding the changes in #12509: Regardless of the threading model we use for
I think ideally we'd implement a coalescing strategy in |
The original implementation for iOS and mbgl did provide for asynchronous tile production, but in #6940 (comment) I asked @JesseCrocker to consider a synchronous API instead, since delegate or data source methods that rely on a passed-in callback to be called tend to be error-prone. It’s easy to forget to call the callback, though the fact that the callback is passed in should mitigate that danger somewhat. I had been thinking primarily of MapKit’s Can the new method be implemented alongside the existing ones? I think it would be fine if the developer has to choose between |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
The core
CustomGeometrySource
is configured with a "fetch tile function" that glues out into the platform-specific wrappers (and eventually the user-provided custom implementation). The darwin implementation of this function is inMGLComputedShapeSource.mm
and the Android implementation is inCustomGeometrySource.java
. Both implementations follow a similar pattern:id<MGLComputedShapeSourceDataSource>
on darwin,GeometryTileProvider
on Android), and then once the synchronous call returns, queue an asynchronoussetTileData
callback that feeds back into the coreCustomGeometrySource
I think this model would make sense if the primary job of the user-provided tile provider was to run some computationally expensive operation, but it doesn't seem to me like a very good fit for the case where the tile provider's job involves asynchronously requesting resources itself. Because the provider doesn't have access to a callback, it needs to block on asynchronous requests, which is an awkward interface and also opens the potential for clogging up the 4 worker threads with blocking requests. Also, this forces the provider to support synchronized cross-thread access to itself (a bit of an anti-pattern), even when it's not necessary.
I think it would be better if we leave concurrency choices to the user, so for instance
GeometryTileProvider::getFeaturesForBounds
would take a callback as an argument (some kind of wrapper on the coreActorRef
that's being used for the underlying callback). Then, for someone implementingGeometryTileProvider
:/cc @asheemmamoowala @jfirebaugh @1ec5 @ivovandongen
The text was updated successfully, but these errors were encountered: