Skip to content
Open
Show file tree
Hide file tree
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
35 changes: 31 additions & 4 deletions indra/newview/llaisapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,27 @@ 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;

static void aisScheduleNotifyObservers()
{
if (!sAISNotifyObserversPending)
{
sAISNotifyObserversPending = true;
LLAppViewer::instance()->postToMainCoro(
[]()
{
gInventory.notifyObservers();
sAISNotifyObserversPending = false;
});
}
}

AISUpdate::AISUpdate(const LLSD& update, AISAPI::COMMAND_TYPE type, const LLSD& request_body)
: mType(type)
{
Expand Down Expand Up @@ -1683,7 +1704,7 @@ void AISUpdate::doUpdate()
// fetching can receive massive amount of items and folders
if (gInventory.getChangedIDs().size() > MAX_UPDATE_BACKLOG)
{
gInventory.notifyObservers();
aisScheduleNotifyObservers();
checkTimeout();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
Expand Down Expand Up @@ -1744,7 +1765,7 @@ void AISUpdate::doUpdate()
// fetching can receive massive amount of items and folders
if (gInventory.getChangedIDs().size() > MAX_UPDATE_BACKLOG)
{
gInventory.notifyObservers();
aisScheduleNotifyObservers();
checkTimeout();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
Expand Down Expand Up @@ -1815,6 +1836,12 @@ void AISUpdate::doUpdate()

checkTimeout();

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

5 changes: 4 additions & 1 deletion indra/newview/llinventorymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,10 @@ void LLInventoryModel::deleteObject(const LLUUID& id, bool fix_broken_links, boo

// Note : We need to tell the inventory observers that those things are going to be deleted *before* the tree is cleared or they won't know what to delete (in views and view models)
addChangedMask(LLInventoryObserver::REMOVE, id);
gInventory.notifyObservers();
if (do_notify_observers)
{
notifyObservers();
}

if (item_array_t* item_list = getUnlockedItemArray(id))
{
Expand Down