Skip to content

Commit

Permalink
don't use a spinlock for the HandleArena
Browse files Browse the repository at this point in the history
We've seen hangs/ANR that are not well understood on that spinlock, so
for now we're going back to mutexes, which, on android, are very 
efficient under low contention (no syscall).

FIXES=[308029108]
  • Loading branch information
pixelflinger committed Oct 27, 2023
1 parent 8aeec2b commit 4d8e6ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions filament/backend/include/private/backend/HandleAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,16 @@ class HandleAllocator {
}
};


// FIXME: We should be using a Spinlock here, at least on platforms where mutexes are not
// efficient (i.e. non-Linux). However, we've seen some hangs on that spinlock, which
// we don't understand well (b/308029108).
#ifndef NDEBUG
using HandleArena = utils::Arena<Allocator,
utils::LockingPolicy::SpinLock,
utils::LockingPolicy::Mutex,
utils::TrackingPolicy::DebugAndHighWatermark>;
#else
using HandleArena = utils::Arena<Allocator,
utils::LockingPolicy::SpinLock>;
utils::LockingPolicy::Mutex>;
#endif

// allocateHandle()/deallocateHandle() selects the pool to use at compile-time based on the
Expand Down
2 changes: 1 addition & 1 deletion filament/src/details/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ class FEngine : public Engine {
ResourceList<FRenderTarget> mRenderTargets{ "RenderTarget" };

// the fence list is accessed from multiple threads
utils::SpinLock mFenceListLock;
utils::Mutex mFenceListLock;
ResourceList<FFence> mFences{"Fence"};

mutable uint32_t mMaterialId = 0;
Expand Down

0 comments on commit 4d8e6ee

Please sign in to comment.