Skip to content

Commit 3cab5ca

Browse files
committed
#5046 Fix accordion control's excessive rearranges #2
Since arrange is no longer part of LLInventoryItemsList::doIdle(), reduced time limit.
1 parent bc4492d commit 3cab5ca

File tree

6 files changed

+51
-6
lines changed

6 files changed

+51
-6
lines changed

indra/llui/llaccordionctrl.cpp

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ static constexpr F32 AUTO_SCROLL_RATE_ACCEL = 120.f;
4747

4848
static LLDefaultChildRegistry::Register<LLAccordionCtrl> t2("accordion");
4949

50+
std::set<LLAccordionCtrl*> LLAccordionCtrl::sPendingArrange;
51+
5052
LLAccordionCtrl::LLAccordionCtrl(const Params& params):LLPanel(params)
5153
, mFitParent(params.fit_parent)
5254
, mNoVisibleTabsOrigString(params.no_visible_tabs_text.initial_value().asString())
@@ -163,7 +165,11 @@ bool LLAccordionCtrl::postBuild()
163165
//---------------------------------------------------------------------------------
164166
LLAccordionCtrl::~LLAccordionCtrl()
165167
{
166-
mAccordionTabs.clear();
168+
if (mArrangePending)
169+
{
170+
sPendingArrange.erase(this);
171+
}
172+
mAccordionTabs.clear();
167173
}
168174

169175
//---------------------------------------------------------------------------------
@@ -184,7 +190,7 @@ void LLAccordionCtrl::reshape(S32 width, S32 height, bool called_from_parent)
184190
// necessary text paddings can be set via h_pad and v_pad
185191
mNoVisibleTabsHelpText->setRect(getLocalRect());
186192

187-
arrange();
193+
scheduleArrange();
188194
}
189195

190196
//---------------------------------------------------------------------------------
@@ -328,7 +334,7 @@ void LLAccordionCtrl::addCollapsibleCtrl(LLAccordionCtrlTab* accordion_tab)
328334
mAccordionTabs.push_back(accordion_tab);
329335

330336
accordion_tab->setDropDownStateChangedCallback( boost::bind(&LLAccordionCtrl::onCollapseCtrlCloseOpen, this, (S16)(mAccordionTabs.size() - 1)) );
331-
arrange();
337+
scheduleArrange();
332338
}
333339

334340
void LLAccordionCtrl::removeCollapsibleCtrl(LLAccordionCtrlTab* accordion_tab)
@@ -685,8 +691,9 @@ S32 LLAccordionCtrl::notifyParent(const LLSD& info)
685691
std::string str_action = info["action"];
686692
if (str_action == "size_changes")
687693
{
688-
//
689-
arrange();
694+
// Multiple children can request an arrange,
695+
// but only need to do it once so schedule it for later.
696+
scheduleArrange();
690697
return 1;
691698
}
692699
if (str_action == "select_next")
@@ -928,3 +935,25 @@ void LLAccordionCtrl::collapseAllTabs()
928935
arrange();
929936
}
930937
}
938+
939+
void LLAccordionCtrl::scheduleArrange()
940+
{
941+
if (!mArrangePending)
942+
{
943+
mArrangePending = true;
944+
sPendingArrange.insert(this);
945+
}
946+
}
947+
948+
void LLAccordionCtrl::updateClass()
949+
{
950+
for (LLAccordionCtrl* inst : sPendingArrange)
951+
{
952+
if (inst)
953+
{
954+
inst->mArrangePending = false;
955+
inst->arrange();
956+
}
957+
}
958+
sPendingArrange.clear();
959+
}

indra/llui/llaccordionctrl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ class LLAccordionCtrl: public LLPanel
142142

143143
void setSkipScrollToChild(bool skip) { mSkipScrollToChild = skip; }
144144

145+
void scheduleArrange();
146+
static void updateClass();
147+
145148
private:
146149
void initNoTabsWidget(const LLTextBox::Params& tb_params);
147150
void updateNoTabsHelpTextVisibility();
@@ -188,12 +191,15 @@ class LLAccordionCtrl: public LLPanel
188191
LLTextBox* mNoVisibleTabsHelpText = nullptr;
189192

190193
bool mSkipScrollToChild = false;
194+
bool mArrangePending = false;
191195

192196
std::string mNoMatchedTabsOrigString;
193197
std::string mNoVisibleTabsOrigString;
194198

195199
LLAccordionCtrlTab* mSelectedTab = nullptr;
196200
const LLTabComparator* mTabComparator = nullptr;
201+
202+
static std::set<LLAccordionCtrl*> sPendingArrange;
197203
};
198204

199205

indra/newview/llinventoryitemslist.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ void LLInventoryItemsList::updateSelection()
145145
bool LLInventoryItemsList::doIdle()
146146
{
147147
if (mRefreshState == REFRESH_COMPLETE) return true; // done
148+
LL_PROFILE_ZONE_SCOPED;
148149

149150
if (isInVisibleChain() || mForceRefresh || !getFilterSubString().empty())
150151
{
@@ -166,7 +167,7 @@ void LLInventoryItemsList::idle(void* user_data)
166167

167168
using namespace std::chrono;
168169
auto start = steady_clock::now();
169-
const milliseconds time_limit = milliseconds(3);
170+
const milliseconds time_limit = milliseconds(2);
170171
const auto end_time = start + time_limit;
171172
S32 max_update_count = 50;
172173

indra/newview/llinventorylistitem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ LLPanelInventoryListItemBase::Params::Params()
6969

7070
LLPanelInventoryListItemBase* LLPanelInventoryListItemBase::create(LLViewerInventoryItem* item)
7171
{
72+
LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
7273
LLPanelInventoryListItemBase* list_item = NULL;
7374
if (item)
7475
{
@@ -189,6 +190,7 @@ void LLPanelInventoryListItemBase::setShowWidget(LLUICtrl* ctrl, bool show)
189190

190191
bool LLPanelInventoryListItemBase::postBuild()
191192
{
193+
LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
192194
LLViewerInventoryItem* inv_item = getItem();
193195
if (inv_item)
194196
{

indra/newview/lloutfitslist.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,10 @@ void LLOutfitsList::onRefreshComplete(LLUICtrl* ctrl)
568568
if (!ctrl || getFilterSubString().empty())
569569
return;
570570

571+
LL_PROFILE_ZONE_SCOPED;
572+
573+
// TODO: We are doing it multiple times per frame on init
574+
// as multiple lists are refreshing. Needs improvements.
571575
for (outfits_map_t::iterator
572576
iter = mOutfitsMap.begin(),
573577
iter_end = mOutfitsMap.end();

indra/newview/llviewerwindow.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#include "raytrace.h"
8787

8888
// newview includes
89+
#include "llaccordionctrl.h"
8990
#include "llbox.h"
9091
#include "llchicletbar.h"
9192
#include "llconsole.h"
@@ -3440,6 +3441,8 @@ void LLViewerWindow::updateUI()
34403441

34413442
LLConsole::updateClass();
34423443

3444+
// execute postponed arrange calls
3445+
LLAccordionCtrl::updateClass();
34433446
// animate layout stacks so we have up to date rect for world view
34443447
LLLayoutStack::updateClass();
34453448

0 commit comments

Comments
 (0)