mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Avoid using global Mutex variables (#1252)
After 5c9815f, some Mutexes are used as global C++ variables which are loaded before main(). Since the Mutex constructor checks for unfair lock experiment, it triggers an experiment configuration load, and our app isn't ready to respond that early in the process.
This commit is contained in:
@@ -34,9 +34,13 @@
|
||||
|
||||
{
|
||||
if (self = [super init]) {
|
||||
static dispatch_once_t onceToken;
|
||||
static ASDN::Mutex *mutex;
|
||||
dispatch_once(&onceToken, ^{
|
||||
mutex = new ASDN::Mutex();
|
||||
});
|
||||
|
||||
// Concurrently initialising TextKit components crashes (rdar://18448377) so we use a global lock.
|
||||
// Allocate mutex on the heap to prevent destruction at app exit (https://github.com/TextureGroup/Texture/issues/136)
|
||||
static auto *mutex = new ASDN::Mutex;
|
||||
ASDN::MutexLocker l(*mutex);
|
||||
|
||||
__instanceLock__ = std::make_shared<ASDN::Mutex>();
|
||||
|
||||
Reference in New Issue
Block a user