summaryrefslogtreecommitdiff
path: root/indra/newview/llmeshrepository.cpp
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2024-07-19 20:17:37 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2024-07-29 21:20:38 +0300
commitc4ff0b48898de86b9ee8e198395e16a8429c8aa4 (patch)
tree6b142eebb25f0f7fee253daa4d4b83b1d7f94a2c /indra/newview/llmeshrepository.cpp
parent5d25504f8335132d0d222b266f8772062c88b335 (diff)
viewer#2071 Properly handle 'out of memory' for meshes
Diffstat (limited to 'indra/newview/llmeshrepository.cpp')
-rw-r--r--indra/newview/llmeshrepository.cpp60
1 files changed, 54 insertions, 6 deletions
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 1c64ed6822..a1b2d502af 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -1360,7 +1360,19 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id, bool can_retry)
U8* buffer = new(std::nothrow) U8[size];
if (!buffer)
{
- LL_WARNS(LOG_MESH) << "Failed to allocate memory for skin info, size: " << size << LL_ENDL;
+ // Not sure what size is reasonable for skin info,
+ // but if 20MB allocation failed, we definetely have issues
+ const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB
+ if (size < MAX_SIZE)
+ {
+ LLError::LLUserWarningMsg::showOutOfMemory();
+ LL_ERRS() << "Bad memory allocation for skin info, size: " << size << LL_ENDL;
+ }
+ else
+ {
+ // Ignore failures for anomalously large data
+ LL_WARNS(LOG_MESH) << "Failed to allocate memory for skin info, size: " << size << LL_ENDL;
+ }
return false;
}
LLMeshRepository::sCacheBytesRead += size;
@@ -1473,7 +1485,19 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id)
U8* buffer = new(std::nothrow) U8[size];
if (!buffer)
{
- LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL;
+ // Not sure what size is reasonable for decomposition
+ // but if 20MB allocation failed, we definetely have issues
+ const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB
+ if (size < MAX_SIZE)
+ {
+ LLError::LLUserWarningMsg::showOutOfMemory();
+ LL_ERRS() << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL;
+ }
+ else
+ {
+ // Ignore failures for anomalously large decompositiions
+ LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL;
+ }
return false;
}
LLMeshRepository::sCacheBytesRead += size;
@@ -1575,7 +1599,19 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id)
U8* buffer = new(std::nothrow) U8[size];
if (!buffer)
{
- LL_WARNS(LOG_MESH) << "Failed to allocate memory for physics shape, size: " << size << LL_ENDL;
+ // Not sure what size is reasonable for physcis
+ // but if 20MB allocation failed, we definetely have issues
+ const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB
+ if (size < MAX_SIZE)
+ {
+ LLError::LLUserWarningMsg::showOutOfMemory();
+ LL_ERRS() << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL;
+ }
+ else
+ {
+ // Ignore failures for anomalously large meshes
+ LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL;
+ }
return false;
}
file.read(buffer, size);
@@ -1766,9 +1802,21 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod,
U8* buffer = new(std::nothrow) U8[size];
if (!buffer)
{
- LL_WARNS(LOG_MESH) << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL;
- // todo: for now it will result in indefinite constant retries, should result in timeout
- // or in retry-count and disabling mesh. (but usually viewer is beyond saving at this point)
+ // Not sure what size is reasonable for a mesh,
+ // but if 20MB allocation failed, we definetely have issues
+ const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB
+ if (size < MAX_SIZE)
+ {
+ LLError::LLUserWarningMsg::showOutOfMemory();
+ LL_ERRS() << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL;
+ }
+ else
+ {
+ // Ignore failures for anomalously large data
+ LL_WARNS(LOG_MESH) << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL;
+ // todo: for now it will result in indefinite constant retries, should result in timeout
+ // or in retry-count and disabling mesh. (but usually viewer is beyond saving at this point)
+ }
return false;
}
LLMeshRepository::sCacheBytesRead += size;