Bug 1871557: Make CompositorThreadHolder::IsInCompositorThread more accurate. r=gfx-reviewers,aosmond

As described in `CompositorThreadHolder::Shutdown`, it doesn't actually
shutdown the compositor thread, and other work may still be running on
it. Without this change, after calling `Shutdown`, `IsInCompositorThread`
will return false even for code running on the compositor thread. This
change adds an extra check that will return true if the current thread
matches the thread id of the compositor thread, even if the holder no
longer exists.

Differential Revision: https://phabricator.services.mozilla.com/D221729
This commit is contained in:
Brad Werth 2024-09-11 03:14:57 +00:00
parent ddd14e6b96
commit 7aa47e1d6b

View File

@ -174,7 +174,11 @@ void CompositorThreadHolder::Shutdown() {
/* static */
bool CompositorThreadHolder::IsInCompositorThread() {
if (!CompositorThread()) {
return false;
// We no longer have a pointer to the compositor thread, but we might
// still be running in the compositor thread. In we ever had a
// compositor thread, we logged the thread id in sProfilerThreadId,
// so we compare that value against the current thread id.
return (sProfilerThreadId == profiler_current_thread_id());
}
bool in = false;
MOZ_ALWAYS_SUCCEEDS(CompositorThread()->IsOnCurrentThread(&in));