fix crashes and flaws for SH-3086

meow-7.2.2
Xiaohong Bao 2012-05-04 18:16:37 -06:00
parent c143a4f87e
commit 0afca8603a
6 changed files with 208 additions and 104 deletions

View File

@ -67,6 +67,7 @@ LLFloaterTextureFetchDebugger::LLFloaterTextureFetchDebugger(const LLSD& key)
BOOL LLFloaterTextureFetchDebugger::postBuild(void)
{
mDebugger = LLAppViewer::getTextureFetch()->getFetchDebugger();
mStartStatus = (S32)LLTextureFetchDebugger::IDLE;
//set states for buttons
mButtonStateMap["start_btn"] = true;
@ -93,7 +94,7 @@ BOOL LLFloaterTextureFetchDebugger::postBuild(void)
LLFloaterTextureFetchDebugger::~LLFloaterTextureFetchDebugger()
{
//stop everything
mDebugger->stopDebug();
mDebugger->setStopDebug();
}
void LLFloaterTextureFetchDebugger::updateButtons()
@ -125,11 +126,69 @@ void LLFloaterTextureFetchDebugger::disableButtons()
childDisable("refetchallcache_btn");
childDisable("refetchallhttp_btn");
}
void LLFloaterTextureFetchDebugger::setStartStatus(S32 status)
{
llassert_always(LLTextureFetchDebugger::IDLE == (LLTextureFetchDebugger::e_debug_state)mStartStatus) ;
mStartStatus = status;
}
bool LLFloaterTextureFetchDebugger::idleStart()
{
switch((LLTextureFetchDebugger::e_debug_state)mStartStatus)
{
case LLTextureFetchDebugger::IDLE:
break;
case LLTextureFetchDebugger::START_DEBUG:
mDebugger->startDebug();
break;
case LLTextureFetchDebugger::READ_CACHE:
mDebugger->debugCacheRead();
break;
case LLTextureFetchDebugger::WRITE_CACHE:
mDebugger->debugCacheWrite();
break;
case LLTextureFetchDebugger::DECODING:
mDebugger->debugDecoder();
break;
case LLTextureFetchDebugger::HTTP_FETCHING:
mDebugger->debugHTTP();
break;
case LLTextureFetchDebugger::GL_TEX:
mDebugger->debugGLTextureCreation();
break;
case LLTextureFetchDebugger::REFETCH_VIS_CACHE:
mDebugger->debugRefetchVisibleFromCache();
break;
case LLTextureFetchDebugger::REFETCH_VIS_HTTP:
mDebugger->debugRefetchVisibleFromHTTP();
break;
case LLTextureFetchDebugger::REFETCH_ALL_CACHE:
mDebugger->debugRefetchAllFromCache();
break;
case LLTextureFetchDebugger::REFETCH_ALL_HTTP:
mDebugger->debugRefetchAllFromHTTP();
break;
default:
break;
}
if(mStartStatus != (S32)LLTextureFetchDebugger::IDLE)
{
mStartStatus = (S32)LLTextureFetchDebugger::IDLE;
return true;
}
return false;
}
void LLFloaterTextureFetchDebugger::idle()
{
LLTextureFetchDebugger::e_debug_state state = mDebugger->getState();
if(idleStart())
{
return;
}
LLTextureFetchDebugger::e_debug_state state = mDebugger->getState();
if(mDebugger->update())
{
switch(state)
@ -137,38 +196,36 @@ void LLFloaterTextureFetchDebugger::idle()
case LLTextureFetchDebugger::IDLE:
break;
case LLTextureFetchDebugger::READ_CACHE:
mButtonStateMap["decode_btn"] = true;
updateButtons();
mButtonStateMap["decode_btn"] = true;
break;
case LLTextureFetchDebugger::WRITE_CACHE:
updateButtons();
case LLTextureFetchDebugger::WRITE_CACHE:
break;
case LLTextureFetchDebugger::DECODING:
mButtonStateMap["gl_btn"] = true;
updateButtons();
mButtonStateMap["gl_btn"] = true;
break;
case LLTextureFetchDebugger::HTTP_FETCHING:
mButtonStateMap["cacheread_btn"] = true;
mButtonStateMap["cachewrite_btn"] = true;
mButtonStateMap["decode_btn"] = true;
updateButtons();
mButtonStateMap["decode_btn"] = true;
break;
case LLTextureFetchDebugger::GL_TEX:
updateButtons();
case LLTextureFetchDebugger::GL_TEX:
break;
case LLTextureFetchDebugger::REFETCH_VIS_CACHE:
updateButtons();
case LLTextureFetchDebugger::REFETCH_VIS_HTTP:
updateButtons();
case LLTextureFetchDebugger::REFETCH_VIS_CACHE:
break;
case LLTextureFetchDebugger::REFETCH_VIS_HTTP:
break;
case LLTextureFetchDebugger::REFETCH_ALL_CACHE:
break;
case LLTextureFetchDebugger::REFETCH_ALL_CACHE:
updateButtons();
case LLTextureFetchDebugger::REFETCH_ALL_HTTP:
updateButtons();
break;
default:
break;
}
if(state != LLTextureFetchDebugger::IDLE)
{
updateButtons();
}
}
}
@ -182,21 +239,21 @@ void LLFloaterTextureFetchDebugger::onClickStart()
{
disableButtons();
mDebugger->startDebug();
setStartStatus((S32)LLTextureFetchDebugger::START_DEBUG);
mButtonStateMap["start_btn"] = false;
if(LLAppViewer::getTextureFetch()->canLoadFromCache())
{
mButtonStateMap["cacheread_btn"] = true;
mButtonStateMap["http_btn"] = false;
mButtonStateMap["refetchviscache_btn"] = true;
mButtonStateMap["refetchvishttp_btn"] = false;
mButtonStateMap["refetchallcache_btn"] = true;
mButtonStateMap["refetchallhttp_btn"] = false;
mButtonStateMap["cachewrite_btn"] = false;
}
else
//if(LLAppViewer::getTextureFetch()->canLoadFromCache())
//{
// mButtonStateMap["cacheread_btn"] = true;
// mButtonStateMap["http_btn"] = false;
// mButtonStateMap["refetchviscache_btn"] = true;
// mButtonStateMap["refetchvishttp_btn"] = false;
// mButtonStateMap["refetchallcache_btn"] = true;
// mButtonStateMap["refetchallhttp_btn"] = false;
// mButtonStateMap["cachewrite_btn"] = false;
//}
//else
{
mButtonStateMap["cacheread_btn"] = true;
mButtonStateMap["http_btn"] = true;
@ -214,7 +271,9 @@ void LLFloaterTextureFetchDebugger::onClickClose()
setVisible(FALSE);
//stop everything
mDebugger->stopDebug();
mDebugger->setStopDebug();
delete this;
}
void LLFloaterTextureFetchDebugger::onClickClear()
@ -232,7 +291,7 @@ void LLFloaterTextureFetchDebugger::onClickClear()
updateButtons();
//stop everything
mDebugger->stopDebug();
mDebugger->setStopDebug();
mDebugger->clearHistory();
}
@ -240,63 +299,63 @@ void LLFloaterTextureFetchDebugger::onClickCacheRead()
{
disableButtons();
mDebugger->debugCacheRead();
setStartStatus((S32)LLTextureFetchDebugger::READ_CACHE);
}
void LLFloaterTextureFetchDebugger::onClickCacheWrite()
{
disableButtons();
mDebugger->debugCacheWrite();
setStartStatus((S32)LLTextureFetchDebugger::WRITE_CACHE);
}
void LLFloaterTextureFetchDebugger::onClickHTTPLoad()
{
disableButtons();
mDebugger->debugHTTP();
setStartStatus((S32)LLTextureFetchDebugger::HTTP_FETCHING);
}
void LLFloaterTextureFetchDebugger::onClickDecode()
{
disableButtons();
mDebugger->debugDecoder();
setStartStatus((S32)LLTextureFetchDebugger::DECODING);
}
void LLFloaterTextureFetchDebugger::onClickGLTexture()
{
disableButtons();
mDebugger->debugGLTextureCreation();
setStartStatus((S32)LLTextureFetchDebugger::GL_TEX);
}
void LLFloaterTextureFetchDebugger::onClickRefetchVisCache()
{
disableButtons();
mDebugger->debugRefetchVisibleFromCache();
setStartStatus((S32)LLTextureFetchDebugger::REFETCH_VIS_CACHE);
}
void LLFloaterTextureFetchDebugger::onClickRefetchVisHTTP()
{
disableButtons();
mDebugger->debugRefetchVisibleFromHTTP();
setStartStatus((S32)LLTextureFetchDebugger::REFETCH_VIS_HTTP);
}
void LLFloaterTextureFetchDebugger::onClickRefetchAllCache()
{
disableButtons();
mDebugger->debugRefetchAllFromCache();
setStartStatus((S32)LLTextureFetchDebugger::REFETCH_ALL_CACHE);
}
void LLFloaterTextureFetchDebugger::onClickRefetchAllHTTP()
{
disableButtons();
mDebugger->debugRefetchAllFromHTTP();
setStartStatus((S32)LLTextureFetchDebugger::REFETCH_ALL_HTTP);
}
void LLFloaterTextureFetchDebugger::draw()

