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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Join worker tasks before destroying TileData
Fixes #1309
- Loading branch information
1 parent
e476fcb
commit 5c7867f
Showing
11 changed files
with
111 additions
and
40 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <mbgl/util/work_request.hpp> | ||
|
||
namespace mbgl { | ||
|
||
WorkRequest::WorkRequest() = default; | ||
|
||
WorkRequest::WorkRequest(Future&& future) | ||
: complete(std::move(future)) { | ||
} | ||
|
||
WorkRequest::WorkRequest(WorkRequest&& o) | ||
: complete(std::move(o.complete)) { | ||
} | ||
|
||
WorkRequest::~WorkRequest() { | ||
if (complete.valid()) { | ||
complete.get(); | ||
} | ||
} | ||
|
||
WorkRequest& WorkRequest::operator=(WorkRequest&& o) { | ||
complete = std::move(o.complete); | ||
return *this; | ||
} | ||
|
||
WorkRequest::operator bool() const { | ||
return complete.valid(); | ||
} | ||
|
||
void WorkRequest::join() { | ||
complete.get(); | ||
} | ||
|
||
} |
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,31 @@ | ||
#ifndef MBGL_UTIL_WORK_REQUEST | ||
#define MBGL_UTIL_WORK_REQUEST | ||
|
||
#include <mbgl/util/noncopyable.hpp> | ||
|
||
#include <future> | ||
|
||
namespace mbgl { | ||
|
||
class WorkRequest : public util::noncopyable { | ||
public: | ||
using Future = std::future<void>; | ||
|
||
WorkRequest(); | ||
WorkRequest(Future&&); | ||
WorkRequest(WorkRequest&&); | ||
~WorkRequest(); | ||
|
||
WorkRequest& operator=(WorkRequest&&); | ||
operator bool() const; | ||
|
||
// Wait for the worker task to complete. | ||
void join(); | ||
|
||
private: | ||
Future complete; | ||
}; | ||
|
||
} | ||
|
||
#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
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
5c7867f
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.
This causes severe render stalls, but will likely be fixed by #1326
5c7867f
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.
In fact, this makes the library pretty much unusable in areas that require many different glyph PBFs: When zooming into the area, you'll likely trigger a cancellation, which blocks the Map thread until it is complete. However, the Worker threads wait for the Glyph PBF, which never happens because the Map thread can't process the return value and we end up in a deadlock that we'll never recover from.
5c7867f
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.
Damn, that's bad. If #1326 will definitely fix this I agree we should consider merging it now rather than later. The alternatives are to back this out and keep trying to patch up the shared pointer lifetime issues (failed in several tries so far), or address #1364/#926 head-on.