[Impeller] Make ContextVK hash values globally unique#171119
Merged
auto-submit[bot] merged 2 commits intoflutter:masterfrom Jun 25, 2025
Merged
[Impeller] Make ContextVK hash values globally unique#171119auto-submit[bot] merged 2 commits intoflutter:masterfrom
auto-submit[bot] merged 2 commits intoflutter:masterfrom
Conversation
ContextVK had been using a thread-local counter to assign the value returned by GetHash. But CommandPoolRecyclerVK was using these values as keys in a process-wide global map. If two engine instances using different task runner threads both created a ContextVK, then the thread-local counter could cause both contexts to share the same hash. So when CommandPoolRecyclerVK::DestroyThreadLocalPools destroys the pools associated with the first context's hash, it will also incorrectly destroy the second context's pools. Fixes flutter#170141
gaaclarke
approved these changes
Jun 25, 2025
Member
gaaclarke
left a comment
There was a problem hiding this comment.
lgtm with one minor request.
| // You could make a context once per nanosecond for 584 years on one thread | ||
| // before this overflows. | ||
| return ++tls_context_count; | ||
| return ++context_count; |
Member
There was a problem hiding this comment.
The google convention is to not use operators with atomic values.
Suggested change
| return ++context_count; | |
| return context_count.fetch_add(1); |
flutteractionsbot
pushed a commit
to flutteractionsbot/flutter
that referenced
this pull request
Jun 26, 2025
ContextVK had been using a thread-local counter to assign the value returned by GetHash. But CommandPoolRecyclerVK was using these values as keys in a process-wide global map. If two engine instances using different task runner threads both created a ContextVK, then the thread-local counter could cause both contexts to share the same hash. So when CommandPoolRecyclerVK::DestroyThreadLocalPools destroys the pools associated with the first context's hash, it will also incorrectly destroy the second context's pools. Fixes flutter#170141
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 27, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 27, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 27, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 27, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 28, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 28, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 28, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 29, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 29, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 29, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 30, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 30, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jun 30, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 1, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 1, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 1, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 2, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 2, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 2, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 2, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 2, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 3, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 3, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 3, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 3, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 3, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 4, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 4, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 4, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 5, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 5, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 6, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 6, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 6, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 7, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 7, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Jul 7, 2025
mboetger
pushed a commit
to mboetger/flutter
that referenced
this pull request
Jul 21, 2025
ContextVK had been using a thread-local counter to assign the value returned by GetHash. But CommandPoolRecyclerVK was using these values as keys in a process-wide global map. If two engine instances using different task runner threads both created a ContextVK, then the thread-local counter could cause both contexts to share the same hash. So when CommandPoolRecyclerVK::DestroyThreadLocalPools destroys the pools associated with the first context's hash, it will also incorrectly destroy the second context's pools. Fixes flutter#170141
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Aug 14, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Aug 14, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Aug 15, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Aug 15, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Aug 16, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ContextVK had been using a thread-local counter to assign the value returned by GetHash. But CommandPoolRecyclerVK was using these values as keys in a process-wide global map.
If two engine instances using different task runner threads both created a ContextVK, then the thread-local counter could cause both contexts to share the same hash. So when CommandPoolRecyclerVK::DestroyThreadLocalPools destroys the pools associated with the first context's hash, it will also incorrectly destroy the second context's pools.
Fixes #170141