PresentDrawable was moved to main thread by default in google#7535 and stopped most crashes when a drawable is released. But there still appears to be crashes if a drawable is released on main thread at the same time that -nextDrawable is called from the Filament render thread. (It's likely that the drawable pool in CAMetalLayer is completely non-thread-safe.)
So, add a mutex to the swapchain and always acquire it before creating or releasing a CAMetalDrawable.
PresentDrawable was moved to main thread by default in google#7535 and stopped most crashes when a drawable is released. But there still appears to be crashes if a drawable is released on main thread at the same time that -nextDrawable is called from the Filament render thread. (It's likely that the drawable pool in CAMetalLayer is completely non-thread-safe.)
So, add a mutex to the swapchain and always acquire it before creating or releasing a CAMetalDrawable.