View File

@ -65,9 +65,12 @@ private:
void updateButtons();
void disableButtons();
void setStartStatus(S32 status);
bool idleStart();
private:
LLTextureFetchDebugger* mDebugger;
std::map<std::string, bool> mButtonStateMap;
S32 mStartStatus;
};
#endif // LL_FLOATER_TEXTURE_FETCH_DEBUGGER__H

View File

@ -695,7 +695,7 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher,
mMetricsStartTime(0)
{
mCanUseNET = mUrl.empty() ;
calcWorkPriority();
mType = host.isOk() ? LLImageBase::TYPE_AVATAR_BAKE : LLImageBase::TYPE_NORMAL;
// llinfos << "Create: " << mID << " mHost:" << host << " Discard=" << discard << llendl;
@ -953,7 +953,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
offset, size, responder);
mCacheReadTimer.reset();
}
else if(!mUrl.empty() && mCanUseHTTP && mFetcher->canLoadFromNetwork())
else if(!mUrl.empty() && mCanUseHTTP)
{
if (!(mUrl.compare(0, 7, "http://") == 0))
{
@ -963,15 +963,11 @@ bool LLTextureFetchWorker::doWork(S32 param)
setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
mState = SEND_HTTP_REQ;
}
else if(mFetcher->canLoadFromNetwork())
else
{
setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
mState = LOAD_FROM_NETWORK;
}
else
{
return true; //failed
}
}
if (mLoaded)
@ -1019,15 +1015,12 @@ bool LLTextureFetchWorker::doWork(S32 param)
return true;
}
// need more data
else if(mFetcher->canLoadFromNetwork())
else
{
LL_DEBUGS("Texture") << mID << ": Not in Cache" << LL_ENDL;
mState = LOAD_FROM_NETWORK;
}
else
{
return true; //failed
}
// fall through
LLTextureFetch::sCacheHitRate.addValue(0.f);
}
@ -2306,6 +2299,10 @@ S32 LLTextureFetch::update(F32 max_time_ms)
commonUpdate();
}
if(mFetchDebugger)
{
mFetchDebugger->tryToStopDebug(); //check if need to stop debugger.
}
return res;
}
@ -3192,7 +3189,8 @@ LLTextureFetchDebugger::LLTextureFetchDebugger(LLTextureFetch* fetcher, LLTextur
LLTextureFetchDebugger::~LLTextureFetchDebugger()
{
mFetchingHistory.clear();
stopDebug();
mStopDebug = TRUE;
tryToStopDebug();
}
void LLTextureFetchDebugger::init()
@ -3228,6 +3226,8 @@ void LLTextureFetchDebugger::init()
mRefetchedAllPixels = 0;
mFreezeHistory = FALSE;
mStopDebug = FALSE;
mClearHistory = FALSE;
}
void LLTextureFetchDebugger::startDebug()
@ -3235,6 +3235,7 @@ void LLTextureFetchDebugger::startDebug()
//lock the fetcher
mFetcher->lockFetcher(true);
mFreezeHistory = TRUE;
mFetcher->resetLoadSource();
//clear the current fetching queue
gTextureList.clearFetchingRequests();
@ -3290,8 +3291,13 @@ void LLTextureFetchDebugger::startDebug()
mNumFetchedTextures = fetched_textures.size();
}
void LLTextureFetchDebugger::stopDebug()
void LLTextureFetchDebugger::tryToStopDebug()
{
if(!mStopDebug)
{
return;
}
//clear the current debug work
S32 size = mFetchingHistory.size();
switch(mState)
@ -3320,35 +3326,50 @@ void LLTextureFetchDebugger::stopDebug()
break;
case GL_TEX:
break;
case REFETCH_VIS_CACHE:
break;
case REFETCH_VIS_HTTP:
break;
case REFETCH_ALL_CACHE:
mRefetchList.clear();
break;
case REFETCH_ALL_HTTP:
mRefetchList.clear();
break;
default:
break;
}
while(1)
if(update())
{
if(update())
//unlock the fetcher
mFetcher->lockFetcher(false);
mFetcher->resetLoadSource();
mFreezeHistory = FALSE;
mStopDebug = FALSE;
if(mClearHistory)
{
break;
mFetchingHistory.clear();
init();
mTotalFetchingTime = gDebugTimers[0].getElapsedTimeF32(); //reset
}
}
//unlock the fetcher
mFetcher->lockFetcher(false);
mFetcher->resetLoadSource();
mFreezeHistory = FALSE;
mTotalFetchingTime = gDebugTimers[0].getElapsedTimeF32(); //reset
mRefetchList.clear();
}
//called in the main thread and when the fetching queue is empty
void LLTextureFetchDebugger::clearHistory()
{
mFetchingHistory.clear();
init();
mClearHistory = TRUE;
}
void LLTextureFetchDebugger::addHistoryEntry(LLTextureFetchWorker* worker)
{
if(worker->mRawImage.isNull() || worker->mFormattedImage.isNull())
{
return;
}
if(mFreezeHistory)
{
if(mState == REFETCH_VIS_CACHE || mState == REFETCH_VIS_HTTP)
@ -3517,6 +3538,12 @@ void LLTextureFetchDebugger::debugHTTP()
S32 LLTextureFetchDebugger::fillCurlQueue()
{
if(mStopDebug) //stop
{
mNbCurlCompleted = mFetchingHistory.size();
return 0;
}
if (mNbCurlRequests == 24)
return mNbCurlRequests;
@ -3624,6 +3651,15 @@ void LLTextureFetchDebugger::makeRefetchList()
void LLTextureFetchDebugger::scanRefetchList()
{
if(mStopDebug)
{
return;
}
if(!mRefetchNonVis)
{
return;
}
for(std::map< LLPointer<LLViewerFetchedTexture>, std::vector<S32> >::iterator iter = mRefetchList.begin();
iter != mRefetchList.end(); )
{
@ -3646,14 +3682,13 @@ void LLTextureFetchDebugger::debugRefetchVisibleFromCache()
mState = REFETCH_VIS_CACHE;
clearTextures();
mFetcher->setLoadSource(LLTextureFetch::FROM_CACHE_ONLY);
mFetcher->setLoadSource(LLTextureFetch::FROM_ALL);
mTimer.reset();
mFetcher->lockFetcher(false);
mRefetchVisCacheTime = -1.f;
mRefetchedVisData = 0;
mRefetchedVisPixels = 0;
mRefetchStartTime = gDebugTimers[0].getElapsedTimeF32();
}
void LLTextureFetchDebugger::debugRefetchVisibleFromHTTP()
@ -3661,16 +3696,14 @@ void LLTextureFetchDebugger::debugRefetchVisibleFromHTTP()
llassert_always(mState == IDLE);
mState = REFETCH_VIS_HTTP;
clearCache();
clearTextures();
mFetcher->setLoadSource(LLTextureFetch::FROM_NETWORK_ONLY);
mFetcher->setLoadSource(LLTextureFetch::FROM_HTTP_ONLY);
mTimer.reset();
mFetcher->lockFetcher(false);
mRefetchVisHTTPTime = -1.f;
mRefetchedVisData = 0;
mRefetchedVisPixels = 0;
mRefetchStartTime = gDebugTimers[0].getElapsedTimeF32();
}
void LLTextureFetchDebugger::debugRefetchAllFromCache()
@ -3680,14 +3713,14 @@ void LLTextureFetchDebugger::debugRefetchAllFromCache()
clearTextures();
makeRefetchList();
mFetcher->setLoadSource(LLTextureFetch::FROM_CACHE_ONLY);
mFetcher->setLoadSource(LLTextureFetch::FROM_ALL);
mTimer.reset();
mFetcher->lockFetcher(false);
mRefetchAllCacheTime = -1.f;
mRefetchedAllData = 0;
mRefetchedAllPixels = 0;
mRefetchStartTime = gDebugTimers[0].getElapsedTimeF32();
mRefetchNonVis = FALSE;
}
void LLTextureFetchDebugger::debugRefetchAllFromHTTP()
@ -3695,17 +3728,16 @@ void LLTextureFetchDebugger::debugRefetchAllFromHTTP()
llassert_always(mState == IDLE);
mState = REFETCH_ALL_HTTP;
clearCache();
clearTextures();
makeRefetchList();
mFetcher->setLoadSource(LLTextureFetch::FROM_NETWORK_ONLY);
mFetcher->setLoadSource(LLTextureFetch::FROM_HTTP_ONLY);
mTimer.reset();
mFetcher->lockFetcher(false);
mRefetchAllHTTPTime = -1.f;
mRefetchedAllData = 0;
mRefetchedAllPixels = 0;
mRefetchStartTime = gDebugTimers[0].getElapsedTimeF32();
mRefetchNonVis = TRUE;
}
bool LLTextureFetchDebugger::update()
@ -3751,7 +3783,7 @@ bool LLTextureFetchDebugger::update()
case REFETCH_VIS_CACHE:
if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
{
mRefetchVisCacheTime = gDebugTimers[0].getElapsedTimeF32() - mRefetchStartTime;
mRefetchVisCacheTime = mTimer.getElapsedTimeF32() ;
mState = IDLE;
mFetcher->lockFetcher(true);
mFetcher->resetLoadSource();
@ -3760,7 +3792,7 @@ bool LLTextureFetchDebugger::update()
case REFETCH_VIS_HTTP:
if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
{
mRefetchVisHTTPTime = gDebugTimers[0].getElapsedTimeF32() - mRefetchStartTime;
mRefetchVisHTTPTime = mTimer.getElapsedTimeF32() ;
mState = IDLE;
mFetcher->lockFetcher(true);
mFetcher->resetLoadSource();
@ -3770,22 +3802,31 @@ bool LLTextureFetchDebugger::update()
scanRefetchList();
if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
{
mRefetchAllCacheTime = gDebugTimers[0].getElapsedTimeF32() - mRefetchStartTime;
mState = IDLE;
if(!mRefetchNonVis)
{
mRefetchNonVis = TRUE; //start to fetch non-vis
scanRefetchList();
break;
}
mRefetchAllCacheTime = mTimer.getElapsedTimeF32() ;
mState = IDLE;
mFetcher->lockFetcher(true);
mFetcher->resetLoadSource();
mRefetchList.clear();
mRefetchNonVis = FALSE;
}
break;
case REFETCH_ALL_HTTP:
scanRefetchList();
if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
{
mRefetchAllHTTPTime = gDebugTimers[0].getElapsedTimeF32() - mRefetchStartTime;
mRefetchAllHTTPTime = mTimer.getElapsedTimeF32() ;
mState = IDLE;
mFetcher->lockFetcher(true);
mFetcher->resetLoadSource();
mRefetchList.clear();
mRefetchNonVis = FALSE;
}
break;
default:

View File

@ -221,8 +221,7 @@ public:
enum e_tex_source
{
FROM_ALL = 0,
FROM_CACHE_ONLY,
FROM_NETWORK_ONLY,
FROM_HTTP_ONLY,
INVALID_SOURCE
};
private:
@ -240,8 +239,7 @@ public:
void setLoadSource(e_tex_source source) {mFetchSource = source;}
void resetLoadSource() {mFetchSource = mOriginFetchSource;}
bool canLoadFromCache() { return mFetchSource != FROM_NETWORK_ONLY;}
bool canLoadFromNetwork() { return mFetchSource != FROM_CACHE_ONLY;}
bool canLoadFromCache() { return mFetchSource != FROM_HTTP_ONLY;}
};
//debug use
@ -257,6 +255,7 @@ public:
enum e_debug_state
{
IDLE = 0,
START_DEBUG,
READ_CACHE,
WRITE_CACHE,
DECODING,
@ -347,13 +346,15 @@ private:
U32 mRefetchedAllPixels;
BOOL mFreezeHistory;
BOOL mStopDebug;
BOOL mClearHistory;
BOOL mRefetchNonVis;
std::string mHTTPUrl;
S32 mNbCurlRequests;
S32 mNbCurlCompleted;
std::map< LLPointer<LLViewerFetchedTexture>, std::vector<S32> > mRefetchList;
F32 mRefetchStartTime;
public:
bool update(); //called in the main thread once per frame
@ -364,7 +365,8 @@ public:
void setCurlGetRequest(LLCurlRequest* request) { mCurlGetRequest = request;}
void startDebug();
void stopDebug(); //stop everything
void setStopDebug() {mStopDebug = TRUE;}
void tryToStopDebug(); //stop everything
void debugCacheRead();
void debugCacheWrite();
void debugHTTP();

View File

@ -409,7 +409,11 @@ void LLViewerTextureManager::cleanup()
void LLViewerTexture::initClass()
{
LLImageGL::sDefaultGLTexture = LLViewerFetchedTexture::sDefaultImagep->getGLTexture() ;
sTexelPixelRatio = gSavedSettings.getF32("TexelPixelRatio");
if(gSavedSettings.getBOOL("TextureFetchDebuggerEnabled"))
{
sTexelPixelRatio = gSavedSettings.getF32("TexelPixelRatio");
}
}
// static
@ -2168,7 +2172,10 @@ bool LLViewerFetchedTexture::updateFetch()
void LLViewerFetchedTexture::clearFetchedResults()
{
llassert_always(!mNeedsCreateTexture && !mIsFetching);
if(mNeedsCreateTexture || mIsFetching)
{
return ;
}
cleanup();
destroyGLTexture();

View File

@ -266,7 +266,7 @@
width="264">
<radio_item
height="16"
label="Cache + Network"
label="Cache + HTTP"
layout="topleft"
left="3"
name="0"
@ -274,18 +274,10 @@
width="100" />
<radio_item
height="16"
label="Cache Only"
layout="topleft"
left_delta="120"
name="1"
top_delta="0"
width="200" />
<radio_item
height="16"
label="Network Only"
label="HTTP Only"
layout="topleft"
left_delta="100"
name="2"
name="1"
top_delta="0"
width="200" />
</radio_group>