Bug 1656261 - Disable StartupCaching of Omnijar zip central r=froydnj

This is a speculative fix for a crash we're seeing due to xul.css ostensibly
not existing. The theory is that xul.css does in fact exist and the cached
zip central for the omnijar is simply corrupt in some way. If it is corrupt in
this way, then there is a bigger issue, and we need to investigate deeper.

However, the benefit of this approach is that it is a very small and contained
patch which should be simple to uplift.

Differential Revision: https://phabricator.services.mozilla.com/D86829
This commit is contained in:
Doug Thayer 2020-08-13 17:34:05 +00:00
Родитель 9eb0dfc2fa
Коммит 66f210cc61
1 изменённых файлов: 2 добавлений и 35 удалений

Просмотреть файл

@ -92,41 +92,8 @@ void Omnijar::InitOne(nsIFile* aPath, Type aType) {
}
RefPtr<nsZipArchive> zipReader = new nsZipArchive();
auto* cache = scache::StartupCache::GetSingleton();
const uint8_t* centralBuf = nullptr;
uint32_t centralBufLength = 0;
nsCString startupCacheKey =
nsPrintfCString("::%s:OmnijarCentral", sCachePrefixes[aType]);
if (cache) {
nsresult rv = cache->GetBuffer(startupCacheKey.get(),
reinterpret_cast<const char**>(&centralBuf),
&centralBufLength);
if (NS_FAILED(rv)) {
centralBuf = nullptr;
centralBufLength = 0;
}
}
if (!centralBuf) {
if (NS_FAILED(zipReader->OpenArchive(file))) {
return;
}
if (cache) {
size_t bufSize;
// Annoyingly, nsZipArchive and the startupcache use different types to
// represent bytes (uint8_t vs char), so we have to do a little dance to
// convert the UniquePtr over.
UniquePtr<char[]> centralBuf(reinterpret_cast<char*>(
zipReader->CopyCentralDirectoryBuffer(&bufSize).release()));
if (centralBuf) {
cache->PutBuffer(startupCacheKey.get(), std::move(centralBuf), bufSize);
}
}
} else {
if (NS_FAILED(zipReader->LazyOpenArchive(
file, Span(centralBuf, centralBufLength)))) {
return;
}
if (NS_FAILED(zipReader->OpenArchive(file))) {
return;
}
RefPtr<nsZipArchive> outerReader;