summaryrefslogtreecommitdiff
path: root/indra/newview/lltexturefetch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltexturefetch.cpp')
-rwxr-xr-x[-rw-r--r--]indra/newview/lltexturefetch.cpp583
1 files changed, 349 insertions, 234 deletions
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index e5f2ca7e5c..62b2f5f976 100644..100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -36,7 +36,7 @@
#include "lldir.h"
#include "llhttpclient.h"
-#include "llhttpstatuscodes.h"
+#include "llhttpconstants.h"
#include "llimage.h"
#include "llimagej2c.h"
#include "llimageworker.h"
@@ -53,6 +53,7 @@
#include "llviewerstatsrecorder.h"
#include "llviewerassetstats.h"
#include "llworld.h"
+#include "llsdparam.h"
#include "llsdutil.h"
#include "llstartup.h"
#include "llsdserialize.h"
@@ -63,9 +64,11 @@
#include "bufferarray.h"
#include "bufferstream.h"
+#include "llhttpretrypolicy.h"
+
bool LLTextureFetchDebugger::sDebuggerEnabled = false ;
-LLStat LLTextureFetch::sCacheHitRate("texture_cache_hits", 128);
-LLStat LLTextureFetch::sCacheReadLatency("texture_cache_read_latency", 128);
+LLTrace::EventStatHandle<LLUnit<F32, LLUnits::Percent> > LLTextureFetch::sCacheHitRate("texture_cache_hits");
+LLTrace::EventStatHandle<F64Milliseconds > LLTextureFetch::sCacheReadLatency("texture_cache_read_latency");
//////////////////////////////////////////////////////////////////////////////
@@ -244,6 +247,25 @@ static const S32 HTTP_REQUESTS_IN_QUEUE_LOW_WATER = 20; // Active level at whi
//////////////////////////////////////////////////////////////////////////////
+static const char* e_state_name[] =
+{
+ "INVALID",
+ "INIT",
+ "LOAD_FROM_TEXTURE_CACHE",
+ "CACHE_POST",
+ "LOAD_FROM_NETWORK",
+ "LOAD_FROM_SIMULATOR",
+ "WAIT_HTTP_RESOURCE",
+ "WAIT_HTTP_RESOURCE2",
+ "SEND_HTTP_REQ",
+ "WAIT_HTTP_REQ",
+ "DECODE_IMAGE",
+ "DECODE_IMAGE_UPDATE",
+ "WRITE_TO_CACHE",
+ "WAIT_ON_WRITE",
+ "DONE"
+};
+
class LLTextureFetchWorker : public LLWorkerClass, public LLCore::HttpHandler
{
@@ -382,12 +404,14 @@ public:
void setCanUseHTTP(bool can_use_http) { mCanUseHTTP = can_use_http; }
bool getCanUseHTTP() const { return mCanUseHTTP; }
+ void setUrl(const std::string& url) { mUrl = url; }
+
LLTextureFetch & getFetcher() { return *mFetcher; }
// Inherited from LLCore::HttpHandler
// Threads: Ttf
virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response);
-
+
protected:
LLTextureFetchWorker(LLTextureFetch* fetcher, FTType f_type,
const std::string& url, const LLUUID& id, const LLHost& host,
@@ -503,11 +527,12 @@ private:
static const char* sStateDescs[];
e_state mState;
void setState(e_state new_state);
+
e_write_to_cache_state mWriteToCacheState;
LLTextureFetch* mFetcher;
LLPointer<LLImageFormatted> mFormattedImage;
- LLPointer<LLImageRaw> mRawImage;
- LLPointer<LLImageRaw> mAuxImage;
+ LLPointer<LLImageRaw> mRawImage,
+ mAuxImage;
FTType mFTType;
LLUUID mID;
LLHost mHost;
@@ -516,22 +541,22 @@ private:
F32 mImagePriority;
U32 mWorkPriority;
F32 mRequestedPriority;
- S32 mDesiredDiscard;
- S32 mSimRequestedDiscard;
- S32 mRequestedDiscard;
- S32 mLoadedDiscard;
- S32 mDecodedDiscard;
- LLFrameTimer mRequestedTimer;
- LLFrameTimer mFetchTimer;
+ S32 mDesiredDiscard,
+ mSimRequestedDiscard,
+ mRequestedDiscard,
+ mLoadedDiscard,
+ mDecodedDiscard;
+ LLFrameTimer mRequestedTimer,
+ mFetchTimer;
LLTimer mCacheReadTimer;
F32 mCacheReadTime;
- LLTextureCache::handle_t mCacheReadHandle;
- LLTextureCache::handle_t mCacheWriteHandle;
- S32 mRequestedSize;
- S32 mRequestedOffset;
- S32 mDesiredSize;
- S32 mFileSize;
- S32 mCachedSize;
+ LLTextureCache::handle_t mCacheReadHandle,
+ mCacheWriteHandle;
+ S32 mRequestedSize,
+ mRequestedOffset,
+ mDesiredSize,
+ mFileSize,
+ mCachedSize;
e_request_state mSentRequest;
handle_t mDecodeHandle;
BOOL mLoaded;
@@ -541,20 +566,25 @@ private:
BOOL mHaveAllData;
BOOL mInLocalCache;
BOOL mInCache;
- bool mCanUseHTTP ;
- bool mCanUseNET ; //can get from asset server.
+ bool mCanUseHTTP,
+ mCanUseNET ; //can get from asset server.
S32 mRetryAttempt;
S32 mActiveCount;
LLCore::HttpStatus mGetStatus;
std::string mGetReason;
+ LLAdaptiveRetryPolicy mFetchRetryPolicy;
+
// Work Data
LLMutex mWorkMutex;
struct PacketData
{
- PacketData(U8* data, S32 size) { mData = data; mSize = size; }
+ PacketData(U8* data, S32 size)
+ : mData(data), mSize(size)
+ {}
~PacketData() { clearData(); }
void clearData() { delete[] mData; mData = NULL; }
+
U8* mData;
U32 mSize;
};
@@ -568,16 +598,16 @@ private:
LLCore::HttpHandle mHttpHandle; // Handle of any active request
LLCore::BufferArray * mHttpBufferArray; // Refcounted pointer to response data
- int mHttpPolicyClass;
+ S32 mHttpPolicyClass;
bool mHttpActive; // Active request to http library
- unsigned int mHttpReplySize; // Actual received data size
- unsigned int mHttpReplyOffset; // Actual received data offset
+ U32 mHttpReplySize, // Actual received data size
+ mHttpReplyOffset; // Actual received data offset
bool mHttpHasResource; // Counts against Fetcher's mHttpSemaphore
// State history
- U32 mCacheReadCount;
- U32 mCacheWriteCount;
- U32 mResourceWaitCount; // Requests entering WAIT_HTTP_RESOURCE2
+ U32 mCacheReadCount,
+ mCacheWriteCount,
+ mResourceWaitCount; // Requests entering WAIT_HTTP_RESOURCE2
};
//////////////////////////////////////////////////////////////////////////////
@@ -889,13 +919,14 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher,
mHttpHasResource(false),
mCacheReadCount(0U),
mCacheWriteCount(0U),
- mResourceWaitCount(0U)
+ mResourceWaitCount(0U),
+ mFetchRetryPolicy(10.0,3600.0,2.0,10)
{
mCanUseNET = mUrl.empty() ;
calcWorkPriority();
mType = host.isOk() ? LLImageBase::TYPE_AVATAR_BAKE : LLImageBase::TYPE_NORMAL;
-// llinfos << "Create: " << mID << " mHost:" << host << " Discard=" << discard << llendl;
+// LL_INFOS() << "Create: " << mID << " mHost:" << host << " Discard=" << discard << LL_ENDL;
if (!mFetcher->mDebugPause)
{
U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH;
@@ -906,10 +937,10 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher,
LLTextureFetchWorker::~LLTextureFetchWorker()
{
-// llinfos << "Destroy: " << mID
+// LL_INFOS() << "Destroy: " << mID
// << " Decoded=" << mDecodedDiscard
// << " Requested=" << mRequestedDiscard
-// << " Desired=" << mDesiredDiscard << llendl;
+// << " Desired=" << mDesiredDiscard << LL_ENDL;
llassert_always(!haveWork());
lockWorkMutex(); // +Mw (should be useless)
@@ -941,7 +972,7 @@ LLTextureFetchWorker::~LLTextureFetchWorker()
mHttpBufferArray = NULL;
}
unlockWorkMutex(); // -Mw
- mFetcher->removeFromHTTPQueue(mID, 0);
+ mFetcher->removeFromHTTPQueue(mID, (S32Bytes)0);
mFetcher->removeHttpWaiter(mID);
mFetcher->updateStateStats(mCacheReadCount, mCacheWriteCount, mResourceWaitCount);
}
@@ -970,7 +1001,7 @@ void LLTextureFetchWorker::setupPacketData()
mFirstPacket = (data_size - FIRST_PACKET_SIZE) / MAX_IMG_PACKET_SIZE + 1;
if (FIRST_PACKET_SIZE + (mFirstPacket-1) * MAX_IMG_PACKET_SIZE != data_size)
{
- llwarns << "Bad CACHED TEXTURE size: " << data_size << " removing." << llendl;
+ LL_WARNS() << "Bad CACHED TEXTURE size: " << data_size << " removing." << LL_ENDL;
removeFromCache();
resetFormattedData();
clearPackets();
@@ -1093,14 +1124,14 @@ bool LLTextureFetchWorker::doWork(S32 param)
{
if (mState == INIT || mState == LOAD_FROM_NETWORK || mState == LOAD_FROM_SIMULATOR)
{
- LL_DEBUGS("Texture") << mID << " abort: mImagePriority < F_ALMOST_ZERO" << llendl;
+ LL_DEBUGS("Texture") << mID << " abort: mImagePriority < F_ALMOST_ZERO" << LL_ENDL;
return true; // abort
}
}
if(mState > CACHE_POST && !mCanUseNET && !mCanUseHTTP)
{
//nowhere to get data, abort.
- LL_WARNS("Texture") << mID << " abort, nowhere to get data" << llendl;
+ LL_WARNS("Texture") << mID << " abort, nowhere to get data" << LL_ENDL;
return true ;
}
@@ -1148,6 +1179,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
mDesiredSize = llmax(mDesiredSize, TEXTURE_CACHE_ENTRY_SIZE); // min desired size is TEXTURE_CACHE_ENTRY_SIZE
LL_DEBUGS("Texture") << mID << ": Priority: " << llformat("%8.0f",mImagePriority)
<< " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL;
+
// fall through
}
@@ -1178,9 +1210,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
offset, size, responder);
mCacheReadTimer.reset();
}
-/* SH-3980 - disabling caching of server bakes until we can fix the blurring problems */
-/* else if ((mUrl.empty()||mFTType==FTT_SERVER_BAKE) && mFetcher->canLoadFromCache()) */
- else if (mUrl.empty() && mFetcher->canLoadFromCache())
+ else if ((mUrl.empty() || mFTType==FTT_SERVER_BAKE) && mFetcher->canLoadFromCache())
{
setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it
@@ -1216,7 +1246,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
//
//This should never happen
//
- LL_DEBUGS("Texture") << mID << " this should never happen" << llendl;
+ LL_DEBUGS("Texture") << mID << " this should never happen" << LL_ENDL;
return false;
}
}
@@ -1238,7 +1268,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
if (mLoadedDiscard < 0)
{
LL_WARNS("Texture") << mID << " mLoadedDiscard is " << mLoadedDiscard
- << ", should be >=0" << llendl;
+ << ", should be >=0" << LL_ENDL;
}
setState(DECODE_IMAGE);
mInCache = TRUE;
@@ -1246,7 +1276,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
LL_DEBUGS("Texture") << mID << ": Cached. Bytes: " << mFormattedImage->getDataSize()
<< " Size: " << llformat("%dx%d",mFormattedImage->getWidth(),mFormattedImage->getHeight())
<< " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL;
- LLTextureFetch::sCacheHitRate.addValue(100.f);
+ record(LLTextureFetch::sCacheHitRate, LLUnits::Ratio::fromValue(1));
}
else
{
@@ -1264,12 +1294,27 @@ bool LLTextureFetchWorker::doWork(S32 param)
}
// fall through
- LLTextureFetch::sCacheHitRate.addValue(0.f);
+ record(LLTextureFetch::sCacheHitRate, LLUnits::Ratio::fromValue(0));
}
}
if (mState == LOAD_FROM_NETWORK)
{
+ // Check for retries to previous server failures.
+ F32 wait_seconds;
+ if (mFetchRetryPolicy.shouldRetry(wait_seconds))
+ {
+ if (wait_seconds <= 0.0)
+ {
+ LL_INFOS() << mID << " retrying now" << LL_ENDL;
+ }
+ else
+ {
+ //LL_INFOS() << mID << " waiting to retry for " << wait_seconds << " seconds" << LL_ENDL;
+ return false;
+ }
+ }
+
static LLCachedControl<bool> use_http(gSavedSettings,"ImagePipelineUseHTTP", true);
// if (mHost != LLHost::invalid) get_url = false;
@@ -1286,27 +1331,33 @@ bool LLTextureFetchWorker::doWork(S32 param)
std::string http_url = region->getHttpUrl() ;
if (!http_url.empty())
{
- mUrl = http_url + "/?texture_id=" + mID.asString().c_str();
+ if (mFTType != FTT_DEFAULT)
+ {
+ LL_WARNS() << "trying to seek a non-default texture on the sim. Bad!" << LL_ENDL;
+ }
+ setUrl(http_url + "/?texture_id=" + mID.asString().c_str());
+ LL_DEBUGS("Texture") << "Texture URL " << mUrl << LL_ENDL;
mWriteToCacheState = CAN_WRITE ; //because this texture has a fixed texture id.
}
else
{
mCanUseHTTP = false ;
+ LL_DEBUGS("Texture") << "Texture not available via HTTP: no URL " << mUrl << LL_ENDL;
}
}
else
{
// This will happen if not logged in or if a region deoes not have HTTP Texture enabled
- //llwarns << "Region not found for host: " << mHost << llendl;
+ //LL_WARNS() << "Region not found for host: " << mHost << LL_ENDL;
+ LL_DEBUGS("Texture") << "Texture not available via HTTP: no region " << mUrl << LL_ENDL;
mCanUseHTTP = false;
}
}
-#if 0 /* SH-3980 - disabling caching of server bakes until we can fix the blurring problems */
- if (mFTType == FTT_SERVER_BAKE)
+ else if (mFTType == FTT_SERVER_BAKE)
{
mWriteToCacheState = CAN_WRITE;
}
-#endif
+
if (mCanUseHTTP && !mUrl.empty())
{
setState(WAIT_HTTP_RESOURCE);
@@ -1340,7 +1391,6 @@ bool LLTextureFetchWorker::doWork(S32 param)
//recordTextureStart(false);
//setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
- LL_DEBUGS("Texture") << mID << " does this happen?" << llendl;
return false;
}
}
@@ -1358,15 +1408,15 @@ bool LLTextureFetchWorker::doWork(S32 param)
if (mFormattedImage.isNull() || !mFormattedImage->getDataSize())
{
// processSimulatorPackets() failed
-// llwarns << "processSimulatorPackets() failed to load buffer" << llendl;
- LL_WARNS("Texture") << mID << " processSimulatorPackets() failed to load buffer" << llendl;
+// LL_WARNS() << "processSimulatorPackets() failed to load buffer" << LL_ENDL;
+ LL_WARNS("Texture") << mID << " processSimulatorPackets() failed to load buffer" << LL_ENDL;
return true; // failed
}
setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
if (mLoadedDiscard < 0)
{
LL_WARNS("Texture") << mID << " mLoadedDiscard is " << mLoadedDiscard
- << ", should be >=0" << llendl;
+ << ", should be >=0" << LL_ENDL;
}
setState(DECODE_IMAGE);
mWriteToCacheState = SHOULD_WRITE;
@@ -1416,7 +1466,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
if (! mCanUseHTTP)
{
releaseHttpSemaphore();
- LL_WARNS("Texture") << mID << " abort: SEND_HTTP_REQ but !mCanUseHTTP" << llendl;
+ LL_WARNS("Texture") << mID << " abort: SEND_HTTP_REQ but !mCanUseHTTP" << LL_ENDL;
return true; // abort
}
@@ -1436,7 +1486,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
if (mLoadedDiscard < 0)
{
LL_WARNS("Texture") << mID << " mLoadedDiscard is " << mLoadedDiscard
- << ", should be >=0" << llendl;
+ << ", should be >=0" << LL_ENDL;
}
setState(DECODE_IMAGE);
releaseHttpSemaphore();
@@ -1445,7 +1495,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
else
{
releaseHttpSemaphore();
- LL_WARNS("Texture") << mID << " SEND_HTTP_REQ abort: cur_size " << cur_size << " <=0" << llendl;
+ LL_WARNS("Texture") << mID << " SEND_HTTP_REQ abort: cur_size " << cur_size << " <=0" << LL_ENDL;
return true; // abort.
}
}
@@ -1482,18 +1532,20 @@ bool LLTextureFetchWorker::doWork(S32 param)
<< LL_ENDL;
// Will call callbackHttpGet when curl request completes
+ // Only server bake images use the returned headers currently, for getting retry-after field.
+ LLCore::HttpOptions *options = (mFTType == FTT_SERVER_BAKE) ? mFetcher->mHttpOptionsWithHeaders: mFetcher->mHttpOptions;
mHttpHandle = mFetcher->mHttpRequest->requestGetByteRange(mHttpPolicyClass,
mWorkPriority,
mUrl,
mRequestedOffset,
mRequestedSize,
- mFetcher->mHttpOptions,
+ options,
mFetcher->mHttpHeaders,
this);
}
if (LLCORE_HTTP_HANDLE_INVALID == mHttpHandle)
{
- llwarns << "HTTP GET request failed for " << mID << llendl;
+ LL_WARNS() << "HTTP GET request failed for " << mID << LL_ENDL;
resetFormattedData();
releaseHttpSemaphore();
return true; // failed
@@ -1519,16 +1571,22 @@ bool LLTextureFetchWorker::doWork(S32 param)
{
if (http_not_found == mGetStatus)
{
- if(mWriteToCacheState == NOT_WRITE) //map tiles
+ if (mFTType != FTT_MAP_TILE)
+ {
+ LL_WARNS() << "Texture missing from server (404): " << mUrl << LL_ENDL;
+ }
+
+ if(mWriteToCacheState == NOT_WRITE) //map tiles or server bakes
{
setState(DONE);
releaseHttpSemaphore();
- LL_DEBUGS("Texture") << mID << " abort: WAIT_HTTP_REQ not found" << llendl;
- return true; // failed, means no map tile on the empty region.
+ if (mFTType != FTT_MAP_TILE)
+ {
+ LL_WARNS("Texture") << mID << " abort: WAIT_HTTP_REQ not found" << LL_ENDL;
+ }
+ return true;
}
- llwarns << "Texture missing from server (404): " << mUrl << llendl;
-
// roll back to try UDP
if (mCanUseNET)
{
@@ -1543,6 +1601,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
else if (http_service_unavail == mGetStatus)
{
LL_INFOS_ONCE("Texture") << "Texture server busy (503): " << mUrl << LL_ENDL;
+ LL_INFOS() << "503: HTTP GET failed for: " << mUrl
+ << " Status: " << mGetStatus.toHex()
+ << " Reason: '" << mGetReason << "'"
+ << LL_ENDL;
}
else if (http_not_sat == mGetStatus)
{
@@ -1551,13 +1613,16 @@ bool LLTextureFetchWorker::doWork(S32 param)
}
else
{
- llinfos << "HTTP GET failed for: " << mUrl
+ LL_INFOS() << "HTTP GET failed for: " << mUrl
<< " Status: " << mGetStatus.toTerseString()
<< " Reason: '" << mGetReason << "'"
- << llendl;
+ << LL_ENDL;
}
- mUrl.clear();
+ if (mFTType != FTT_SERVER_BAKE)
+ {
+ mUrl.clear();
+ }
if (cur_size > 0)
{
// Use available data
@@ -1566,7 +1631,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
if (mLoadedDiscard < 0)
{
LL_WARNS("Texture") << mID << " mLoadedDiscard is " << mLoadedDiscard
- << ", should be >=0" << llendl;
+ << ", should be >=0" << LL_ENDL;
}
setState(DECODE_IMAGE);
releaseHttpSemaphore();
@@ -1577,14 +1642,14 @@ bool LLTextureFetchWorker::doWork(S32 param)
resetFormattedData();
setState(DONE);
releaseHttpSemaphore();
- LL_WARNS("Texture") << mID << " abort: fail harder" << llendl;
+ LL_WARNS("Texture") << mID << " abort: fail harder" << LL_ENDL;
return true; // failed
}
// Clear the url since we're done with the fetch
// Note: mUrl is used to check is fetching is required so failure to clear it will force an http fetch
// next time the texture is requested, even if the data have already been fetched.
- if(mWriteToCacheState != NOT_WRITE)
+ if(mWriteToCacheState != NOT_WRITE && mFTType != FTT_SERVER_BAKE)
{
// Why do we want to keep url if NOT_WRITE - is this a proxy for map tiles?
mUrl.clear();
@@ -1601,7 +1666,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
// abort.
setState(DONE);
- LL_WARNS("Texture") << mID << " abort: no data received" << llendl;
+ LL_WARNS("Texture") << mID << " abort: no data received" << LL_ENDL;
releaseHttpSemaphore();
return true;
}
@@ -1670,7 +1735,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
if (mLoadedDiscard < 0)
{
LL_WARNS("Texture") << mID << " mLoadedDiscard is " << mLoadedDiscard
- << ", should be >=0" << llendl;
+ << ", should be >=0" << LL_ENDL;
}
setState(DECODE_IMAGE);
if (mWriteToCacheState != NOT_WRITE)
@@ -1711,26 +1776,26 @@ bool LLTextureFetchWorker::doWork(S32 param)
{
// We aborted, don't decode
setState(DONE);
- LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: desired discard " << mDesiredDiscard << "<0" << llendl;
+ LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: desired discard " << mDesiredDiscard << "<0" << LL_ENDL;
return true;
}
if (mFormattedImage->getDataSize() <= 0)
{
- llwarns << "Decode entered with invalid mFormattedImage. ID = " << mID << llendl;
+ LL_WARNS() << "Decode entered with invalid mFormattedImage. ID = " << mID << LL_ENDL;
//abort, don't decode
setState(DONE);
- LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: (mFormattedImage->getDataSize() <= 0)" << llendl;
+ LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: (mFormattedImage->getDataSize() <= 0)" << LL_ENDL;
return true;
}
if (mLoadedDiscard < 0)
{
- llwarns << "Decode entered with invalid mLoadedDiscard. ID = " << mID << llendl;
+ LL_WARNS() << "Decode entered with invalid mLoadedDiscard. ID = " << mID << LL_ENDL;
//abort, don't decode
setState(DONE);
- LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: mLoadedDiscard < 0" << llendl;
+ LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: mLoadedDiscard < 0" << LL_ENDL;
return true;
}
@@ -1763,7 +1828,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
if (mCachedSize > 0 && !mInLocalCache && mRetryAttempt == 0)
{
// Cache file should be deleted, try again
-// llwarns << mID << ": Decode of cached file failed (removed), retrying" << llendl;
+ LL_WARNS() << mID << ": Decode of cached file failed (removed), retrying" << LL_ENDL;
llassert_always(mDecodeHandle == 0);
mFormattedImage = NULL;
++mRetryAttempt;
@@ -1773,7 +1838,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
}
else
{
-// llwarns << "UNABLE TO LOAD TEXTURE: " << mID << " RETRIES: " << mRetryAttempt << llendl;
+// LL_WARNS() << "UNABLE TO LOAD TEXTURE: " << mID << " RETRIES: " << mRetryAttempt << LL_ENDL;
setState(DONE); // failed
}
}
@@ -1855,7 +1920,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
setState(INIT);
LL_DEBUGS("Texture") << mID << " more data requested, returning to INIT: "
<< " mDecodedDiscard " << mDecodedDiscard << ">= 0 && mDesiredDiscard " << mDesiredDiscard
- << "<" << " mDecodedDiscard " << mDecodedDiscard << llendl;
+ << "<" << " mDecodedDiscard " << mDecodedDiscard << LL_ENDL;
setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
return false;
}
@@ -1883,37 +1948,75 @@ void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRe
if (log_to_viewer_log || log_to_sim)
{
- U64 timeNow = LLTimer::getTotalTime();
- mFetcher->mTextureInfo.setRequestStartTime(mID, mMetricsStartTime);
+ mFetcher->mTextureInfo.setRequestStartTime(mID, mMetricsStartTime.value());
mFetcher->mTextureInfo.setRequestType(mID, LLTextureInfoDetails::REQUEST_TYPE_HTTP);
mFetcher->mTextureInfo.setRequestSize(mID, mRequestedSize);
mFetcher->mTextureInfo.setRequestOffset(mID, mRequestedOffset);
- mFetcher->mTextureInfo.setRequestCompleteTimeAndLog(mID, timeNow);
+ mFetcher->mTextureInfo.setRequestCompleteTimeAndLog(mID, LLTimer::getTotalTime());
}
+ static LLCachedControl<F32> fake_failure_rate(gSavedSettings, "TextureFetchFakeFailureRate", 0.0f);
+ F32 rand_val = ll_frand();
+ F32 rate = fake_failure_rate;
+ if (mFTType == FTT_SERVER_BAKE && (fake_failure_rate > 0.0) && (rand_val < fake_failure_rate))
+ {
+ LL_WARNS() << mID << " for debugging, setting fake failure status for texture " << mID
+ << " (rand was " << rand_val << "/" << rate << ")" << LL_ENDL;
+ response->setStatus(LLCore::HttpStatus(503));
+ }
bool success = true;
bool partial = false;
LLCore::HttpStatus status(response->getStatus());
+ if (!status && (mFTType == FTT_SERVER_BAKE))
+ {
+ LL_INFOS() << mID << " state " << e_state_name[mState] << LL_ENDL;
+ mFetchRetryPolicy.onFailure(response);
+ F32 retry_after;
+ if (mFetchRetryPolicy.shouldRetry(retry_after))
+ {
+ LL_INFOS() << mID << " will retry after " << retry_after << " seconds, resetting state to LOAD_FROM_NETWORK" << LL_ENDL;
+ mFetcher->removeFromHTTPQueue(mID, S32Bytes(0));
+ std::string reason(status.toString());
+ setGetStatus(status, reason);
+ releaseHttpSemaphore();
+ setState(LOAD_FROM_NETWORK);
+ return;
+ }
+ else
+ {
+ LL_INFOS() << mID << " will not retry" << LL_ENDL;
+ }
+ }
+ else
+ {
+ mFetchRetryPolicy.onSuccess();
+ }
LL_DEBUGS("Texture") << "HTTP COMPLETE: " << mID
- << " status: " << status.toTerseString()
- << " '" << status.toString() << "'"
- << llendl;
+ << " status: " << status.toTerseString()
+ << " '" << status.toString() << "'"
+ << LL_ENDL;
+
// unsigned int offset(0), length(0), full_length(0);
// response->getRange(&offset, &length, &full_length);
-// llwarns << "HTTP COMPLETE: " << mID << " handle: " << handle
+// LL_WARNS() << "HTTP COMPLETE: " << mID << " handle: " << handle
// << " status: " << status.toULong() << " '" << status.toString() << "'"
// << " req offset: " << mRequestedOffset << " req length: " << mRequestedSize
// << " offset: " << offset << " length: " << length
-// << llendl;
+// << LL_ENDL;
+ std::string reason(status.toString());
+ setGetStatus(status, reason);
if (! status)
{
success = false;
- std::string reason(status.toString());
- setGetStatus(status, reason);
- llwarns << "CURL GET FAILED, status: " << status.toTerseString()
- << " reason: " << reason << llendl;
+ if (mFTType != FTT_MAP_TILE) // missing map tiles are normal, don't complain about them.
+ {
+ std::string reason(status.toString());
+ setGetStatus(status, reason);
+ LL_WARNS() << "CURL GET FAILED, status: " << status.toTerseString()
+ << " reason: " << reason << LL_ENDL;
+ }
}
else
{
@@ -1927,7 +2030,7 @@ void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRe
partial = (par_status == status);
}
- S32 data_size = callbackHttpGet(response, partial, success);
+ S32BytesImplicit data_size = callbackHttpGet(response, partial, success);
if (log_texture_traffic && data_size > 0)
{
@@ -2123,13 +2226,13 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response,
if (mState != WAIT_HTTP_REQ)
{
- llwarns << "callbackHttpGet for unrequested fetch worker: " << mID
- << " req=" << mSentRequest << " state= " << mState << llendl;
+ LL_WARNS() << "callbackHttpGet for unrequested fetch worker: " << mID
+ << " req=" << mSentRequest << " state= " << mState << LL_ENDL;
return data_size;
}
if (mLoaded)
{
- llwarns << "Duplicate callback for " << mID.asString() << llendl;
+ LL_WARNS() << "Duplicate callback for " << mID.asString() << LL_ENDL;
return data_size ; // ignore duplicate callback
}
if (success)
@@ -2194,7 +2297,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response,
else if (data_size > mRequestedSize)
{
// *TODO: This shouldn't be happening any more (REALLY don't expect this anymore)
- llwarns << "data_size = " << data_size << " > requested: " << mRequestedSize << llendl;
+ LL_WARNS() << "data_size = " << data_size << " > requested: " << mRequestedSize << LL_ENDL;
mHaveAllData = TRUE;
llassert_always(mDecodeHandle == 0);
mFormattedImage = NULL; // discard any previous data we had
@@ -2229,7 +2332,7 @@ void LLTextureFetchWorker::callbackCacheRead(bool success, LLImageFormatted* ima
LLMutexLock lock(&mWorkMutex); // +Mw
if (mState != LOAD_FROM_TEXTURE_CACHE)
{
-// llwarns << "Read callback for " << mID << " with state = " << mState << llendl;
+// LL_WARNS() << "Read callback for " << mID << " with state = " << mState << LL_ENDL;
return;
}
if (success)
@@ -2254,7 +2357,7 @@ void LLTextureFetchWorker::callbackCacheWrite(bool success)
LLMutexLock lock(&mWorkMutex); // +Mw
if (mState != WAIT_ON_WRITE)
{
-// llwarns << "Write callback for " << mID << " with state = " << mState << llendl;
+// LL_WARNS() << "Write callback for " << mID << " with state = " << mState << LL_ENDL;
return;
}
mWritten = TRUE;
@@ -2273,7 +2376,7 @@ void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImag
}
if (mState != DECODE_IMAGE_UPDATE)
{
-// llwarns << "Decode callback for " << mID << " with state = " << mState << llendl;
+// LL_WARNS() << "Decode callback for " << mID << " with state = " << mState << LL_ENDL;
mDecodeHandle = 0;
return;
}
@@ -2291,12 +2394,12 @@ void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImag
}
else
{
- llwarns << "DECODE FAILED: " << mID << " Discard: " << (S32)mFormattedImage->getDiscardLevel() << llendl;
+ LL_WARNS() << "DECODE FAILED: " << mID << " Discard: " << (S32)mFormattedImage->getDiscardLevel() << LL_ENDL;
removeFromCache();
mDecodedDiscard = -1; // Redundant, here for clarity and paranoia
}
mDecoded = TRUE;
-// llinfos << mID << " : DECODE COMPLETE " << llendl;
+// LL_INFOS() << mID << " : DECODE COMPLETE " << LL_ENDL;
setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
mCacheReadTime = mCacheReadTimer.getElapsedTimeF32();
} // -Mw
@@ -2329,11 +2432,11 @@ bool LLTextureFetchWorker::writeToCacheComplete()
// Threads: Ttf
void LLTextureFetchWorker::recordTextureStart(bool is_http)
{
- if (! mMetricsStartTime)
+ if (! mMetricsStartTime.value())
{
mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
}
- LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE,
+ LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE,
is_http,
LLImageBase::TYPE_AVATAR_BAKE == mType);
}
@@ -2342,15 +2445,15 @@ void LLTextureFetchWorker::recordTextureStart(bool is_http)
// Threads: Ttf
void LLTextureFetchWorker::recordTextureDone(bool is_http)
{
- if (mMetricsStartTime)
+ if (mMetricsStartTime.value())
{
- LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE,
+ LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_TEXTURE,
is_http,
LLImageBase::TYPE_AVATAR_BAKE == mType,
LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime);
- mMetricsStartTime = 0;
+ mMetricsStartTime = (U32Seconds)0;
}
- LLViewerAssetStatsFF::record_dequeue_thread1(LLViewerAssetType::AT_TEXTURE,
+ LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE,
is_http,
LLImageBase::TYPE_AVATAR_BAKE == mType);
}
@@ -2390,7 +2493,7 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
mFetcherLocked(FALSE)
{
mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
- mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), gSavedSettings.getU32("TextureLoggingThreshold"));
+ mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), U32Bytes(gSavedSettings.getU32("TextureLoggingThreshold")));
LLTextureFetchDebugger::sDebuggerEnabled = gSavedSettings.getBOOL("TextureFetchDebuggerEnabled");
if(LLTextureFetchDebugger::isEnabled())
@@ -2473,14 +2576,18 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const
{
return false;
}
-
+
+ if (f_type == FTT_SERVER_BAKE)
+ {
+ LL_DEBUGS("Avatar") << " requesting " << id << " " << w << "x" << h << " discard " << desired_discard << " type " << f_type << LL_ENDL;
+ }
LLTextureFetchWorker* worker = getWorker(id) ;
if (worker)
{
if (worker->mHost != host)
{
- llwarns << "LLTextureFetch::createRequest " << id << " called with multiple hosts: "
- << host << " != " << worker->mHost << llendl;
+ LL_WARNS() << "LLTextureFetch::createRequest " << id << " called with multiple hosts: "
+ << host << " != " << worker->mHost << LL_ENDL;
removeRequest(worker, true);
worker = NULL;
return false;
@@ -2489,9 +2596,21 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const
S32 desired_size;
std::string exten = gDirUtilp->getExtension(url);
- if (!url.empty() && (!exten.empty() && LLImageBase::getCodecFromExtension(exten) != IMG_CODEC_J2C))
+ //if (f_type == FTT_SERVER_BAKE)
+ if ((f_type == FTT_SERVER_BAKE) && !url.empty() && !exten.empty() && (LLImageBase::getCodecFromExtension(exten) != IMG_CODEC_J2C))
+ {
+ // SH-4030: This case should be redundant with the following one, just
+ // breaking it out here to clarify that it's intended behavior.
+ llassert(!url.empty() && (!exten.empty() && LLImageBase::getCodecFromExtension(exten) != IMG_CODEC_J2C));
+
+ // Do full requests for baked textures to reduce interim blurring.
+ LL_DEBUGS("Texture") << "full request for " << id << " texture is FTT_SERVER_BAKE" << LL_ENDL;
+ desired_size = MAX_IMAGE_DATA_SIZE;
+ desired_discard = 0;
+ }
+ else if (!url.empty() && (!exten.empty() && LLImageBase::getCodecFromExtension(exten) != IMG_CODEC_J2C))
{
- LL_DEBUGS("Texture") << "full request for " << id << " exten is not J2C: " << exten << llendl;
+ LL_DEBUGS("Texture") << "full request for " << id << " exten is not J2C: " << exten << LL_ENDL;
// Only do partial requests for J2C at the moment
desired_size = MAX_IMAGE_DATA_SIZE;
desired_discard = 0;
@@ -2531,7 +2650,8 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const
worker->mNeedsAux = needs_aux;
worker->setImagePriority(priority);
worker->setDesiredDiscard(desired_discard, desired_size);
- worker->setCanUseHTTP(can_use_http) ;
+ worker->setCanUseHTTP(can_use_http);
+ worker->setUrl(url);
if (!worker->haveWork())
{
worker->setState(LLTextureFetchWorker::INIT);
@@ -2558,7 +2678,8 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const
worker->unlockWorkMutex(); // -Mw
}
- LL_DEBUGS("Texture") << "REQUESTED: " << id << " Discard: " << desired_discard << " size " << desired_size << llendl;
+ LL_DEBUGS("Texture") << "REQUESTED: " << id << " f_type " << fttype_to_string(f_type)
+ << " Discard: " << desired_discard << " size " << desired_size << LL_ENDL;
return true;
}
@@ -2608,11 +2729,11 @@ void LLTextureFetch::addToHTTPQueue(const LLUUID& id)
} // -Mfnq
// Threads: T*
-void LLTextureFetch::removeFromHTTPQueue(const LLUUID& id, S32 received_size)
+void LLTextureFetch::removeFromHTTPQueue(const LLUUID& id, S32Bytes received_size)
{
LLMutexLock lock(&mNetworkQueueMutex); // +Mfnq
mHTTPTextureQueue.erase(id);
- mHTTPTextureBits += received_size * 8; // Approximate - does not include header bits
+ mHTTPTextureBits += received_size; // Approximate - does not include header bits
} // -Mfnq
// NB: If you change deleteRequest() you should probably make
@@ -2737,7 +2858,8 @@ LLTextureFetchWorker* LLTextureFetch::getWorker(const LLUUID& id)
// Threads: T*
bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
- LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux)
+ LLPointer<LLImageRaw>& raw, LLPointer<LLImageRaw>& aux,
+ LLCore::HttpStatus& last_http_get_status)
{
bool res = false;
LLTextureFetchWorker* worker = getWorker(id);
@@ -2752,20 +2874,21 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
// Should only happen if we set mDebugPause...
if (!mDebugPause)
{
-// llwarns << "Adding work for inactive worker: " << id << llendl;
+// LL_WARNS() << "Adding work for inactive worker: " << id << LL_ENDL;
worker->addWork(0, LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority);
}
}
else if (worker->checkWork())
{
worker->lockWorkMutex(); // +Mw
+ last_http_get_status = worker->mGetStatus;
discard_level = worker->mDecodedDiscard;
raw = worker->mRawImage;
aux = worker->mAuxImage;
- F32 cache_read_time = worker->mCacheReadTime;
- if (cache_read_time != 0.f)
+ F32Seconds cache_read_time(worker->mCacheReadTime);
+ if (cache_read_time != (F32Seconds)0.f)
{
- sCacheReadLatency.addValue(cache_read_time * 1000.f);
+ record(sCacheReadLatency, cache_read_time);
}
res = true;
LL_DEBUGS("Texture") << id << ": Request Finished. State: " << worker->mState << " Discard: " << discard_level << LL_ENDL;
@@ -2889,10 +3012,10 @@ S32 LLTextureFetch::update(F32 max_time_ms)
{
mNetworkQueueMutex.lock(); // +Mfnq
- mMaxBandwidth = band_width;
+ mMaxBandwidth = band_width();
- gTextureList.sTextureBits += mHTTPTextureBits;
- mHTTPTextureBits = 0;
+ add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, mHTTPTextureBits);
+ mHTTPTextureBits = (U32Bits)0;
mNetworkQueueMutex.unlock(); // -Mfnq
}
@@ -2988,7 +3111,7 @@ void LLTextureFetch::threadedUpdate()
S32 q = mCurlGetRequest->getQueued();
if (q > 0)
{
- llinfos << "Queued gets: " << q << llendl;
+ LL_INFOS() << "Queued gets: " << q << LL_ENDL;
info_timer.reset();
}
}
@@ -3037,7 +3160,7 @@ void LLTextureFetch::sendRequestListToSimulators()
(req->mState != LLTextureFetchWorker::LOAD_FROM_SIMULATOR))
{
// We already received our URL, remove from the queue
- llwarns << "Worker: " << req->mID << " in mNetworkQueue but in wrong state: " << req->mState << llendl;
+ LL_WARNS() << "Worker: " << req->mID << " in mNetworkQueue but in wrong state: " << req->mState << LL_ENDL;
mNetworkQueue.erase(curiter);
continue;
}
@@ -3105,8 +3228,8 @@ void LLTextureFetch::sendRequestListToSimulators()
gMessageSystem->addF32Fast(_PREHASH_DownloadPriority, req->mImagePriority);
gMessageSystem->addU32Fast(_PREHASH_Packet, packet);
gMessageSystem->addU8Fast(_PREHASH_Type, req->mType);
-// llinfos << "IMAGE REQUEST: " << req->mID << " Discard: " << req->mDesiredDiscard
-// << " Packet: " << packet << " Priority: " << req->mImagePriority << llendl;
+// LL_INFOS() << "IMAGE REQUEST: " << req->mID << " Discard: " << req->mDesiredDiscard
+// << " Packet: " << packet << " Priority: " << req->mImagePriority << LL_ENDL;
static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog", false);
static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator", false);
@@ -3127,7 +3250,7 @@ void LLTextureFetch::sendRequestListToSimulators()
sim_request_count++;
if (sim_request_count >= IMAGES_PER_REQUEST)
{
-// llinfos << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << llendl;
+// LL_INFOS() << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << LL_ENDL;
gMessageSystem->sendSemiReliable(host, NULL, NULL);
sim_request_count = 0;
@@ -3136,7 +3259,7 @@ void LLTextureFetch::sendRequestListToSimulators()
}
if (gMessageSystem && sim_request_count > 0 && sim_request_count < IMAGES_PER_REQUEST)
{
-// llinfos << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << llendl;
+// LL_INFOS() << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << LL_ENDL;
gMessageSystem->sendSemiReliable(host, NULL, NULL);
sim_request_count = 0;
}
@@ -3172,7 +3295,7 @@ void LLTextureFetch::sendRequestListToSimulators()
gMessageSystem->addF32Fast(_PREHASH_DownloadPriority, 0);
gMessageSystem->addU32Fast(_PREHASH_Packet, 0);
gMessageSystem->addU8Fast(_PREHASH_Type, 0);
-// llinfos << "CANCELING IMAGE REQUEST: " << (*iter2) << llendl;
+// LL_INFOS() << "CANCELING IMAGE REQUEST: " << (*iter2) << LL_ENDL;
request_count++;
if (request_count >= IMAGES_PER_REQUEST)
@@ -3200,12 +3323,12 @@ bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size)
mRequestedTimer.reset();
if (index >= mTotalPackets)
{
-// llwarns << "Received Image Packet " << index << " > max: " << mTotalPackets << " for image: " << mID << llendl;
+// LL_WARNS() << "Received Image Packet " << index << " > max: " << mTotalPackets << " for image: " << mID << LL_ENDL;
return false;
}
if (index > 0 && index < mTotalPackets-1 && size != MAX_IMG_PACKET_SIZE)
{
-// llwarns << "Received bad sized packet: " << index << ", " << size << " != " << MAX_IMG_PACKET_SIZE << " for image: " << mID << llendl;
+// LL_WARNS() << "Received bad sized packet: " << index << ", " << size << " != " << MAX_IMG_PACKET_SIZE << " for image: " << mID << LL_ENDL;
return false;
}
@@ -3215,7 +3338,7 @@ bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size)
}
else if (mPackets[index] != NULL)
{
-// llwarns << "Received duplicate packet: " << index << " for image: " << mID << llendl;
+// LL_WARNS() << "Received duplicate packet: " << index << " for image: " << mID << LL_ENDL;
return false;
}
@@ -3229,25 +3352,14 @@ bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size)
void LLTextureFetchWorker::setState(e_state new_state)
{
- static const char* e_state_name[] =
- {
- "INVALID",
- "INIT",
- "LOAD_FROM_TEXTURE_CACHE",
- "CACHE_POST",
- "LOAD_FROM_NETWORK",
- "LOAD_FROM_SIMULATOR",
- "WAIT_HTTP_RESOURCE",
- "WAIT_HTTP_RESOURCE2",
- "SEND_HTTP_REQ",
- "WAIT_HTTP_REQ",
- "DECODE_IMAGE",
- "DECODE_IMAGE_UPDATE",
- "WRITE_TO_CACHE",
- "WAIT_ON_WRITE",
- "DONE"
- };
- LL_DEBUGS("Texture") << "id: " << mID << " FTType: " << mFTType << " disc: " << mDesiredDiscard << " sz: " << mDesiredSize << " state: " << e_state_name[mState] << " => " << e_state_name[new_state] << llendl;
+ if (mFTType == FTT_SERVER_BAKE)
+ {
+ // NOTE: turning on these log statements is a reliable way to get
+ // blurry images fairly frequently. Presumably this is an
+ // indication of some subtle timing or locking issue.
+
+// LL_INFOS("Texture") << "id: " << mID << " FTType: " << mFTType << " disc: " << mDesiredDiscard << " sz: " << mDesiredSize << " state: " << e_state_name[mState] << " => " << e_state_name[new_state] << LL_ENDL;
+ }
mState = new_state;
}
@@ -3262,26 +3374,26 @@ bool LLTextureFetch::receiveImageHeader(const LLHost& host, const LLUUID& id, U8
if (!worker)
{
-// llwarns << "Received header for non active worker: " << id << llendl;
+// LL_WARNS() << "Received header for non active worker: " << id << LL_ENDL;
res = false;
}
else if (worker->mState != LLTextureFetchWorker::LOAD_FROM_NETWORK ||
worker->mSentRequest != LLTextureFetchWorker::SENT_SIM)
{
-// llwarns << "receiveImageHeader for worker: " << id
+// LL_WARNS() << "receiveImageHeader for worker: " << id
// << " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState]
-// << " sent: " << worker->mSentRequest << llendl;
+// << " sent: " << worker->mSentRequest << LL_ENDL;
res = false;
}
else if (worker->mLastPacket != -1)
{
// check to see if we've gotten this packet before
-// llwarns << "Received duplicate header for: " << id << llendl;
+// LL_WARNS() << "Received duplicate header for: " << id << LL_ENDL;
res = false;
}
else if (!data_size)
{
-// llwarns << "Img: " << id << ":" << " Empty Image Header" << llendl;
+// LL_WARNS() << "Img: " << id << ":" << " Empty Image Header" << LL_ENDL;
res = false;
}
if (!res)
@@ -3323,17 +3435,17 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1
if (!worker)
{
-// llwarns << "Received packet " << packet_num << " for non active worker: " << id << llendl;
+// LL_WARNS() << "Received packet " << packet_num << " for non active worker: " << id << LL_ENDL;
res = false;
}
else if (worker->mLastPacket == -1)
{
-// llwarns << "Received packet " << packet_num << " before header for: " << id << llendl;
+// LL_WARNS() << "Received packet " << packet_num << " before header for: " << id << LL_ENDL;
res = false;
}
else if (!data_size)
{
-// llwarns << "Img: " << id << ":" << " Empty Image Header" << llendl;
+// LL_WARNS() << "Img: " << id << ":" << " Empty Image Header" << LL_ENDL;
res = false;
}
if (!res)
@@ -3361,8 +3473,8 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1
}
else
{
-// llwarns << "receiveImagePacket " << packet_num << "/" << worker->mLastPacket << " for worker: " << id
-// << " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState] << llendl;
+// LL_WARNS() << "receiveImagePacket " << packet_num << "/" << worker->mLastPacket << " for worker: " << id
+// << " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState] << LL_ENDL;
removeFromNetworkQueue(worker, true); // failsafe
}
@@ -3373,7 +3485,7 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1
if (log_to_viewer_log || log_to_sim)
{
- U64 timeNow = LLTimer::getTotalTime();
+ U64Microseconds timeNow = LLTimer::getTotalTime();
mTextureInfo.setRequestSize(id, worker->mFileSize);
mTextureInfo.setRequestCompleteTimeAndLog(id, timeNow);
}
@@ -3454,33 +3566,33 @@ S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& r
void LLTextureFetch::dump()
{
- llinfos << "LLTextureFetch REQUESTS:" << llendl;
+ LL_INFOS() << "LLTextureFetch REQUESTS:" << LL_ENDL;
for (request_queue_t::iterator iter = mRequestQueue.begin();
iter != mRequestQueue.end(); ++iter)
{
LLQueuedThread::QueuedRequest* qreq = *iter;
LLWorkerThread::WorkRequest* wreq = (LLWorkerThread::WorkRequest*)qreq;
LLTextureFetchWorker* worker = (LLTextureFetchWorker*)wreq->getWorkerClass();
- llinfos << " ID: " << worker->mID
+ LL_INFOS() << " ID: " << worker->mID
<< " PRI: " << llformat("0x%08x",wreq->getPriority())
<< " STATE: " << worker->sStateDescs[worker->mState]
- << llendl;
+ << LL_ENDL;
}
- llinfos << "LLTextureFetch ACTIVE_HTTP:" << llendl;
+ LL_INFOS() << "LLTextureFetch ACTIVE_HTTP:" << LL_ENDL;
for (queue_t::const_iterator iter(mHTTPTextureQueue.begin());
mHTTPTextureQueue.end() != iter;
++iter)
{
- llinfos << " ID: " << (*iter) << llendl;
+ LL_INFOS() << " ID: " << (*iter) << LL_ENDL;
}
- llinfos << "LLTextureFetch WAIT_HTTP_RESOURCE:" << llendl;
+ LL_INFOS() << "LLTextureFetch WAIT_HTTP_RESOURCE:" << LL_ENDL;
for (wait_http_res_queue_t::const_iterator iter(mHttpWaitResource.begin());
mHttpWaitResource.end() != iter;
++iter)
{
- llinfos << " ID: " << (*iter) << llendl;
+ LL_INFOS() << " ID: " << (*iter) << LL_ENDL;
}
}
@@ -3798,7 +3910,7 @@ AssetReportHandler stats_handler;
bool
TFReqSetRegion::doWork(LLTextureFetch *)
{
- LLViewerAssetStatsFF::set_region_thread1(mRegionHandle);
+ LLViewerAssetStatsFF::set_region(mRegionHandle);
return true;
}
@@ -3823,8 +3935,8 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
static const U32 report_priority(1);
static LLCore::HttpHandler * const handler(fetcher->isQAMode() || true ? &stats_handler : NULL);
- if (! gViewerAssetStatsThread1)
- return true;
+ //if (! gViewerAssetStatsThread1)
+ // return true;
static volatile bool reporting_started(false);
static volatile S32 report_sequence(0);
@@ -3834,17 +3946,21 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
// but leave it in 'this'. Destructor will rid us of it.
LLViewerAssetStats & main_stats = *mMainStats;
- // Merge existing stats into those from main, convert to LLSD
- main_stats.merge(*gViewerAssetStatsThread1);
- LLSD merged_llsd = main_stats.asLLSD(true);
-
- // Add some additional meta fields to the content
- merged_llsd["session_id"] = mSessionID;
- merged_llsd["agent_id"] = mAgentID;
- merged_llsd["message"] = "ViewerAssetMetrics"; // Identifies the type of metrics
- merged_llsd["sequence"] = report_sequence; // Sequence number
- merged_llsd["initial"] = ! reporting_started; // Initial data from viewer
- merged_llsd["break"] = LLTextureFetch::svMetricsDataBreak; // Break in data prior to this report
+ LLViewerAssetStats::AssetStats stats;
+ main_stats.getStats(stats, true);
+ //LLSD merged_llsd = main_stats.asLLSD();
+
+ bool initial_report = !reporting_started;
+ stats.session_id = mSessionID;
+ stats.agent_id = mAgentID;
+ stats.message = "ViewerAssetMetrics";
+ stats.sequence = static_cast<bool>(report_sequence);
+ stats.initial = initial_report;
+ stats.break_ = static_cast<bool>(LLTextureFetch::svMetricsDataBreak);
+
+ LLSD sd;
+ LLParamSDParser parser;
+ parser.writeSD(sd, stats);
// Update sequence number
if (S32_MAX == ++report_sequence)
@@ -3852,13 +3968,14 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
reporting_started = true;
// Limit the size of the stats report if necessary.
- merged_llsd["truncated"] = truncate_viewer_metrics(10, merged_llsd);
+
+ sd["truncated"] = truncate_viewer_metrics(10, sd);
if (! mCapsURL.empty())
{
LLCore::BufferArray * ba = new LLCore::BufferArray;
LLCore::BufferArrayStream bas(ba);
- LLSDSerialize::toXML(merged_llsd, bas);
+ LLSDSerialize::toXML(sd, bas);
fetcher->getHttpRequest().requestPost(fetcher->getPolicyClass(),
report_priority,
@@ -3878,11 +3995,9 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
// In QA mode, Metrics submode, log the result for ease of testing
if (fetcher->isQAMode())
{
- LL_INFOS("Textures") << ll_pretty_print_sd(merged_llsd) << LL_ENDL;
+ LL_INFOS("Textures") << ll_pretty_print_sd(sd) << LL_ENDL;
}
- gViewerAssetStatsThread1->reset();
-
return true;
}
@@ -4009,7 +4124,7 @@ LLTextureFetchDebugger::~LLTextureFetchDebugger()
void LLTextureFetchDebugger::init()
{
- mState = IDLE;
+ setDebuggerState(IDLE);
mCacheReadTime = -1.f;
mCacheWriteTime = -1.f;
@@ -4106,7 +4221,7 @@ void LLTextureFetchDebugger::startDebug()
//clear the current fetching queue
gTextureList.clearFetchingRequests();
- mState = START_DEBUG;
+ setDebuggerState(START_DEBUG);
}
bool LLTextureFetchDebugger::processStartDebug(F32 max_time)
@@ -4181,7 +4296,7 @@ void LLTextureFetchDebugger::tryToStopDebug()
//clear the current debug work
S32 size = mFetchingHistory.size();
- switch(mState)
+ switch(mDebuggerState)
{
case READ_CACHE:
for(S32 i = 0 ; i < size; i++)
@@ -4254,7 +4369,7 @@ void LLTextureFetchDebugger::addHistoryEntry(LLTextureFetchWorker* worker)
if(mFreezeHistory)
{
- if(mState == REFETCH_VIS_CACHE || mState == REFETCH_VIS_HTTP)
+ if(mDebuggerState == REFETCH_VIS_CACHE || mDebuggerState == REFETCH_VIS_HTTP)
{
mRefetchedVisPixels += worker->mRawImage->getWidth() * worker->mRawImage->getHeight();
mRefetchedVisData += worker->mFormattedImage->getDataSize();
@@ -4299,9 +4414,9 @@ void LLTextureFetchDebugger::unlockCache()
void LLTextureFetchDebugger::debugCacheRead()
{
lockCache();
- llassert_always(mState == IDLE);
+ llassert_always(mDebuggerState == IDLE);
mTimer.reset();
- mState = READ_CACHE;
+ setDebuggerState(READ_CACHE);
mCacheReadTime = -1.f;
S32 size = mFetchingHistory.size();
@@ -4335,9 +4450,9 @@ void LLTextureFetchDebugger::debugCacheWrite()
clearCache();
lockCache();
- llassert_always(mState == IDLE);
+ llassert_always(mDebuggerState == IDLE);
mTimer.reset();
- mState = WRITE_CACHE;
+ setDebuggerState(WRITE_CACHE);
mCacheWriteTime = -1.f;
S32 size = mFetchingHistory.size();
@@ -4364,9 +4479,9 @@ void LLTextureFetchDebugger::unlockDecoder()
void LLTextureFetchDebugger::debugDecoder()
{
lockDecoder();
- llassert_always(mState == IDLE);
+ llassert_always(mDebuggerState == IDLE);
mTimer.reset();
- mState = DECODING;
+ setDebuggerState(DECODING);
mDecodingTime = -1.f;
S32 size = mFetchingHistory.size();
@@ -4385,24 +4500,24 @@ void LLTextureFetchDebugger::debugDecoder()
void LLTextureFetchDebugger::debugHTTP()
{
- llassert_always(mState == IDLE);
+ llassert_always(mDebuggerState == IDLE);
LLViewerRegion* region = gAgent.getRegion();
if (!region)
{
- llinfos << "Fetch Debugger : Current region undefined. Cannot fetch textures through HTTP." << llendl;
+ LL_INFOS() << "Fetch Debugger : Current region undefined. Cannot fetch textures through HTTP." << LL_ENDL;
return;
}
mHTTPUrl = region->getHttpUrl();
if (mHTTPUrl.empty())
{
- llinfos << "Fetch Debugger : Current region URL undefined. Cannot fetch textures through HTTP." << llendl;
+ LL_INFOS() << "Fetch Debugger : Current region URL undefined. Cannot fetch textures through HTTP." << LL_ENDL;
return;
}
mTimer.reset();
- mState = HTTP_FETCHING;
+ setDebuggerState(HTTP_FETCHING);
mHTTPTime = -1.f;
S32 size = mFetchingHistory.size();
@@ -4476,14 +4591,14 @@ S32 LLTextureFetchDebugger::fillCurlQueue()
mFetchingHistory[i].mCurlState = FetchEntry::CURL_DONE;
}
}
- //llinfos << "Fetch Debugger : Having " << mNbCurlRequests << " requests through the curl thread." << llendl;
+ //LL_INFOS() << "Fetch Debugger : Having " << mNbCurlRequests << " requests through the curl thread." << LL_ENDL;
return mNbCurlRequests;
}
void LLTextureFetchDebugger::debugGLTextureCreation()
{
- llassert_always(mState == IDLE);
- mState = GL_TEX;
+ llassert_always(mDebuggerState == IDLE);
+ setDebuggerState(GL_TEX);
mTempTexList.clear();
S32 size = mFetchingHistory.size();
@@ -4604,8 +4719,8 @@ void LLTextureFetchDebugger::scanRefetchList()
void LLTextureFetchDebugger::debugRefetchVisibleFromCache()
{
- llassert_always(mState == IDLE);
- mState = REFETCH_VIS_CACHE;
+ llassert_always(mDebuggerState == IDLE);
+ setDebuggerState(REFETCH_VIS_CACHE);
clearTextures();
mFetcher->setLoadSource(LLTextureFetch::FROM_ALL);
@@ -4619,8 +4734,8 @@ void LLTextureFetchDebugger::debugRefetchVisibleFromCache()
void LLTextureFetchDebugger::debugRefetchVisibleFromHTTP()
{
- llassert_always(mState == IDLE);
- mState = REFETCH_VIS_HTTP;
+ llassert_always(mDebuggerState == IDLE);
+ setDebuggerState(REFETCH_VIS_HTTP);
clearTextures();
mFetcher->setLoadSource(LLTextureFetch::FROM_HTTP_ONLY);
@@ -4634,8 +4749,8 @@ void LLTextureFetchDebugger::debugRefetchVisibleFromHTTP()
void LLTextureFetchDebugger::debugRefetchAllFromCache()
{
- llassert_always(mState == IDLE);
- mState = REFETCH_ALL_CACHE;
+ llassert_always(mDebuggerState == IDLE);
+ setDebuggerState(REFETCH_ALL_CACHE);
clearTextures();
makeRefetchList();
@@ -4651,8 +4766,8 @@ void LLTextureFetchDebugger::debugRefetchAllFromCache()
void LLTextureFetchDebugger::debugRefetchAllFromHTTP()
{
- llassert_always(mState == IDLE);
- mState = REFETCH_ALL_HTTP;
+ llassert_always(mDebuggerState == IDLE);
+ setDebuggerState(REFETCH_ALL_HTTP);
clearTextures();
makeRefetchList();
@@ -4668,19 +4783,19 @@ void LLTextureFetchDebugger::debugRefetchAllFromHTTP()
bool LLTextureFetchDebugger::update(F32 max_time)
{
- switch(mState)
+ switch(mDebuggerState)
{
case START_DEBUG:
if(processStartDebug(max_time))
{
- mState = IDLE;
+ setDebuggerState(IDLE);
}
break;
case READ_CACHE:
if(!mTextureCache->update(1))
{
mCacheReadTime = mTimer.getElapsedTimeF32() ;
- mState = IDLE;
+ setDebuggerState(IDLE);
unlockCache();
}
break;
@@ -4688,7 +4803,7 @@ bool LLTextureFetchDebugger::update(F32 max_time)
if(!mTextureCache->update(1))
{
mCacheWriteTime = mTimer.getElapsedTimeF32() ;
- mState = IDLE;
+ setDebuggerState(IDLE);
unlockCache();
}
break;
@@ -4696,7 +4811,7 @@ bool LLTextureFetchDebugger::update(F32 max_time)
if(!mImageDecodeThread->update(1))
{
mDecodingTime = mTimer.getElapsedTimeF32() ;
- mState = IDLE;
+ setDebuggerState(IDLE);
unlockDecoder();
}
break;
@@ -4706,13 +4821,13 @@ bool LLTextureFetchDebugger::update(F32 max_time)
if (!fillCurlQueue() && mNbCurlCompleted == mFetchingHistory.size())
{
mHTTPTime = mTimer.getElapsedTimeF32() ;
- mState = IDLE;
+ setDebuggerState(IDLE);
}
break;
case GL_TEX:
if(processGLCreation(max_time))
{
- mState = IDLE;
+ setDebuggerState(IDLE);
mTempTexList.clear();
}
break;
@@ -4720,7 +4835,7 @@ bool LLTextureFetchDebugger::update(F32 max_time)
if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
{
mRefetchVisCacheTime = mTimer.getElapsedTimeF32() ;
- mState = IDLE;
+ setDebuggerState(IDLE);
mFetcher->lockFetcher(true);
mFetcher->resetLoadSource();
}
@@ -4729,7 +4844,7 @@ bool LLTextureFetchDebugger::update(F32 max_time)
if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
{
mRefetchVisHTTPTime = mTimer.getElapsedTimeF32() ;
- mState = IDLE;
+ setDebuggerState(IDLE);
mFetcher->lockFetcher(true);
mFetcher->resetLoadSource();
}
@@ -4746,7 +4861,7 @@ bool LLTextureFetchDebugger::update(F32 max_time)
}
mRefetchAllCacheTime = mTimer.getElapsedTimeF32() ;
- mState = IDLE;
+ setDebuggerState(IDLE);
mFetcher->lockFetcher(true);
mFetcher->resetLoadSource();
mRefetchList.clear();
@@ -4758,7 +4873,7 @@ bool LLTextureFetchDebugger::update(F32 max_time)
if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
{
mRefetchAllHTTPTime = mTimer.getElapsedTimeF32() ;
- mState = IDLE;
+ setDebuggerState(IDLE);
mFetcher->lockFetcher(true);
mFetcher->resetLoadSource();
mRefetchList.clear();
@@ -4766,11 +4881,11 @@ bool LLTextureFetchDebugger::update(F32 max_time)
}
break;
default:
- mState = IDLE;
+ setDebuggerState(IDLE);
break;
}
- return mState == IDLE;
+ return mDebuggerState == IDLE;
}
void LLTextureFetchDebugger::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response)
@@ -4778,7 +4893,7 @@ void LLTextureFetchDebugger::onCompleted(LLCore::HttpHandle handle, LLCore::Http
handle_fetch_map_t::iterator iter(mHandleToFetchIndex.find(handle));
if (mHandleToFetchIndex.end() == iter)
{
- llinfos << "Fetch Debugger : Couldn't find handle " << handle << " in fetch list." << llendl;
+ LL_INFOS() << "Fetch Debugger : Couldn't find handle " << handle << " in fetch list." << LL_ENDL;
return;
}
@@ -4786,7 +4901,7 @@ void LLTextureFetchDebugger::onCompleted(LLCore::HttpHandle handle, LLCore::Http
mHandleToFetchIndex.erase(iter);
if (fetch_ind >= mFetchingHistory.size() || mFetchingHistory[fetch_ind].mHttpHandle != handle)
{
- llinfos << "Fetch Debugger : Handle and fetch object in disagreement. Punting." << llendl;
+ LL_INFOS() << "Fetch Debugger : Handle and fetch object in disagreement. Punting." << LL_ENDL;
}
else
{
@@ -4836,7 +4951,7 @@ void LLTextureFetchDebugger::callbackHTTP(FetchEntry & fetch, LLCore::HttpRespon
S32 data_size = ba ? ba->size() : 0;
fetch.mCurlReceivedSize += data_size;
- //llinfos << "Fetch Debugger : got results for " << fetch.mID << ", data_size = " << data_size << ", received = " << fetch.mCurlReceivedSize << ", requested = " << fetch.mRequestedSize << ", partial = " << partial << llendl;
+ //LL_INFOS() << "Fetch Debugger : got results for " << fetch.mID << ", data_size = " << data_size << ", received = " << fetch.mCurlReceivedSize << ", requested = " << fetch.mRequestedSize << ", partial = " << partial << LL_ENDL;
if ((fetch.mCurlReceivedSize >= fetch.mRequestedSize) || !partial || (fetch.mRequestedSize == 600))
{
U8* d_buffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), data_size);
@@ -4862,9 +4977,9 @@ void LLTextureFetchDebugger::callbackHTTP(FetchEntry & fetch, LLCore::HttpRespon
}
else //failed
{
- llinfos << "Fetch Debugger : CURL GET FAILED, ID = " << fetch.mID
+ LL_INFOS() << "Fetch Debugger : CURL GET FAILED, ID = " << fetch.mID
<< ", status: " << status.toTerseString()
- << " reason: " << status.toString() << llendl;
+ << " reason: " << status.toString() << LL_ENDL;
}
}