First part of work for #4498. This change forces each CEF instance to have it's own cache/cookie folder underneath the parent cef_cache folder. The whole cef_cache folder structure is purged at startup (before the parent being created at the first media instance creation)
parent
819817f5c9
commit
356b682f61
|
|
@ -38,6 +38,13 @@
|
|||
#include "volume_catcher.h"
|
||||
#include "media_plugin_base.h"
|
||||
|
||||
// _getpid()/getpid()
|
||||
#if LL_WINDOWS
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "dullahan.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -729,17 +736,34 @@ void MediaPluginCEF::receiveMessage(const char* message_string)
|
|||
std::string user_data_path_cache = message_in.getValue("cache_path");
|
||||
std::string subfolder = message_in.getValue("username");
|
||||
|
||||
// media plugin doesn't have access to gDirUtilp
|
||||
std::string path_separator;
|
||||
#if LL_WINDOWS
|
||||
path_separator = "\\";
|
||||
#else
|
||||
path_separator = "/";
|
||||
#endif
|
||||
|
||||
mRootCachePath = user_data_path_cache + "cef_cache";
|
||||
|
||||
// Issue #4498 Introduce an additional sub-folder underneath the main cache
|
||||
// folder so that each CEF media instance gets its own (as per the CEF API
|
||||
// official position). These folders will be removed at startup by Viewer code
|
||||
// so that their non-trivial size does not exhaust available disk space. This
|
||||
// begs the question - why turn on the cache at all? There are 2 reasons - firstly
|
||||
// some of the instances will benefit from per Viewer session caching and will
|
||||
// use the injected SL cookie and secondly, it's not clear how having no cache
|
||||
// interacts with the multiple simultaneous paradigm we use.
|
||||
mRootCachePath += path_separator;
|
||||
# if LL_WINDOWS
|
||||
mRootCachePath += std::to_string(_getpid());
|
||||
# else
|
||||
mRootCachePath += std::to_string(getpid());
|
||||
# endif
|
||||
|
||||
if (!subfolder.empty())
|
||||
{
|
||||
std::string delim;
|
||||
#if LL_WINDOWS
|
||||
// media plugin doesn't have access to gDirUtilp
|
||||
delim = "\\";
|
||||
#else
|
||||
delim = "/";
|
||||
#endif
|
||||
mCachePath = mRootCachePath + delim + subfolder;
|
||||
mCachePath = mRootCachePath + path_separator + subfolder;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4411,6 +4411,9 @@ bool LLAppViewer::initCache()
|
|||
const U32 CACHE_NUMBER_OF_REGIONS_FOR_OBJECTS = 128;
|
||||
LLVOCache::getInstance()->initCache(LL_PATH_CACHE, CACHE_NUMBER_OF_REGIONS_FOR_OBJECTS, getObjectCacheVersion());
|
||||
|
||||
// Remove old, stale CEF cache folders
|
||||
purgeCefStaleCaches();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -4435,18 +4438,27 @@ void LLAppViewer::loadKeyBindings()
|
|||
LLUrlRegistry::instance().setKeybindingHandler(&gViewerInput);
|
||||
}
|
||||
|
||||
// As per GHI #4498, remove old, stale CEF cache folders from previous sessions
|
||||
void LLAppViewer::purgeCefStaleCaches()
|
||||
{
|
||||
// TODO: we really shouldn't use a hard coded name for the cache folder here...
|
||||
const std::string browser_parent_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "cef_cache");
|
||||
if (LLFile::isdir(browser_parent_cache))
|
||||
{
|
||||
// This is a sledgehammer approach - nukes the cef_cache dir entirely
|
||||
// which is then recreated the first time a CEF instance creates an
|
||||
// individual cache folder. If we ever decide to retain some folders
|
||||
// e.g. Search UI cache - then we will need a more granular approach.
|
||||
gDirUtilp->deleteDirAndContents(browser_parent_cache);
|
||||
}
|
||||
}
|
||||
|
||||
void LLAppViewer::purgeCache()
|
||||
{
|
||||
LL_INFOS("AppCache") << "Purging Cache and Texture Cache..." << LL_ENDL;
|
||||
LLAppViewer::getTextureCache()->purgeCache(LL_PATH_CACHE);
|
||||
LLVOCache::getInstance()->removeCache(LL_PATH_CACHE);
|
||||
LLViewerShaderMgr::instance()->clearShaderCache();
|
||||
std::string browser_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "cef_cache");
|
||||
if (LLFile::isdir(browser_cache))
|
||||
{
|
||||
// cef does not support clear_cache and clear_cookies, so clear what we can manually.
|
||||
gDirUtilp->deleteDirAndContents(browser_cache);
|
||||
}
|
||||
gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""), "*");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ public:
|
|||
|
||||
void initGeneralThread();
|
||||
void purgeUserDataOnExit() { mPurgeUserDataOnExit = true; }
|
||||
void purgeCefStaleCaches(); // Remove old, stale CEF cache folders
|
||||
void purgeCache(); // Clear the local cache.
|
||||
void purgeCacheImmediate(); //clear local cache immediately.
|
||||
S32 updateTextureThreads(F32 max_time);
|
||||
|
|
|
|||
Loading…
Reference in New Issue