Bug 1776653 Part 1: Add more crash annotations when font creation happens. r=jrmuizel

Since we have evidence that CGFontCreate functions can crash, this covers
cases where we might want to know which font was being loaded.

Differential Revision: https://phabricator.services.mozilla.com/D155022
This commit is contained in:
Brad Werth 2022-08-29 17:45:51 +00:00
Родитель 5c60610612
Коммит 99da3205cc
1 изменённых файлов: 14 добавлений и 2 удалений

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

@ -729,6 +729,10 @@ bool MacOSFontEntry::SupportsOpenTypeFeature(Script aScript, uint32_t aFeatureTa
if (!cgFont) {
return mHasAATSmallCaps;
}
CrashReporter::AutoAnnotateCrashReport autoFontName(CrashReporter::Annotation::FontName,
FamilyName());
AutoCFRelease<CTFontRef> ctFont = CTFontCreateWithGraphicsFont(cgFont, 0.0, nullptr, nullptr);
if (ctFont) {
AutoCFRelease<CFArrayRef> features = CTFontCopyFeatures(ctFont);
@ -1717,6 +1721,9 @@ gfxFontEntry* gfxMacPlatformFontList::LookupLocalFont(nsPresContext* aPresContex
nsAutoreleasePool localPool;
CrashReporter::AutoAnnotateCrashReport autoFontName(CrashReporter::Annotation::FontName,
aFontName);
NSString* faceName = GetNSStringForString(NS_ConvertUTF8toUTF16(aFontName));
// lookup face based on postscript or full name
@ -1782,6 +1789,9 @@ gfxFontEntry* gfxMacPlatformFontList::MakePlatformFont(const nsACString& aFontNa
return nullptr;
}
CrashReporter::AutoAnnotateCrashReport autoFontName(CrashReporter::Annotation::FontName,
aFontName);
AutoCFRelease<CGDataProviderRef> provider =
::CGDataProviderCreateWithData(nullptr, aFontData, aLength, &ReleaseData);
AutoCFRelease<CGFontRef> fontRef = ::CGFontCreateWithDataProvider(provider);
@ -2029,8 +2039,10 @@ void gfxMacPlatformFontList::GetFacesInitDataForFamily(const fontlist::Family* a
bool aLoadCmaps) const {
nsAutoreleasePool localPool;
NS_ConvertUTF8toUTF16 name(aFamily->Key().AsString(SharedFontList()));
NSString* family = GetNSStringForString(name);
auto name = aFamily->Key().AsString(SharedFontList());
NSString* family = GetNSStringForString(NS_ConvertUTF8toUTF16(name));
CrashReporter::AutoAnnotateCrashReport autoFontName(CrashReporter::Annotation::FontName, name);
// returns an array of [psname, style name, weight, traits] elements, goofy api
NSArray* fontfaces = [sFontManager availableMembersOfFontFamily:family];