From 34f561c853fd672309aee340b8b0c4e3e9ed6196 Mon Sep 17 00:00:00 2001 From: William Todd Stinson Date: Thu, 1 Nov 2012 17:49:49 -0700 Subject: NORSPEC-8: Adding ability to parse GET data over multiple frames to avoid viewer timeout and crash on regions with large numbers of materials. --- indra/newview/llfloaterdebugmaterials.cpp | 137 ++++++++++++++++----- indra/newview/llfloaterdebugmaterials.h | 12 +- .../default/xui/en/floater_debug_materials.xml | 63 +++++++--- 3 files changed, 167 insertions(+), 45 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterdebugmaterials.cpp b/indra/newview/llfloaterdebugmaterials.cpp index 24a6a79d63..5bb4aa93d4 100644 --- a/indra/newview/llfloaterdebugmaterials.cpp +++ b/indra/newview/llfloaterdebugmaterials.cpp @@ -45,6 +45,7 @@ #include "llhttpclient.h" #include "lllineeditor.h" #include "llmaterialid.h" +#include "llresmgr.h" #include "llscrolllistcell.h" #include "llscrolllistctrl.h" #include "llscrolllistitem.h" @@ -125,6 +126,9 @@ BOOL LLFloaterDebugMaterials::postBuild() llassert(mGetButton != NULL); mGetButton->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onGetClicked, this)); + mParsingStatusText = findChild("loading_status"); + llassert(mParsingStatusText != NULL); + mGetNormalMapScrollList = findChild("get_normal_map_scroll_list"); llassert(mGetNormalMapScrollList != NULL); mGetNormalMapScrollList->setCommitCallback(boost::bind(&LLFloaterDebugMaterials::onGetScrollListSelectionChange, this, _1)); @@ -321,10 +325,20 @@ void LLFloaterDebugMaterials::onClose(bool pIsAppQuitting) LLFloater::onClose(pIsAppQuitting); } +void LLFloaterDebugMaterials::draw() +{ + if (mUnparsedGetData.isDefined()) + { + parseGetResponse(); + } + LLFloater::draw(); +} + LLFloaterDebugMaterials::LLFloaterDebugMaterials(const LLSD& pParams) : LLFloater(pParams), mStatusText(NULL), mGetButton(NULL), + mParsingStatusText(NULL), mGetNormalMapScrollList(NULL), mGetSpecularMapScrollList(NULL), mGetOtherDataScrollList(NULL), @@ -361,7 +375,9 @@ LLFloaterDebugMaterials::LLFloaterDebugMaterials(const LLSD& pParams) mErrorColor(), mRegionCrossConnection(), mTeleportFailedConnection(), - mSelectionUpdateConnection() + mSelectionUpdateConnection(), + mUnparsedGetData(), + mNextUnparsedGetDataIndex(-1) { } @@ -500,10 +516,11 @@ void LLFloaterDebugMaterials::onDeferredRequestPostMaterials(LLUUID regionId, bo void LLFloaterDebugMaterials::onGetResponse(bool pRequestStatus, const LLSD& pContent) { + clearGetResults(); if (pRequestStatus) { setState(kRequestCompleted); - parseGetResponse(pContent); + setUnparsedGetData(pContent); } else { @@ -887,35 +904,31 @@ void LLFloaterDebugMaterials::queryViewableObjects() } } -void LLFloaterDebugMaterials::parseGetResponse(const LLSD& pContent) +void LLFloaterDebugMaterials::parseGetResponse() { - clearGetResults(); - - LLScrollListCell::Params cellParams; - LLScrollListItem::Params normalMapRowParams; - LLScrollListItem::Params specularMapRowParams; - LLScrollListItem::Params otherDataRowParams; - - llassert(pContent.isMap()); - llassert(pContent.has(MATERIALS_CAP_ZIP_FIELD)); - llassert(pContent.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); - - LLSD::Binary responseBinary = pContent.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); - S32 responseSize = static_cast(responseBinary.size()); - std::string responseString(reinterpret_cast(responseBinary.data()), responseSize); - - std::istringstream responseStream(responseString); + llassert(mUnparsedGetData.isDefined()); + llassert(mNextUnparsedGetDataIndex >= 0); - LLSD responseContent; - if (!unzip_llsd(responseContent, responseStream, responseSize)) - { - LL_ERRS("debugMaterials") << "cannot unzip LLSD binary content" << LL_ENDL; - } - else + if (mUnparsedGetData.isDefined()) { - llassert(responseContent.isArray()); - for (LLSD::array_const_iterator materialIter = responseContent.beginArray(); materialIter != responseContent.endArray(); - ++materialIter) + LLScrollListCell::Params cellParams; + LLScrollListItem::Params normalMapRowParams; + LLScrollListItem::Params specularMapRowParams; + LLScrollListItem::Params otherDataRowParams; + + llassert(mUnparsedGetData.isArray()); + LLSD::array_const_iterator materialIter = mUnparsedGetData.beginArray(); + S32 materialIndex; + + for (materialIndex = 0; + (materialIndex < mNextUnparsedGetDataIndex) && (materialIter != mUnparsedGetData.endArray()); + ++materialIndex, ++materialIter) + { + } + + for (S32 currentParseCount = 0; + (currentParseCount < 10) && (materialIter != mUnparsedGetData.endArray()); + ++currentParseCount, ++materialIndex, ++materialIter) { const LLSD &material = *materialIter; llassert(material.isMap()); @@ -1088,6 +1101,16 @@ void LLFloaterDebugMaterials::parseGetResponse(const LLSD& pContent) mGetSpecularMapScrollList->addRow(specularMapRowParams); mGetOtherDataScrollList->addRow(otherDataRowParams); } + + if (materialIter != mUnparsedGetData.endArray()) + { + mNextUnparsedGetDataIndex = materialIndex; + updateGetParsingStatus(); + } + else + { + clearUnparsedGetData(); + } } } @@ -1290,6 +1313,7 @@ void LLFloaterDebugMaterials::clearGetResults() mGetNormalMapScrollList->deleteAllItems(); mGetSpecularMapScrollList->deleteAllItems(); mGetOtherDataScrollList->deleteAllItems(); + clearUnparsedGetData(); } void LLFloaterDebugMaterials::clearPutResults() @@ -1309,6 +1333,63 @@ void LLFloaterDebugMaterials::clearViewableObjectsResults() mViewableObjectsScrollList->deleteAllItems(); } +void LLFloaterDebugMaterials::setUnparsedGetData(const LLSD& pGetData) +{ + llassert(pGetData.isMap()); + llassert(pGetData.has(MATERIALS_CAP_ZIP_FIELD)); + llassert(pGetData.get(MATERIALS_CAP_ZIP_FIELD).isBinary()); + + LLSD::Binary getDataBinary = pGetData.get(MATERIALS_CAP_ZIP_FIELD).asBinary(); + S32 getDataSize = static_cast(getDataBinary.size()); + std::string getDataString(reinterpret_cast(getDataBinary.data()), getDataSize); + + std::istringstream getDataStream(getDataString); + + llassert(!mUnparsedGetData.isDefined()); + if (!unzip_llsd(mUnparsedGetData, getDataStream, getDataSize)) + { + LL_ERRS("debugMaterials") << "cannot unzip LLSD binary content" << LL_ENDL; + } + mNextUnparsedGetDataIndex = 0; + + updateGetParsingStatus(); +} + +void LLFloaterDebugMaterials::clearUnparsedGetData() +{ + mUnparsedGetData.clear(); + mNextUnparsedGetDataIndex = -1; + + updateGetParsingStatus(); +} + +void LLFloaterDebugMaterials::updateGetParsingStatus() +{ + std::string parsingStatus; + + if (mUnparsedGetData.isDefined()) + { + LLLocale locale(LLStringUtil::getLocale()); + std::string numProcessedString; + LLResMgr::getInstance()->getIntegerString(numProcessedString, mNextUnparsedGetDataIndex); + + std::string numTotalString; + LLResMgr::getInstance()->getIntegerString(numTotalString, mUnparsedGetData.size()); + + LLStringUtil::format_map_t stringArgs; + stringArgs["[NUM_PROCESSED]"] = numProcessedString; + stringArgs["[NUM_TOTAL]"] = numTotalString; + + parsingStatus = getString("loading_status_in_progress", stringArgs); + } + else + { + parsingStatus = getString("loading_status_done"); + } + + mParsingStatusText->setText(static_cast(parsingStatus)); +} + void LLFloaterDebugMaterials::updateStatusMessage() { std::string statusText; diff --git a/indra/newview/llfloaterdebugmaterials.h b/indra/newview/llfloaterdebugmaterials.h index 63fa481800..b3983ecd6c 100644 --- a/indra/newview/llfloaterdebugmaterials.h +++ b/indra/newview/llfloaterdebugmaterials.h @@ -55,6 +55,8 @@ public: virtual void onOpen(const LLSD& pKey); virtual void onClose(bool pIsAppQuitting); + virtual void draw(); + protected: private: @@ -106,7 +108,7 @@ private: void queryViewableObjects(); - void parseGetResponse(const LLSD& pContent); + void parseGetResponse(); void parsePutResponse(const LLSD& pContent); void parsePostResponse(const LLSD& pContent); @@ -119,6 +121,10 @@ private: void clearPostResults(); void clearViewableObjectsResults(); + void setUnparsedGetData(const LLSD& pGetData); + void clearUnparsedGetData(); + void updateGetParsingStatus(); + void updateStatusMessage(); void updateControls(); std::string convertToPrintableMaterialID(const LLSD& pBinaryHash) const; @@ -145,6 +151,7 @@ private: LLTextBase* mStatusText; LLButton* mGetButton; + LLTextBase* mParsingStatusText; LLScrollListCtrl* mGetNormalMapScrollList; LLScrollListCtrl* mGetSpecularMapScrollList; LLScrollListCtrl* mGetOtherDataScrollList; @@ -186,6 +193,9 @@ private: boost::signals2::connection mRegionCrossConnection; boost::signals2::connection mTeleportFailedConnection; boost::signals2::connection mSelectionUpdateConnection; + + LLSD mUnparsedGetData; + S32 mNextUnparsedGetDataIndex; }; diff --git a/indra/newview/skins/default/xui/en/floater_debug_materials.xml b/indra/newview/skins/default/xui/en/floater_debug_materials.xml index 504a52e762..cdc1e63ce1 100644 --- a/indra/newview/skins/default/xui/en/floater_debug_materials.xml +++ b/indra/newview/skins/default/xui/en/floater_debug_materials.xml @@ -4,9 +4,9 @@ can_tear_off="false" can_resize="true" height="725" - width="1030" + width="1040" min_height="750" - min_width="1030" + min_width="1040" layout="topleft" name="floater_debug_materials" reuse_instance="true" @@ -20,6 +20,8 @@ Request received. Materials are not enabled for this region. An error occurred during the request. + Processing [NUM_PROCESSED] out of [NUM_TOTAL] + Complete + width="1020"> + width="1020"> + width="1020">