Merge branch 'DRTVWR-548-maint-N' of https://bitbucket.org/lindenlab/viewer

# Conflicts:
#	indra/llcommon/CMakeLists.txt
#	indra/llfilesystem/lldiskcache.cpp
#	indra/llwindow/CMakeLists.txt
#	indra/newview/app_settings/settings.xml
#	indra/newview/llappviewer.cpp
master
Ansariel 2022-06-24 22:18:44 +02:00
commit cfb6c083fe
14 changed files with 250 additions and 78 deletions

View File

@ -406,6 +406,7 @@ Cinder Roxley
STORM-2136
STORM-2144
SL-3404
SL-17634
Clara Young
Coaldust Numbers
VWR-1095

View File

@ -40,7 +40,7 @@ class LLAudioEngine_OpenAL : public LLAudioEngine
LLAudioEngine_OpenAL();
virtual ~LLAudioEngine_OpenAL();
virtual bool init(const S32 num_channels, void *user_data, const std::string &app_title);
virtual bool init(void *user_data, const std::string &app_title);
virtual std::string getDriverName(bool verbose);
virtual void allocateListener();

View File

@ -266,6 +266,11 @@ set(llcommon_HEADER_FILES
StackWalker.h
)
if (DARWIN)
list(APPEND llcommon_HEADER_FILES llsys_objc.h)
list(APPEND llcommon_SOURCE_FILES llsys_objc.mm)
endif (DARWIN)
# <FS:Beq/> Tracy Profiler support
list(APPEND llcommon_SOURCE_FILES llprofiler.cpp)
@ -351,12 +356,6 @@ target_link_libraries(
${TRACY_LIBRARY}
)
if (DARWIN)
include(CMakeFindFrameworks)
find_library(CARBON_LIBRARY Carbon)
target_link_libraries(llcommon ${CARBON_LIBRARY})
endif (DARWIN)
add_dependencies(llcommon stage_third_party_libs)
if (LL_TESTS)

View File

