Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions indra/newview/llaisapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,13 @@ void AISAPI::InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t ht
U32 AISUpdate::sBatchFrameCount = 0;
LLTimer AISUpdate::sBatchTimer;

// Coalesces the deferred gInventory::notifyObservers() calls issued below
// when the change backlog exceeds MAX_UPDATE_BACKLOG, so repeated iterations
// while the backlog remains large don't flood gMainloopWork with duplicate
// postToMainCoro callbacks. Cleared once the posted callback actually runs
// notifyObservers().
static bool sAISNotifyObserversPending = false;

AISUpdate::AISUpdate(const LLSD& update, AISAPI::COMMAND_TYPE type, const LLSD& request_body)
: mType(type)
{
Expand Down Expand Up @@ -1683,7 +1690,16 @@ void AISUpdate::doUpdate()
// fetching can receive massive amount of items and folders
if (gInventory.getChangedIDs().size() > MAX_UPDATE_BACKLOG)
{
gInventory.notifyObservers();
if (!sAISNotifyObserversPending)
{
sAISNotifyObserversPending = true;
LLAppViewer::instance()->postToMainCoro(
[]()
{
gInventory.notifyObservers();
sAISNotifyObserversPending = false;
});
}
checkTimeout();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
Expand Down Expand Up @@ -1744,7 +1760,16 @@ void AISUpdate::doUpdate()
// fetching can receive massive amount of items and folders
if (gInventory.getChangedIDs().size() > MAX_UPDATE_BACKLOG)
{
gInventory.notifyObservers();
if (!sAISNotifyObserversPending)
{
sAISNotifyObserversPending = true;
LLAppViewer::instance()->postToMainCoro(
[]()
{
gInventory.notifyObservers();
sAISNotifyObserversPending = false;
});
}
checkTimeout();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
Expand Down Expand Up @@ -1815,6 +1840,9 @@ void AISUpdate::doUpdate()

checkTimeout();

gInventory.notifyObservers();
LLAppViewer::instance()->postToMainCoro(
[]()
{
gInventory.notifyObservers();
});
}