diff --git a/src/mbgl/map/tile_data.cpp b/src/mbgl/map/tile_data.cpp index 72e356bbf..bb8d18d12 100644 --- a/src/mbgl/map/tile_data.cpp +++ b/src/mbgl/map/tile_data.cpp @@ -64,5 +64,9 @@ void TileData::reparse(Worker& worker, std::function callback) { EnvironmentScope scope(tile->env, ThreadType::TileWorker, "TileWorker_" + tile->name); tile->parse(); }, - callback); + [tile, callback]() { + // `tile` is bound in this lambda to ensure that if it's the last owning pointer, + // destruction happens on the map thread, not the worker thread. + callback(); + }); }