@ -64,6 +64,7 @@ using namespace llsd;
# include <psapi.h> // GetPerformanceInfo() et al.
# include <VersionHelpers.h>
#elif LL_DARWIN
# include "llsys_objc.h"
# include <errno.h>
# include <sys/sysctl.h>
# include <sys/utsname.h>
@ -74,12 +75,6 @@ using namespace llsd;
# include <mach/mach_host.h>
# include <mach/task.h>
# include <mach/task_info.h>
// disable warnings about Gestalt calls being deprecated
// until Apple get's on the ball and provides an alternative
//
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif LL_LINUX
# include <errno.h>
# include <sys/utsname.h>
@ -289,12 +284,9 @@ LLOSInfo::LLOSInfo() :
{
const char * DARWIN_PRODUCT_NAME = "Mac OS X";
SInt32 major_version, minor_version, bugfix_version;
OSErr r1 = Gestalt(gestaltSystemVersionMajor, &major_version);
OSErr r2 = Gestalt(gestaltSystemVersionMinor, &minor_version);
OSErr r3 = Gestalt(gestaltSystemVersionBugFix, &bugfix_version);
S32 major_version, minor_version, bugfix_version = 0;
if((r1 == noErr) && (r2 == noErr) && (r3 == noErr))
if (LLGetDarwinOSInfo(major_version, minor_version, bugfix_version))
{
mMajorVer = major_version;
mMinorVer = minor_version;
@ -1351,10 +1343,3 @@ BOOL gzip_file(const std::string& srcfile, const std::string& dstfile)
if (dst != NULL) gzclose(dst);
return retval;
}
#if LL_DARWIN
// disable warnings about Gestalt calls being deprecated
// until Apple get's on the ball and provides an alternative
//
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

View File

@ -0,0 +1,33 @@
/**
* @file llsys_objc.h
* @brief Header file for llsys_objc.mm
*
* $LicenseInfo:firstyear=2022&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2022, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLSYS_OBJC_H
#define LL_LLSYS_OBJC_H
bool LLGetDarwinOSInfo(int &major, int &minor, int &patch);
#endif // LL_LLSYS_OBJC_H

View File

@ -0,0 +1,64 @@
/**
* @file llsys_objc.mm
* @brief obj-c implementation of the system information functions
*
* $LicenseInfo:firstyear=2022&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2022, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#import "llsys_objc.h"
#import <AppKit/AppKit.h>
static int intAtStringIndex(NSArray *array, int index)
{
return [(NSString *)[array objectAtIndex:index] integerValue];
}
bool LLGetDarwinOSInfo(int &major, int &minor, int &patch)
{
if (NSAppKitVersionNumber > NSAppKitVersionNumber10_8)
{
NSOperatingSystemVersion osVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
major = osVersion.majorVersion;
minor = osVersion.minorVersion;
patch = osVersion.patchVersion;
}
else
{
NSString* versionString = [[NSDictionary dictionaryWithContentsOfFile:
@"/System/Library/CoreServices/SystemVersion.plist"] objectForKey:@"ProductVersion"];
NSArray* versions = [versionString componentsSeparatedByString:@"."];
NSUInteger count = [versions count];
if (count > 0)
{
major = intAtStringIndex(versions, 0);
if (count > 1)
{
minor = intAtStringIndex(versions, 1);
if (count > 2)
{
patch = intAtStringIndex(versions, 2);
}
}
}
}
return true;
}

View File

@ -71,9 +71,9 @@ LLDiskCache::LLDiskCache(const std::string cache_dir,
// WARNING: purge() is called by LLPurgeDiskCacheThread. As such it must
// NOT touch any LLDiskCache data without introducing and locking a mutex!
// Interaction through the filesystem itself should be safe. Lets say thread
// Interaction through the filesystem itself should be safe. Lets say thread
// A is accessing the cache file for reading/writing and thread B is trimming
// the cache. Lets also assume using llifstream to open a file and
// the cache. Lets also assume using llifstream to open a file and
// boost::filesystem::remove are not atomic (which will be pretty much the
// case).
@ -150,49 +150,87 @@ void LLDiskCache::purge()
LL_INFOS() << "Purging cache to a maximum of " << mMaxSizeBytes << " bytes" << LL_ENDL;
// <FS:Beq> Extra accounting to track the retention of static assets
//std::vector<bool> file_removed;
std::vector<S32> file_removed;
int keep{0};
int del{0};
int skip{0};
// </FS:Beq>
if (mEnableCacheDebugInfo)
{
file_removed.reserve(file_info.size());
}
uintmax_t file_size_total = 0;
for (file_info_t& entry : file_info)
{
file_size_total += entry.second.first;
std::string action = "";
if (file_size_total > mMaxSizeBytes)
bool should_remove = file_size_total > mMaxSizeBytes;
// <FS> Make sure static assets are not eliminated
S32 action{ should_remove ? 0 : 1 };
if (should_remove)
{
action = "DELETE:";
// <FS:Beq> Make sure static assets are not eliminated
auto uuid_as_string = gDirUtilp->getBaseFileName(entry.second.second,true);
uuid_as_string = uuid_as_string.substr(mCacheFilenamePrefix.size() + 1, 36);// skip "sl_cache_" and trailing "_N"
auto uuid_as_string = gDirUtilp->getBaseFileName(entry.second.second, true);
uuid_as_string = uuid_as_string.substr(mCacheFilenamePrefix.size() + 1, 36);// skip "sl_cache_" and trailing "_N"
// LL_INFOS() << "checking UUID=" <<uuid_as_string<< LL_ENDL;
if (std::find(mSkipList.begin(), mSkipList.end(), uuid_as_string) != mSkipList.end())
{
// this is one of our protected items so no purging
action = "STATIC:";
skip++;
should_remove = false;
action = 2;
updateFileAccessTime(entry.second.second); // force these to the front of the list next time so that purge size works
}
else
{
del++; // Extra accounting to track the retention of static assets
// </FS:Beq>
boost::filesystem::remove(entry.second.second, ec);
if (ec.failed())
{
LL_WARNS() << "Failed to delete cache file " << entry.second.second << ": " << ec.message() << LL_ENDL;
}
}
}
else
{
keep++; // <FS:Beq/> Extra accounting to track the retention of static assets
action = " KEEP:";
}
// </FS>
if (mEnableCacheDebugInfo)
{
// <FS> Static asset stuff
//file_removed.push_back(should_remove);
file_removed.push_back(action);
}
//std::string action = "";
if (should_remove)
{
boost::filesystem::remove(entry.second.second, ec);
if (ec.failed())
{
LL_WARNS() << "Failed to delete cache file " << entry.second.second << ": " << ec.message() << LL_ENDL;
}
}
}
if (mEnableCacheDebugInfo)
{
auto end_time = std::chrono::high_resolution_clock::now();
auto execute_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count();
// Log afterward so it doesn't affect the time measurement
// Logging thousands of file results can take hundreds of milliseconds
for (size_t i = 0; i < file_info.size(); ++i)
{
const file_info_t& entry = file_info[i];
// <FS> Static asset stuff
//const bool removed = file_removed[i];
//const std::string action = removed ? "DELETE:" : "KEEP:";
std::string action{};
switch (file_removed[i])
{
default:
case 0:
action = "KEEP";
keep++;
break;
case 1:
action = "DELETE";
del++;
break;
case 2:
action = "STATIC";
skip++;
break;
}
// </FS>
// have to do this because of LL_INFO/LL_END weirdness
std::ostringstream line;
@ -203,12 +241,7 @@ void LLDiskCache::purge()
line << " (" << file_size_total << "/" << mMaxSizeBytes << ")";
LL_INFOS() << line.str() << LL_ENDL;
}
}
if (mEnableCacheDebugInfo)
{
auto end_time = std::chrono::high_resolution_clock::now();
auto execute_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count();
LL_INFOS() << "Total dir size after purge is " << dirFileSize(mCacheDir) << LL_ENDL;
LL_INFOS() << "Cache purge took " << execute_time << " ms to execute for " << file_info.size() << " files" << LL_ENDL;
LL_INFOS() << "Deleted: " << del << " Skipped: " << skip << " Kept: " << keep << LL_ENDL; // <FS:Beq/> Extra accounting to track the retention of static assets

View File

@ -213,4 +213,10 @@ if (SDL2_FOUND)
endif ()
target_link_libraries (llwindow ${llwindow_LINK_LIBRARIES})
if (DARWIN)
include(CMakeFindFrameworks)
find_library(CARBON_LIBRARY Carbon)
target_link_libraries(llwindow ${CARBON_LIBRARY})
endif (DARWIN)

View File

@ -2939,7 +2939,7 @@
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>20.0</real>
<real>40.0</real>
</map>
<key>DiskCacheDirName</key>
<map>

View File

@ -5064,15 +5064,23 @@ bool LLAppViewer::initCache()
// initialize the new disk cache using saved settings
const std::string cache_dir_name = gSavedSettings.getString("DiskCacheDirName");
const U32 MB = 1024 * 1024;
const U64 MIN_CACHE_SIZE = 256 * MB;
const U64 MAX_CACHE_SIZE = 9984ll * MB;
const U64 setting_cache_total_size = (U64)gSavedSettings.getU32("CacheSize") * MB;
const U64 cache_total_size = llclamp(setting_cache_total_size, MIN_CACHE_SIZE, MAX_CACHE_SIZE);
// <FS:Ansariel> Better cache size control
//const F64 disk_cache_percent = gSavedSettings.getF32("DiskCachePercentOfTotal");
//const F64 texture_cache_percent = 100.0 - disk_cache_percent;
// </FS:Ansariel>
// note that the maximum size of this cache is defined as a percentage of the
// total cache size - the 'CacheSize' pref - for all caches.
// <FS:Ansariel> Better asset cache size control
//const unsigned int cache_total_size_mb = gSavedSettings.getU32("CacheSize");
//const double disk_cache_percent = gSavedSettings.getF32("DiskCachePercentOfTotal");
//const unsigned int disk_cache_mb = cache_total_size_mb * disk_cache_percent / 100;
// <FS:Ansariel> Better cache size control
//const U32 disk_cache_size = cache_total_size * disk_cache_percent / 100;
const unsigned int disk_cache_mb = gSavedSettings.getU32("FSDiskCacheSize");
const uintmax_t disk_cache_size = disk_cache_mb * 1024ULL * 1024ULL;
// </FS:Ansariel>
const uintmax_t disk_cache_bytes = disk_cache_mb * 1024ULL * 1024ULL;
const bool enable_cache_debug_info = gSavedSettings.getBOOL("EnableDiskCacheDebugInfo");
bool texture_cache_mismatch = false;
@ -5147,7 +5155,7 @@ bool LLAppViewer::initCache()
// </FS:Ansariel>
const std::string cache_dir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, cache_dir_name);
LLDiskCache::initParamSingleton(cache_dir, disk_cache_bytes, enable_cache_debug_info);
LLDiskCache::initParamSingleton(cache_dir, disk_cache_size, enable_cache_debug_info);
if (!read_only)
{
@ -5195,22 +5203,17 @@ bool LLAppViewer::initCache()
LLSplashScreen::update(LLTrans::getString("StartupInitializingTextureCache"));
// Init the texture cache
// Allocate 80% of the cache size for textures
const S32 MB = 1024 * 1024;
const S64 MIN_CACHE_SIZE = 256 * MB;
const S64 MAX_CACHE_SIZE = 9984ll * MB;
// Allocate the remaining percent which is not allocated to the disk cache
// <FS:Ansariel> Better cache size control
//const U32 texture_cache_size = cache_total_size * texture_cache_percent / 100;
const S64 texture_cache_size = (S64)cache_total_size;
// </FS:Ansariel>
S64 cache_size = (S64)(gSavedSettings.getU32("CacheSize")) * MB;
cache_size = llclamp(cache_size, MIN_CACHE_SIZE, MAX_CACHE_SIZE);
S64 texture_cache_size = cache_size;
S64 extra = LLAppViewer::getTextureCache()->initCache(LL_PATH_CACHE, texture_cache_size, texture_cache_mismatch);
texture_cache_size -= extra;
LLAppViewer::getTextureCache()->initCache(LL_PATH_CACHE, texture_cache_size, texture_cache_mismatch);
LLVOCache::getInstance()->initCache(LL_PATH_CACHE, gSavedSettings.getU32("CacheNumberOfRegionsForObjects"), getObjectCacheVersion());
return true;
return true;
}
void LLAppViewer::addOnIdleCallback(const boost::function<void()>& cb)

View File

@ -1043,7 +1043,8 @@ void LLTextureCache::setReadOnly(BOOL read_only)
mReadOnly = read_only ;
}
//called in the main thread.
// Called in the main thread.
// Returns the unused amount of max_size if any
S64 LLTextureCache::initCache(ELLPath location, S64 max_size, BOOL texture_cache_mismatch)
{
llassert_always(getPending() == 0) ; //should not start accessing the texture cache before initialized.

View File

@ -57,6 +57,7 @@
#include "llcompilequeue.h"
#include "llconsole.h"
#include "lldebugview.h"
#include "lldiskcache.h"
#include "llenvironment.h"
#include "llfilepicker.h"
#include "llfirstuse.h"
@ -2400,6 +2401,32 @@ class LLAdvancedDropPacket : public view_listener_t
}
};
//////////////////////
// PURGE DISK CACHE //
//////////////////////
class LLAdvancedPurgeDiskCache : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
LL::WorkQueue::ptr_t main_queue = LL::WorkQueue::getInstance("mainloop");
LL::WorkQueue::ptr_t general_queue = LL::WorkQueue::getInstance("General");
llassert_always(main_queue);
llassert_always(general_queue);
main_queue->postTo(
general_queue,
[]() // Work done on general queue
{
LLDiskCache::getInstance()->purge();
// Nothing needed to return
},
[](){}); // Callback to main thread is empty as there is nothing left to do
return true;
}
};
////////////////////
// EVENT Recorder //
@ -12081,6 +12108,9 @@ void initialize_menus()
view_listener_t::addMenu(new LLAdvancedDisableMessageLog(), "Advanced.DisableMessageLog");
view_listener_t::addMenu(new LLAdvancedDropPacket(), "Advanced.DropPacket");
// Advanced > Cache
view_listener_t::addMenu(new LLAdvancedPurgeDiskCache(), "Advanced.PurgeDiskCache");
// Advanced > Recorder
view_listener_t::addMenu(new LLAdvancedAgentPilot(), "Advanced.AgentPilot");
view_listener_t::addMenu(new LLAdvancedToggleAgentPilotLoop(), "Advanced.ToggleAgentPilotLoop");

View File

@ -1966,8 +1966,13 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use
}
else
{
// Check for video
LLViewerParcelMedia::getInstance()->update(parcel);
if (gNonInteractive)
{
return;
}
// Check for video
LLViewerParcelMedia::getInstance()->update(parcel);
// Then check for music
if (gAudiop)

View File

@ -4591,6 +4591,18 @@
function="Advanced.DropPacket" />
</menu_item_call>
</menu>
<menu
create_jump_keys="true"
label="Cache"
name="Cache"
tear_off="true">
<menu_item_call
label="Purge Disk Cache"
name="Purge Disk Cache">
<menu_item_call.on_click
function="Advanced.PurgeDiskCache" />
</menu_item_call>
</menu>
<menu_item_call
label="Dump Scripted Camera"
name="Dump Scripted Camera">