summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2024-01-09 23:16:57 +0200
committerGitHub <noreply@github.com>2024-01-09 23:16:57 +0200
commit305fe845c6058177c84c7f8d49c3faedec2e8282 (patch)
tree66d94a4d09201cbe80a4d525da460269b68fa1cb /indra
parentafe91b7eb68da65687beef451bd094ff0091b717 (diff)
SL-20779 More reliable decode and encode error logging (#615)
Diffstat (limited to 'indra')
-rw-r--r--indra/llimage/llimage.cpp13
-rw-r--r--indra/llimage/llimage.h5
-rw-r--r--indra/llimage/llimageworker.cpp19
-rw-r--r--indra/llimage/llimageworker.h2
-rw-r--r--indra/newview/llfloatersimplesnapshot.cpp6
-rw-r--r--indra/newview/llpanelprofile.cpp2
-rw-r--r--indra/newview/lltexturefetch.cpp10
-rw-r--r--indra/newview/llviewerassetupload.cpp2
-rw-r--r--indra/newview/llviewermenufile.cpp2
9 files changed, 33 insertions, 28 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 031471d1fe..9c0cc8d760 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -584,8 +584,7 @@ static void bilinear_scale(const U8 *src, U32 srcW, U32 srcH, U32 srcCh, U32 src
//---------------------------------------------------------------------------
//static
-std::string LLImage::sLastErrorMessage;
-LLMutex* LLImage::sMutex = NULL;
+thread_local std::string LLImage::sLastThreadErrorMessage;
bool LLImage::sUseNewByteRange = false;
S32 LLImage::sMinimalReverseByteRangePercent = 75;
@@ -594,28 +593,24 @@ void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_
{
sUseNewByteRange = use_new_byte_range;
sMinimalReverseByteRangePercent = minimal_reverse_byte_range_percent;
- sMutex = new LLMutex();
}
//static
void LLImage::cleanupClass()
{
- delete sMutex;
- sMutex = NULL;
}
//static
-const std::string& LLImage::getLastError()
+const std::string& LLImage::getLastThreadError()
{
static const std::string noerr("No Error");
- return sLastErrorMessage.empty() ? noerr : sLastErrorMessage;
+ return sLastThreadErrorMessage.empty() ? noerr : sLastThreadErrorMessage;
}
//static
void LLImage::setLastError(const std::string& message)
{
- LLMutexLock m(sMutex);
- sLastErrorMessage = message;
+ sLastThreadErrorMessage = message;
}
//---------------------------------------------------------------------------
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 8f9e1b3c54..01b6642e1e 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -95,15 +95,14 @@ public:
static void initClass(bool use_new_byte_range = false, S32 minimal_reverse_byte_range_percent = 75);
static void cleanupClass();
- static const std::string& getLastError();
+ static const std::string& getLastThreadError();
static void setLastError(const std::string& message);
static bool useNewByteRange() { return sUseNewByteRange; }
static S32 getReverseByteRangePercent() { return sMinimalReverseByteRangePercent; }
protected:
- static LLMutex* sMutex;
- static std::string sLastErrorMessage;
+ static thread_local std::string sLastThreadErrorMessage;
static bool sUseNewByteRange;
static S32 sMinimalReverseByteRangePercent;
};
diff --git a/indra/llimage/llimageworker.cpp b/indra/llimage/llimageworker.cpp
index c1ee052997..e09f6a0a13 100644
--- a/indra/llimage/llimageworker.cpp
+++ b/indra/llimage/llimageworker.cpp
@@ -55,6 +55,7 @@ private:
BOOL mDecodedRaw;
BOOL mDecodedAux;
LLPointer<LLImageDecodeThread::Responder> mResponder;
+ std::string mErrorString;
};
@@ -149,8 +150,9 @@ ImageRequest::~ImageRequest()
bool ImageRequest::processRequest()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
- const F32 decode_time_slice = 0.f; //disable time slicing
- bool done = true;
+ const F32 decode_time_slice = 0.f; //disable time slicing
+ bool done = true;
+ mErrorString.clear();
if (!mDecodedRaw && mFormattedImage.notNull())
{
// Decode primary channels
@@ -159,10 +161,13 @@ bool ImageRequest::processRequest()
// parse formatted header
if (!mFormattedImage->updateData())
{
+ // Pick up errors from updateData
+ mErrorString = LLImage::getLastThreadError();
return true; // done (failed)
}
if (!(mFormattedImage->getWidth() * mFormattedImage->getHeight() * mFormattedImage->getComponents()))
{
+ mErrorString = "Invalid image size";
return true; // done (failed)
}
if (mDiscardLevel >= 0)
@@ -176,6 +181,9 @@ bool ImageRequest::processRequest()
done = mFormattedImage->decode(mDecodedImageRaw, decode_time_slice);
// some decoders are removing data when task is complete and there were errors
mDecodedRaw = done && mDecodedImageRaw->getData();
+
+ // Pick up errors from decoding
+ mErrorString = LLImage::getLastThreadError();
}
if (done && mNeedsAux && !mDecodedAux && mFormattedImage.notNull())
{
@@ -188,7 +196,10 @@ bool ImageRequest::processRequest()
}
done = mFormattedImage->decodeChannels(mDecodedImageAux, decode_time_slice, 4, 4);
mDecodedAux = done && mDecodedImageAux->getData();
- }
+
+ // Pick up errors from decoding
+ mErrorString = LLImage::getLastThreadError();
+ }
return done;
}
@@ -199,7 +210,7 @@ void ImageRequest::finishRequest(bool completed)
if (mResponder.notNull())
{
bool success = completed && mDecodedRaw && (!mNeedsAux || mDecodedAux);
- mResponder->completed(success, mDecodedImageRaw, mDecodedImageAux);
+ mResponder->completed(success, mErrorString, mDecodedImageRaw, mDecodedImageAux);
}
// Will automatically be deleted
}
diff --git a/indra/llimage/llimageworker.h b/indra/llimage/llimageworker.h
index ca4c0d93d0..c48c8084ee 100644
--- a/indra/llimage/llimageworker.h
+++ b/indra/llimage/llimageworker.h
@@ -39,7 +39,7 @@ public:
protected:
virtual ~Responder();
public:
- virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux) = 0;
+ virtual void completed(bool success, const std::string& error_message, LLImageRaw* raw, LLImageRaw* aux) = 0;
};
public:
diff --git a/indra/newview/llfloatersimplesnapshot.cpp b/indra/newview/llfloatersimplesnapshot.cpp
index 58604c5628..40d5a5ed84 100644
--- a/indra/newview/llfloatersimplesnapshot.cpp
+++ b/indra/newview/llfloatersimplesnapshot.cpp
@@ -370,7 +370,7 @@ void LLFloaterSimpleSnapshot::onSend()
else
{
LLSD notif_args;
- notif_args["REASON"] = LLImage::getLastError().c_str();
+ notif_args["REASON"] = LLImage::getLastThreadError().c_str();
LLNotificationsUtil::add("CannotUploadTexture", notif_args);
}
}
@@ -389,7 +389,7 @@ void LLFloaterSimpleSnapshot::uploadThumbnail(const std::string &file_path, cons
if (!LLViewerTextureList::createUploadFile(file_path, temp_file, codec, THUMBNAIL_SNAPSHOT_DIM_MAX, THUMBNAIL_SNAPSHOT_DIM_MIN, true))
{
LLSD notif_args;
- notif_args["REASON"] = LLImage::getLastError().c_str();
+ notif_args["REASON"] = LLImage::getLastThreadError().c_str();
LLNotificationsUtil::add("CannotUploadTexture", notif_args);
LL_WARNS("Thumbnail") << "Failed to upload thumbnail for " << inventory_id << " " << task_id << ", reason: " << notif_args["REASON"].asString() << LL_ENDL;
return;
@@ -404,7 +404,7 @@ void LLFloaterSimpleSnapshot::uploadThumbnail(LLPointer<LLImageRaw> raw_image, c
if (!LLViewerTextureList::createUploadFile(raw_image, temp_file, THUMBNAIL_SNAPSHOT_DIM_MAX, THUMBNAIL_SNAPSHOT_DIM_MIN))
{
LLSD notif_args;
- notif_args["REASON"] = LLImage::getLastError().c_str();
+ notif_args["REASON"] = LLImage::getLastThreadError().c_str();
LLNotificationsUtil::add("CannotUploadTexture", notif_args);
LL_WARNS("Thumbnail") << "Failed to upload thumbnail for " << inventory_id << " " << task_id << ", reason: " << notif_args["REASON"].asString() << LL_ENDL;
return;
diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp
index 55ddeed4ec..67c942b267 100644
--- a/indra/newview/llpanelprofile.cpp
+++ b/indra/newview/llpanelprofile.cpp
@@ -1369,7 +1369,7 @@ void LLProfileImagePicker::notify(const std::vector<std::string>& filenames)
if (!LLViewerTextureList::createUploadFile(file_path, temp_file, codec, MAX_DIM))
{
LLSD notif_args;
- notif_args["REASON"] = LLImage::getLastError().c_str();
+ notif_args["REASON"] = LLImage::getLastThreadError().c_str();
LLNotificationsUtil::add("CannotUploadTexture", notif_args);
LL_WARNS("AvatarProperties") << "Failed to upload profile image of type " << (S32)mType << ", " << notif_args["REASON"].asString() << LL_ENDL;
return;
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 38c9b3717d..a8fc3d295c 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -348,13 +348,13 @@ private:
}
// Threads: Tid
- virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux)
+ virtual void completed(bool success, const std::string& error_message, LLImageRaw* raw, LLImageRaw* aux)
{
LL_PROFILE_ZONE_SCOPED;
LLTextureFetchWorker* worker = mFetcher->getWorker(mID);
if (worker)
{
- worker->callbackDecoded(success, raw, aux);
+ worker->callbackDecoded(success, error_message, raw, aux);
}
}
private:
@@ -398,7 +398,7 @@ public:
void callbackCacheWrite(bool success);
// Threads: Tid
- void callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux);
+ void callbackDecoded(bool success, const std::string& error_message, LLImageRaw* raw, LLImageRaw* aux);
// Threads: T*
void setGetStatus(LLCore::HttpStatus status, const std::string& reason)
@@ -2305,7 +2305,7 @@ void LLTextureFetchWorker::callbackCacheWrite(bool success)
//////////////////////////////////////////////////////////////////////////////
// Threads: Tid
-void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImageRaw* aux)
+void LLTextureFetchWorker::callbackDecoded(bool success, const std::string &error_message, LLImageRaw* raw, LLImageRaw* aux)
{
LLMutexLock lock(&mWorkMutex); // +Mw
if (mDecodeHandle == 0)
@@ -2332,7 +2332,7 @@ void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImag
}
else
{
- LL_WARNS(LOG_TXT) << "DECODE FAILED: " << mID << " Discard: " << (S32)mFormattedImage->getDiscardLevel() << LL_ENDL;
+ LL_WARNS(LOG_TXT) << "DECODE FAILED: " << mID << " Discard: " << (S32)mFormattedImage->getDiscardLevel() << ", reason: " << error_message << LL_ENDL;
removeFromCache();
mDecodedDiscard = -1; // Redundant, here for clarity and paranoia
}
diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp
index e2e321af0d..9d95c8d054 100644
--- a/indra/newview/llviewerassetupload.cpp
+++ b/indra/newview/llviewerassetupload.cpp
@@ -417,7 +417,7 @@ LLSD LLNewFileResourceUploadInfo::exportTempFile()
if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec))
{
errorMessage = llformat("Problem with file %s:\n\n%s\n",
- getFileName().c_str(), LLImage::getLastError().c_str());
+ getFileName().c_str(), LLImage::getLastThreadError().c_str());
errorLabel = "ProblemWithFile";
error = true;
}
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 5461e0f362..fe5fee6ee6 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -947,7 +947,7 @@ void handle_compress_image(void*)
}
else
{
- LL_INFOS() << "Compression failed: " << LLImage::getLastError() << LL_ENDL;
+ LL_INFOS() << "Compression failed: " << LLImage::getLastThreadError() << LL_ENDL;
}
infile = picker.getNextFile();