SL-14988 Viewer freezes when opening any CEF based window

Don't block main thread if possible
master
Andrey Kleshchev 2021-05-21 19:06:11 +03:00
parent cb8b5f6ba6
commit fa26f5eaa2
1 changed files with 8 additions and 4 deletions

View File

@ -320,8 +320,9 @@ void LLPluginProcessParent::idle(void)
do
{
// process queued messages
mIncomingQueueMutex.lock();
while(!mIncomingQueue.empty())
// Inside main thread, it is preferable not to block it on mutex.
bool locked = mIncomingQueueMutex.trylock();
while(locked && !mIncomingQueue.empty())
{
LLPluginMessage message = mIncomingQueue.front();
mIncomingQueue.pop();
@ -329,10 +330,13 @@ void LLPluginProcessParent::idle(void)
receiveMessage(message);
mIncomingQueueMutex.lock();
locked = mIncomingQueueMutex.trylock();
}
mIncomingQueueMutex.unlock();
if (locked)
{
mIncomingQueueMutex.unlock();
}
// Give time to network processing
if(mMessagePipe)