mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] Lock access to descriptor pool map. (flutter/engine#56113)
Speculative fix for https://github.com/flutter/flutter/issues/157565 which looks like the kind of error that might happen if we concurrently mutate this hashmap.
This commit is contained in:
parent
c025861523
commit
368ca941eb
@ -503,15 +503,18 @@ std::shared_ptr<CommandBuffer> ContextVK::CreateCommandBuffer() const {
|
||||
|
||||
// look up a cached descriptor pool for the current frame and reuse it
|
||||
// if it exists, otherwise create a new pool.
|
||||
DescriptorPoolMap::iterator current_pool =
|
||||
cached_descriptor_pool_.find(std::this_thread::get_id());
|
||||
std::shared_ptr<DescriptorPoolVK> descriptor_pool;
|
||||
if (current_pool == cached_descriptor_pool_.end()) {
|
||||
descriptor_pool =
|
||||
(cached_descriptor_pool_[std::this_thread::get_id()] =
|
||||
std::make_shared<DescriptorPoolVK>(weak_from_this()));
|
||||
} else {
|
||||
descriptor_pool = current_pool->second;
|
||||
{
|
||||
Lock lock(desc_pool_mutex_);
|
||||
DescriptorPoolMap::iterator current_pool =
|
||||
cached_descriptor_pool_.find(std::this_thread::get_id());
|
||||
if (current_pool == cached_descriptor_pool_.end()) {
|
||||
descriptor_pool =
|
||||
(cached_descriptor_pool_[std::this_thread::get_id()] =
|
||||
std::make_shared<DescriptorPoolVK>(weak_from_this()));
|
||||
} else {
|
||||
descriptor_pool = current_pool->second;
|
||||
}
|
||||
}
|
||||
|
||||
auto tracked_objects = std::make_shared<TrackedObjectsVK>(
|
||||
@ -668,7 +671,10 @@ void ContextVK::InitializeCommonlyUsedShadersIfNeeded() const {
|
||||
}
|
||||
|
||||
void ContextVK::DisposeThreadLocalCachedResources() {
|
||||
cached_descriptor_pool_.erase(std::this_thread::get_id());
|
||||
{
|
||||
Lock lock(desc_pool_mutex_);
|
||||
cached_descriptor_pool_.erase(std::this_thread::get_id());
|
||||
}
|
||||
command_pool_recycler_->Dispose();
|
||||
}
|
||||
|
||||
|
||||
@ -234,7 +234,9 @@ class ContextVK final : public Context,
|
||||
using DescriptorPoolMap =
|
||||
std::unordered_map<std::thread::id, std::shared_ptr<DescriptorPoolVK>>;
|
||||
|
||||
mutable DescriptorPoolMap cached_descriptor_pool_;
|
||||
mutable Mutex desc_pool_mutex_;
|
||||
mutable DescriptorPoolMap IPLR_GUARDED_BY(desc_pool_mutex_)
|
||||
cached_descriptor_pool_;
|
||||
bool should_disable_surface_control_ = false;
|
||||
bool should_batch_cmd_buffers_ = false;
|
||||
std::vector<std::shared_ptr<CommandBuffer>> pending_command_buffers_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user