Bug 1321522: Add null check and logging on fontResource in RecordedScaledFontCreation::PlayEvent. r=milan a=gchang
MozReview-Commit-ID: 3nM28xgGLPO
--- a/gfx/2d/Logging.h
+++ b/gfx/2d/Logging.h
@@ -124,16 +124,17 @@ enum class LogReason : int {
InvalidContext,
InvalidCommandList,
AsyncTransactionTimeout, // 30
TextureCreation,
InvalidCacheSurface,
AlphaWithBasicClient,
UnbalancedClipStack,
ProcessingError,
+ NativeFontResourceNotFound,
// End
MustBeLessThanThis = 101,
};
struct BasicLogger
{
// For efficiency, this method exists and copies the logic of the
// OutputMessage below. If making any changes here, also make it
--- a/gfx/2d/RecordedEvent.cpp
+++ b/gfx/2d/RecordedEvent.cpp
@@ -1639,16 +1639,22 @@ RecordedFontDescriptor::RecordedFontDesc
mData.resize(size);
aStream.read((char*)&mData[0], size);
}
bool
RecordedScaledFontCreation::PlayEvent(Translator *aTranslator) const
{
NativeFontResource *fontResource = aTranslator->LookupNativeFontResource(mFontDataKey);
+ if (!fontResource) {
+ gfxDevCrash(LogReason::NativeFontResourceNotFound) <<
+ "NativeFontResource lookup failed for key |" << hexa(mFontDataKey) << "|.";
+ return false;
+ }
+
RefPtr<ScaledFont> scaledFont = fontResource->CreateScaledFont(mIndex, mGlyphSize);
aTranslator->AddScaledFont(mRefPtr, scaledFont);
return true;
}
void
RecordedScaledFontCreation::RecordToStream(std::ostream &aStream) const
{