This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Hang on each tile load — VectorTileData, TileWorker::parseLayer #3636
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
55e2819
[core] Add nonblocking task cancellation
tmpsantos 571c57e
[core] Make TileData cancellation non-blocking
tmpsantos 3a79d28
[core] Make TileData observable
tmpsantos dfdf867
[core] Add a custom deleter for the TileData
tmpsantos 42e7ecb
[core] Queue redoTextPlacement jobs
tmpsantos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <mbgl/map/tile_data_deleter.hpp> | ||
|
||
#include <mbgl/map/tile_data.hpp> | ||
|
||
namespace mbgl { | ||
|
||
TileDataDeleter::~TileDataDeleter() { | ||
// Force the canceling of all pending TileData | ||
// before destroying. We have assert()s on Debug | ||
// mode on TileData to make sure it doesn't block | ||
// at the destructor unless explicitly canceled. | ||
for (auto& entry : tileDataMap) { | ||
entry.first->tryCancel(true); | ||
} | ||
} | ||
|
||
void TileDataDeleter::add(TileData* data) { | ||
std::unique_ptr<TileData> tileData(data); | ||
|
||
// This custom deleter will try to cancel the task if it is | ||
// non-blocking, otherwise we keep it and subscribe to the | ||
// event when the work is completed. When the event triggers | ||
// we delete the TileData because this time it won't block. | ||
if (!tileData->tryCancel()) { | ||
data->setObserver(this); | ||
tileDataMap.emplace(data, std::move(tileData)); | ||
} | ||
} | ||
|
||
void TileDataDeleter::onTileDataWorkCompleted(TileData* data) { | ||
tileDataMap.erase(data); | ||
} | ||
|
||
} // namespace mbgl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef MBGL_MAP_TILE_DATA_DELETER | ||
#define MBGL_MAP_TILE_DATA_DELETER | ||
|
||
#include <mbgl/map/tile_data.hpp> | ||
#include <mbgl/util/noncopyable.hpp> | ||
|
||
#include <memory> | ||
#include <unordered_map> | ||
|
||
namespace mbgl { | ||
|
||
class TileData; | ||
|
||
class TileDataDeleter : public TileData::Observer, private util::noncopyable { | ||
public: | ||
virtual ~TileDataDeleter(); | ||
|
||
void add(TileData*); | ||
|
||
// TileData::Observer implementation. | ||
void onTileDataWorkCompleted(TileData*) override; | ||
|
||
private: | ||
std::unordered_map<TileData*, std::unique_ptr<TileData>> tileDataMap; | ||
}; | ||
|
||
} // namespace mbgl | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why move from
std::make_shared
tonew
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is sad, but
std::make_shared
doesn't support custom deleter. :(